These are chat archives for ChaiScript/ChaiScript

19th
Jan 2018
NiklasRosenstein
@NiklasRosenstein
Jan 19 2018 20:31
Hi! Quick question: Would it be (or is it already) possible to compile the main portion of Chai into a static library ? I think this would reduce compilation times very drastically. As a positive side-effect, it would overcome the requirement of compiling every translation unit that uses chai with /bigobj.
Jason Turner
@lefticus
Jan 19 2018 20:38
that is exactly how the official cmakelists builds chaiscript
2 static libraries and one executable
NiklasRosenstein
@NiklasRosenstein
Jan 19 2018 20:45
Hm, I can see that in the CMakeLists.txt -- I like to believe that I'm doing it the same way (well, almost, as I currently only build a single static library from the two .cpp files in static_libs), however I fail to see how all this code that is compiled into the static libraries should suddenly be "disabled", without any special preprocessor definitions or the like, when compiling the main executable.
To be honest, the CMake script confuses me a little bit.
NiklasRosenstein
@NiklasRosenstein
Jan 19 2018 20:51

Chai_INCLUDES is passed to the chai executable in line 282

add_executable(chai src/main.cpp ${Chai_INCLUDES})

Why are the headers files additional input source files for the compiler? Wouldn't CMake create separate translation units for each source file (and in this case, for headers files?)

Maybe understanding that solves the mystery of compiling the static library and main executable properly. :)

Thanks for your time if you can spare some.

Jason Turner
@lefticus
Jan 19 2018 20:52
Those headers are added for the sake of the IDE, so you can see which files are used. The key is that in main.cpp I'm only including the bits that are necessary: https://github.com/ChaiScript/ChaiScript/blob/develop/src/main.cpp#L19-L21
the chaiscript_basic header doesn't require the stdlib and parser code to be parsed/compiled
NiklasRosenstein
@NiklasRosenstein
Jan 19 2018 20:54
Aha! Mystery solved, thank you very much.
My swift eyes must have dismissed that part of main.cpp
Jason Turner
@lefticus
Jan 19 2018 21:43
BTW to all those watching the issues with MSVC, I believe they are fully fixed on develop now. Please report with all compiler flags used if you continue to have issues.
Stefan Agartsson
@Zephyrox_twitter
Jan 19 2018 23:06
@lefticus hey, sorry for the late reply! It seems to work even with /std::c++latest