CMAKE_BUILD_TYPE initialized on Windows before CMAKE_USER_MAKE_RULES_OVERRIDE
On Linux, unless I set -DCMAKE_BUILD_TYPE=$type
that variable is an empty string:
$ cat ../CMakeLists.txt
message("CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'")
$ cmake -G Ninja . | grep CMAKE_BUILD_TYPE=
CMAKE_BUILD_TYPE=''
On Windows, it is Debug
unless I override it explicitly:
λ cat ..\CMakeLists.txt
message("CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'")
λ cmake -G Ninja . | grep CMAKE_BUILD_TYPE=
CMAKE_BUILD_TYPE='Debug'
This is a problem for us because we'd like the default to a release build, but on Windows with the Ninja generator we can't detect whether a build type has been specified explicitly or not (in every other case we can check whether CMAKE_BUILD_TYPE
is empty). We see that checking CMAKE_BUILD_TYPE
is not a viable approach for IDE generators, but it seems Ninja should be supported. How should we be doing this?
Edited by Brad King