[CMake] How to support separate debug and release build directories?

David Demelier markand at malikania.fr
Fri Jun 21 09:45:40 EDT 2019


Le 21/06/2019 à 15:42, David Aldrich a écrit :
>     Do never test CMAKE_BUILD_TYPE in CMakeLists.txt files, it is
>     ignored in
>     multiple generators (e.g. Visual Studio).
> 
> Does that mean I shouldn't have this in CMakeLists.txt? :
> 
> # Specify a Release build by default
> if(NOT CMAKE_BUILD_TYPE)
>    set(CMAKE_BUILD_TYPE "Release")
>    message(STATUS "Build type not specified: Use Release by default")
> endif(NOT CMAKE_BUILD_TYPE)

It may be handy if you're sure that the project will only use single 
generators tools (e.g. make, ninja) otherwise yes it's strongly advised 
to not touch/inspect CMAKE_BUILD_TYPE if your project can be build with 
any kind of generators.

Regards

-- 
David



More information about the CMake mailing list