2

I am using CMake to build a cross-platform (e.g. Linux/Windows) application which uses also thirdparty libraries as external projects.

I'm aware of the fact that MSVC is a multi-configuration environment, hence CMAKE_BUILD_TYPE is not used, instead it uses the CMAKE_CONFIGURATION_TYPES set to build every possible configuration.

I'm also aware of the fact that instead of providing a configuration at configuration type (e.g. cmake -DCMAKE_BUILD_TYPE ..) I need to provide the configuration at build type (cmake --build . --config Release)

See CMAKE_BUILD_TYPE not being used in CMakeLists.txt

What I completely fail to understand is:

I don't want multi-configuration builds. I want to build EITHER Debug OR Release. Can I achieve that with CMake + MSVC + ExternalProjects? If yes how?

Thanks,

harsszegi
  • 339
  • 2
  • 13
  • I've to admit I don't understand your question/problem. If you have added the project via [`ExternalProject_Add`](https://cmake.org/cmake/help/latest/module/ExternalProject.html) and you choose e.g. `Debug` in VS IDE as your active configuration, your external project will automatically also build with `Debug`. So you can alternatively use makefile or Ninja generator with MSVC to get single configuration builds. Can you please give mode details what your desired behavior might look like? Calling something from the command line? Restricting something in the IDE? – Florian Jul 02 '17 at 09:32
  • I don't use any VS IDE, only command line compilation. And I don't want to use anything else than cmake (and MSVC obviously) to drive the build. Btw I have created a kind of hack, meaning that I do "cmake --build . --config Debug/Release" and apart from these I build both the Debug and Release variants of the external projects (via giving them CMAKE_BUILD_TYPE manually) so during the compilation of the main application the proper libraries of the given external project is picked up, however I find this extremely hackish – harsszegi Jul 03 '17 at 09:56
  • Can then please give a [mcve] of your CMake code? Especially how you have include the external project? – Florian Jul 03 '17 at 10:14

0 Answers0