Clear default flags in an (im)proper way
The CMAKE_NOT_USING_CONFIG_FLAGS option is really only settable by a user that doesn't want _DEBUG or _RELEASE flags to not have effect. If we want other flags than the platform default, we must do hairy things like clearing them from the cache (overriding the user's seletion if it was the same as the platform default).
This commit is contained in:
parent
d801668c1c
commit
e9d0216577
@ -78,8 +78,20 @@ function (set_default_option lang varname flag regex)
|
|||||||
endif ()
|
endif ()
|
||||||
endfunction (set_default_option)
|
endfunction (set_default_option)
|
||||||
|
|
||||||
# note: this must be called before project()
|
# clear default options as a proxy for not using any default options
|
||||||
|
# at all. there is one *huge* problem with this: CMake runs the platform
|
||||||
|
# initialization before executing any line at all in the project and
|
||||||
|
# there seems to be no way to disable that behaviour, so we cannot really
|
||||||
|
# distinguish between a platform default and something that the user has
|
||||||
|
# passed on the command line. the best thing we can do is to all user-
|
||||||
|
# defined setting if they are something other than the platform default.
|
||||||
macro (no_default_options)
|
macro (no_default_options)
|
||||||
# prevent the platform probe to set options
|
foreach (lang IN ITEMS C CXX Fortran)
|
||||||
set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE)
|
foreach (build IN ITEMS DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
|
||||||
|
if ("${CMAKE_${lang}_FLAGS_${build}}" STREQUAL "${CMAKE_${lang}_FLAGS_${build}_INIT}")
|
||||||
|
# for some strange reason we cannot clear this flag, only set it to empty
|
||||||
|
set (CMAKE_${lang}_FLAGS_${build} "")
|
||||||
|
endif ()
|
||||||
|
endforeach (build)
|
||||||
|
endforeach (lang)
|
||||||
endmacro (no_default_options)
|
endmacro (no_default_options)
|
||||||
|
Loading…
Reference in New Issue
Block a user