There are often many swiches to enable/disable when trying to build a project that uses CMake.
How do you store the build settings made by some user to make a build reproduceable on another machine? Is there some kind of export functionality or do you just copy the build (cache) folder?
There is an option to pre-load a script for populating the cache file with cmake using
The initial-cache is a file containing variables set in the following way, e.g. for the install prefix:
Then just pass this file while populating the cache with cmake. Easy, but I didn't know that and found no good sample. As a plus, this is an platform independent way instead of writing a script or batch file.
I create a separate script folder next to the sources out of the generated out-of-source build folder. My files containing the settings are stored there for each lib/executable to build.
You can put all the settings into a separate file and at the end of the day there are just a few calls left:
Simple, isn't it?
Automatically generate
initial-cache
file:If you are on a *nix system you can run the following inside your build dir:
On Windows, something like the following
cmake
script should work:Save it to, e.g.,
get_cache_vars.cmake
and run it like:The best way to replicate this on another machine is to use -DSETTING=TRUE/FALSE args.
If you have a LOT of these options differing from the default you can build your cmake call using a script.
Ex:
Distribute the helper bash script to the other machine.