CMAKE_BUILD_TYPE can be unset when setting CMAKE_BUILD_TYPE_INIT after usage of "enable_language()"
This might be a border case and I'm not even sure if it's a bug or not, but I thought I'd mention it just in case:
After !1345 (merged) which was merged in 48f7e2d3 (i.e. starting with CMake 3.11) it seems the order of execution of some code has changed, specifically the line
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_INIT}" CACHE STRING)
This change of execution order causes CMAKE_BUILD_TYPE
to be unset in the following example in CMake 3.11, while it was set properly in earlier versions:
cmake_minimum_required (VERSION 3.0)
# using this before setting CMAKE_BUILD_TYPE_INIT causes CMAKE_BUILD_TYPE to be unset
set(CMAKE_RC_COMPILER "echo")
enable_language(RC)
# avoid having empty buildtype
set(CMAKE_BUILD_TYPE_INIT "Release")
project (Test)
message("CMAKE_BUILD_TYPE_INIT=${CMAKE_BUILD_TYPE_INIT}")
message("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
If this turns out to be problem with the build file, some documentation on how/where to set CMAKE_BUILD_TYPE_INIT
and how/where to use enable_language()
might prove helpful.