17

E.g. how should I build release and debug version at the same time? I guess the answer make use of cache variables and some kind of "collection" of them. Is it common way to get configuration params from cache params, isn'it ? If the answer is yes, how should I use several "collections" of them in a best way ? Thanks a lot!

2 Answers 2

17

You don't specify the platform you are talking about. The Makefiles based generators will only build one configuration at a time, and the normal way to build several configurations is to use separate build trees, e.g. one for 64-bit Linux on Intel, one for 32-bit Windows, etc. Most CMake projects advise out of source builds, and assuming you wrote your CMakeLists files correctly you could have ~/src/YourProject, and ~/build/YourProject-Release, ~/build/YourProject-Debug.

This is the advised way to do it, assuming your source tree does not have any CMakeCache.txt etc in it. You can then run cmake -DCMAKE_BUILD_TYPE:STRING=Debug ~/src/YourProject in the debug directory, and similar for the release. This has the advantage that you can point dependent projects at the appropriate configuration.

The Boost CMake project has also explored building all configurations in the same build tree using library name mangling to differentiate. This may be worth looking at if you must build all configurations in the same build tree.

Sign up to request clarification or add additional context in comments.

Comments

10

(for fellow googlers)

Be careful of not confusing build types and build configurations.

If you really mean "build types" such as debug and release and want to build them at the same time, then Cmake FAQ gives an answer : How can I build multiple modes without switching

Basically it involves using several out-of-source builds.

2 Comments

What is the difference between "build type" and "build configuration"?
"types" aka "modes" and "configurations" are basically ways to create Debug and Release builds for different tools. Configurations are only available to tools that support it, eg Visual Studio. Modes are also normally used for Debug and Release style compilations, but cmake implements them for make in separate build folders as make doesn't have the same style of configuration support that VS had, namely selecting a build type/configuration from the configuration drop down in the GUI.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.