diff options
author | Beren Minor <beren.minor+git@gmail.com> | 2017-11-27 18:22:11 (GMT) |
---|---|---|
committer | Beren Minor <beren.minor+git@gmail.com> | 2018-01-08 20:15:14 (GMT) |
commit | 48f7e2d30000dc57c31d3e3ab81077950704a587 (patch) | |
tree | e7653b43cf9d1da67b5c1285d994c9ca232056b6 | |
parent | f7f34a46e674fcf0326b0dbbc6dbb35c9e3c022f (diff) | |
download | CMake-48f7e2d30000dc57c31d3e3ab81077950704a587.zip CMake-48f7e2d30000dc57c31d3e3ab81077950704a587.tar.gz CMake-48f7e2d30000dc57c31d3e3ab81077950704a587.tar.bz2 |
Unhardcode the CMAKE_CONFIGURATION_TYPES values
This removes duplicated code for per-config variable initialization by
providing a `cmake_initialize_per_config_variable(<PREFIX> <DOCSTRING>)`
function.
This function initializes a `<PREFIX>` cache variable from `<PREFIX>_INIT`
and unless the `CMAKE_NOT_USING_CONFIG_FLAGS` variable is defined, does
the same with `<PREFIX>_<CONFIG>` from `<PREFIX>_<CONFIG>_INIT` for every
`<CONFIG>` in `CMAKE_CONFIGURATION_TYPES` for multi-config generators or
`CMAKE_BUILD_TYPE` for single-config generators.
32 files changed, 113 insertions, 410 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 735b93b..3f57612 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -414,6 +414,8 @@ Variables for Languages /variable/CMAKE_LANG_CREATE_SHARED_MODULE /variable/CMAKE_LANG_CREATE_STATIC_LIBRARY /variable/CMAKE_LANG_FLAGS + /variable/CMAKE_LANG_FLAGS_CONFIG + /variable/CMAKE_LANG_FLAGS_CONFIG_INIT /variable/CMAKE_LANG_FLAGS_DEBUG /variable/CMAKE_LANG_FLAGS_DEBUG_INIT /variable/CMAKE_LANG_FLAGS_INIT @@ -423,6 +425,7 @@ Variables for Languages /variable/CMAKE_LANG_FLAGS_RELEASE_INIT /variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO /variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT + /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE diff --git a/Help/prop_tgt/LINK_FLAGS.rst b/Help/prop_tgt/LINK_FLAGS.rst index 409d00a..0940121 100644 --- a/Help/prop_tgt/LINK_FLAGS.rst +++ b/Help/prop_tgt/LINK_FLAGS.rst @@ -5,4 +5,4 @@ Additional flags to use when linking this target. The LINK_FLAGS property can be used to add extra flags to the link step of a target. LINK_FLAGS_<CONFIG> will add to the configuration -<CONFIG>, for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. +<CONFIG>, for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO, ... diff --git a/Help/variable/CMAKE_BUILD_TYPE.rst b/Help/variable/CMAKE_BUILD_TYPE.rst index 2d54d60..2d35635 100644 --- a/Help/variable/CMAKE_BUILD_TYPE.rst +++ b/Help/variable/CMAKE_BUILD_TYPE.rst @@ -5,7 +5,7 @@ Specifies the build type on single-configuration generators. This statically specifies what build type (configuration) will be built in this build tree. Possible values are empty, ``Debug``, ``Release``, -``RelWithDebInfo`` and ``MinSizeRel``. This variable is only meaningful to +``RelWithDebInfo``, ``MinSizeRel``, ... This variable is only meaningful to single-configuration generators (such as :ref:`Makefile Generators` and :generator:`Ninja`) i.e. those which choose a single configuration when CMake runs to generate a build tree as opposed to multi-configuration generators @@ -13,7 +13,7 @@ which offer selection of the build configuration within the generated build environment. There are many per-config properties and variables (usually following clean ``SOME_VAR_<CONFIG>`` order conventions), such as ``CMAKE_C_FLAGS_<CONFIG>``, specified as uppercase: -``CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]``. For example, +``CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL|...]``. For example, in a build tree configured to build type ``Debug``, CMake will see to having :variable:`CMAKE_C_FLAGS_DEBUG <CMAKE_<LANG>_FLAGS_DEBUG>` settings get added to the :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` settings. See diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst new file mode 100644 index 0000000..1dbd036 --- /dev/null +++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst @@ -0,0 +1,4 @@ +CMAKE_<LANG>_FLAGS_<CONFIG> +--------------------------- + +Flags for language ``<LANG>`` when building for the ``<CONFIG>`` configuration. diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst new file mode 100644 index 0000000..1eb5b3f --- /dev/null +++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst @@ -0,0 +1,10 @@ +CMAKE_<LANG>_FLAGS_<CONFIG>_INIT +-------------------------------- + +Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache +entry the first time a build tree is configured for language ``<LANG>``. +This variable is meant to be set by a :variable:`toolchain file +<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to +the value based on the environment and target platform. + +See also :variable:`CMAKE_<LANG>_FLAGS_INIT`. diff --git a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst index a233d4a..6be424a 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst @@ -1,6 +1,5 @@ CMAKE_<LANG>_FLAGS_DEBUG ------------------------ -Flags for ``Debug`` build type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``. +This variable is the ``Debug`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst index dcddb2e..de7fcfc 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst @@ -1,10 +1,5 @@ CMAKE_<LANG>_FLAGS_DEBUG_INIT ----------------------------- -Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_DEBUG` cache -entry the first time a build tree is configured for language ``<LANG>``. -This variable is meant to be set by a :variable:`toolchain file -<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to -the value based on the environment and target platform. - -See also :variable:`CMAKE_<LANG>_FLAGS_INIT`. +This variable is the ``Debug`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst index 1d32cc3..a88d122 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst @@ -7,9 +7,5 @@ This variable is meant to be set by a :variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to the value based on the environment and target platform. -See also the configuration-specific variables: - -* :variable:`CMAKE_<LANG>_FLAGS_DEBUG_INIT` -* :variable:`CMAKE_<LANG>_FLAGS_RELEASE_INIT` -* :variable:`CMAKE_<LANG>_FLAGS_MINSIZEREL_INIT` -* :variable:`CMAKE_<LANG>_FLAGS_RELWITHDEBINFO_INIT` +See also the configuration-specific +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst index a9436c1..634fab9 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst @@ -1,7 +1,5 @@ CMAKE_<LANG>_FLAGS_MINSIZEREL ----------------------------- -Flags for ``MinSizeRel`` build type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel`` -(short for minimum size release). +This variable is the ``MinSizeRel`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst index c0aedf4..1e7003c 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst @@ -1,10 +1,5 @@ CMAKE_<LANG>_FLAGS_MINSIZEREL_INIT ---------------------------------- -Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_MINSIZEREL` -cache entry the first time a build tree is configured for language ``<LANG>``. -This variable is meant to be set by a :variable:`toolchain file -<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to -the value based on the environment and target platform. - -See also :variable:`CMAKE_<LANG>_FLAGS_INIT`. +This variable is the ``MinSizeRel`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst index ffc5d79..3baeab0 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst @@ -1,6 +1,5 @@ CMAKE_<LANG>_FLAGS_RELEASE -------------------------- -Flags for ``Release`` build type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``. +This variable is the ``Release`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst index 59f92ff..e7c73fe 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst @@ -1,10 +1,5 @@ CMAKE_<LANG>_FLAGS_RELEASE_INIT ------------------------------- -Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_RELEASE` -cache entry the first time a build tree is configured for language ``<LANG>``. -This variable is meant to be set by a :variable:`toolchain file -<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to -the value based on the environment and target platform. - -See also :variable:`CMAKE_<LANG>_FLAGS_INIT`. +This variable is the ``Release`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst index 962768e..67a5073 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst @@ -1,7 +1,5 @@ CMAKE_<LANG>_FLAGS_RELWITHDEBINFO --------------------------------- -Flags for ``RelWithDebInfo`` type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo`` -(short for Release With Debug Information). +This variable is the ``RelWithDebInfo`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst index 915f023..3ab3975 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst @@ -1,10 +1,5 @@ CMAKE_<LANG>_FLAGS_RELWITHDEBINFO_INIT -------------------------------------- -Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_RELWITHDEBINFO` -cache entry the first time a build tree is configured for language ``<LANG>``. -This variable is meant to be set by a :variable:`toolchain file -<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to -the value based on the environment and target platform. - -See also :variable:`CMAKE_<LANG>_FLAGS_INIT`. +This variable is the ``RelWithDebInfo`` variant of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG.rst new file mode 100644 index 0000000..8ed1c02 --- /dev/null +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_CONFIG.rst @@ -0,0 +1,5 @@ +CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG> +-------------------------------------- + +GHS kernel flags for language ``<LANG>`` when building for the ``<CONFIG>`` +configuration. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst index 1f639a3..4fea67a 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst @@ -1,6 +1,5 @@ CMAKE_<LANG>_GHS_KERNEL_FLAGS_DEBUG ----------------------------------- -GHS kernel flags for ``Debug`` build type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``. +This variable is the ``Debug`` variant of the +:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst index 94e2115..31f87f2 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst @@ -1,7 +1,5 @@ CMAKE_<LANG>_GHS_KERNEL_FLAGS_MINSIZEREL ---------------------------------------- -GHS kernel flags for ``MinSizeRel`` build type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel`` -(short for minimum size release). +This variable is the ``MinSizeRel`` variant of the +:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst index 74566ef..1acd198 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst @@ -1,6 +1,5 @@ CMAKE_<LANG>_GHS_KERNEL_FLAGS_RELEASE ------------------------------------- -GHS kernel flags for ``Release`` build type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``. +This variable is the ``Release`` variant of the +:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst index d148193..ac1b6bc 100644 --- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst +++ b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst @@ -1,7 +1,5 @@ CMAKE_<LANG>_GHS_KERNEL_FLAGS_RELWITHDEBINFO -------------------------------------------- -GHS kernel flags for ``RelWithDebInfo`` type or configuration. - -``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo`` -(short for Release With Debug Information). +This variable is the ``RelWithDebInfo`` variant of the +:variable:`CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG>` variable. diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index f7cf900..125c4e3 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -67,38 +67,7 @@ endif() # Support for CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT and friends: set(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT "$ENV{ASM${ASM_DIALECT}FLAGS} ${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}") -foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_ASM${ASM_DIALECT}_FLAGS${c}_INIT}" CMAKE_ASM${ASM_DIALECT}_FLAGS${c}_INIT) -endforeach() - -set (CMAKE_ASM${ASM_DIALECT}_FLAGS "${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}" CACHE STRING - "Flags used by the assembler during all build types.") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - # default build type is none - if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) - set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING - "Choose the type of build, options are: None, Debug Release RelWithDebInfo MinSizeRel.") - endif() - unset(_GENERATOR_IS_MULTI_CONFIG) - set (CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG "${CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags used by the assembler during debug builds.") - set (CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL "${CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the assembler during release minsize builds.") - set (CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE "${CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the assembler during release builds.") - set (CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO "${CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the assembler during Release with Debug Info builds.") -endif() - -mark_as_advanced(CMAKE_ASM${ASM_DIALECT}_FLAGS - CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG - CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL - CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE - CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO - ) - +cmake_initialize_per_config_variable(CMAKE_ASM${ASM_DIALECT}_FLAGS "Flags used by the ASM${ASM_DIALECT} compiler") if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT) set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 71aadb4..1e46cac 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -102,30 +102,7 @@ endif() set(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}") -foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_C_FLAGS${c}_INIT}" CMAKE_C_FLAGS${c}_INIT) -endforeach() - -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING - "Flags used by the compiler during all build types.") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - # default build type is none - if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) - set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING - "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") - endif() - unset(_GENERATOR_IS_MULTI_CONFIG) - set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags used by the compiler during debug builds.") - set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release builds for minimum size.") - set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds.") - set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during release builds with debug info.") -endif() +cmake_initialize_per_config_variable(CMAKE_C_FLAGS "Flags used by the C compiler") if(CMAKE_C_STANDARD_LIBRARIES_INIT) set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT}" @@ -208,13 +185,6 @@ if(NOT CMAKE_EXECUTABLE_RPATH_LINK_C_FLAG) set(CMAKE_EXECUTABLE_RPATH_LINK_C_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG}) endif() -mark_as_advanced( -CMAKE_C_FLAGS -CMAKE_C_FLAGS_DEBUG -CMAKE_C_FLAGS_MINSIZEREL -CMAKE_C_FLAGS_RELEASE -CMAKE_C_FLAGS_RELWITHDEBINFO -) set(CMAKE_C_INFORMATION_LOADED 1) diff --git a/Modules/CMakeCSharpInformation.cmake b/Modules/CMakeCSharpInformation.cmake index 25f869c..48e1a1e 100644 --- a/Modules/CMakeCSharpInformation.cmake +++ b/Modules/CMakeCSharpInformation.cmake @@ -44,23 +44,8 @@ endif() # use _INIT variables so that this only happens the first time # and you can set these flags in the cmake cache set(CMAKE_CSharp_FLAGS_INIT "$ENV{CSFLAGS} ${CMAKE_CSharp_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_CSharp_FLAGS_INIT STREQUAL " ") - set(CMAKE_CSharp_FLAGS_INIT) -endif() -set (CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS_INIT}" CACHE STRING - "Flags used by the C# compiler during all build types.") -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_CSharp_FLAGS_DEBUG "${CMAKE_CSharp_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags used by the C# compiler during debug builds.") - set (CMAKE_CSharp_FLAGS_MINSIZEREL "${CMAKE_CSharp_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the C# compiler during release builds for minimum size.") - set (CMAKE_CSharp_FLAGS_RELEASE "${CMAKE_CSharp_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the C# compiler during release builds.") - set (CMAKE_CSharp_FLAGS_RELWITHDEBINFO "${CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the C# compiler during release builds with debug info.") -endif() +cmake_initialize_per_config_variable(CMAKE_CSharp_FLAGS "Flags used by the C# compiler") if(CMAKE_CSharp_STANDARD_LIBRARIES_INIT) set(CMAKE_CSharp_STANDARD_LIBRARIES "${CMAKE_CSharp_STANDARD_LIBRARIES_INIT}" @@ -71,49 +56,12 @@ endif() # set missing flags (if they are not defined). This is needed in the # unlikely case that you have only C# and no C/C++ targets in your # project. -if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS) - set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_DEBUG) - set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_RELEASE) - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL) - set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO) - set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE) -endif() - -if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS) - set(CMAKE_EXE_LINKER_FLAGS "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_DEBUG) - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELEASE) - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_MINSIZEREL) - set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE) -endif() -if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO) - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE) -endif() +cmake_initialize_per_config_variable(CMAKE_EXE_LINKER_FLAGS "Flags used by the linker") +cmake_initialize_per_config_variable(CMAKE_SHARED_LINKER_FLAGS "Flags used by the linker during the creation of shared libraries") set(CMAKE_CSharp_CREATE_SHARED_LIBRARY "CSharp_NO_CREATE_SHARED_LIBRARY") set(CMAKE_CSharp_CREATE_SHARED_MODULE "CSharp_NO_CREATE_SHARED_MODULE") set(CMAKE_CSharp_LINK_EXECUTABLE "CSharp_NO_LINK_EXECUTABLE") -mark_as_advanced( - CMAKE_CSharp_FLAGS - CMAKE_CSharp_FLAGS_RELEASE - CMAKE_CSharp_FLAGS_RELWITHDEBINFO - CMAKE_CSharp_FLAGS_MINSIZEREL - CMAKE_CSharp_FLAGS_DEBUG - ) - set(CMAKE_CSharp_USE_RESPONSE_FILE_FOR_OBJECTS 1) set(CMAKE_CSharp_INFORMATION_LOADED 1) diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index f4609cd..167e177 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -74,24 +74,7 @@ endif() # and you can set these flags in the cmake cache set(CMAKE_CUDA_FLAGS_INIT "$ENV{CUDAFLAGS} ${CMAKE_CUDA_FLAGS_INIT}") -foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_CUDA_FLAGS${c}_INIT}" CMAKE_CUDA_FLAGS${c}_INIT) -endforeach() - -set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS_INIT}" CACHE STRING - "Flags used by the compiler during all build types.") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags used by the compiler during debug builds.") - set (CMAKE_CUDA_FLAGS_MINSIZEREL "${CMAKE_CUDA_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release builds for minimum size.") - set (CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds.") - set (CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during release builds with debug info.") - -endif() +cmake_initialize_per_config_variable(CMAKE_CUDA_FLAGS "Flags used by the CUDA compiler") if(CMAKE_CUDA_STANDARD_LIBRARIES_INIT) set(CMAKE_CUDA_STANDARD_LIBRARIES "${CMAKE_CUDA_STANDARD_LIBRARIES_INIT}" @@ -207,11 +190,4 @@ endif() unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS) -mark_as_advanced( -CMAKE_CUDA_FLAGS -CMAKE_CUDA_FLAGS_RELEASE -CMAKE_CUDA_FLAGS_RELWITHDEBINFO -CMAKE_CUDA_FLAGS_MINSIZEREL -CMAKE_CUDA_FLAGS_DEBUG) - set(CMAKE_CUDA_INFORMATION_LOADED 1) diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index ec731fa..31ccef7 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -197,24 +197,7 @@ endforeach() # and you can set these flags in the cmake cache set(CMAKE_CXX_FLAGS_INIT "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}") -foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_CXX_FLAGS${c}_INIT}" CMAKE_CXX_FLAGS${c}_INIT) -endforeach() - -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT}" CACHE STRING - "Flags used by the compiler during all build types.") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags used by the compiler during debug builds.") - set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release builds for minimum size.") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds.") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during release builds with debug info.") - -endif() +cmake_initialize_per_config_variable(CMAKE_CXX_FLAGS "Flags used by the CXX compiler") if(CMAKE_CXX_STANDARD_LIBRARIES_INIT) set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES_INIT}" @@ -287,11 +270,7 @@ endif() mark_as_advanced( CMAKE_VERBOSE_MAKEFILE -CMAKE_CXX_FLAGS -CMAKE_CXX_FLAGS_RELEASE -CMAKE_CXX_FLAGS_RELWITHDEBINFO -CMAKE_CXX_FLAGS_MINSIZEREL -CMAKE_CXX_FLAGS_DEBUG) +) set(CMAKE_CXX_INFORMATION_LOADED 1) diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index 43b5da0..b043e18 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -10,120 +10,14 @@ string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}") string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " $ENV{LDFLAGS}") string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}") -foreach(t EXE SHARED MODULE STATIC) - foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_${t}_LINKER_FLAGS${c}_INIT}" CMAKE_${t}_LINKER_FLAGS${c}_INIT) - endforeach() -endforeach() - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - # default build type is none - if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) - set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING - "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") - endif() - unset(_GENERATOR_IS_MULTI_CONFIG) - - set (CMAKE_EXE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING - "Flags used by the linker during debug builds.") - - set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT} CACHE STRING - "Flags used by the linker during release minsize builds.") - - set (CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT} CACHE STRING - "Flags used by the linker during release builds.") - - set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO - ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING - "Flags used by the linker during Release with Debug Info builds.") - - set (CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT} CACHE STRING - "Flags used by the linker during debug builds.") - - set (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL ${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT} - CACHE STRING - "Flags used by the linker during release minsize builds.") - - set (CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT} CACHE STRING - "Flags used by the linker during release builds.") - - set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO - ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING - "Flags used by the linker during Release with Debug Info builds.") - - set (CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING - "Flags used by the linker during debug builds.") - - set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL ${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT} - CACHE STRING - "Flags used by the linker during release minsize builds.") - - set (CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT} CACHE STRING - "Flags used by the linker during release builds.") - - set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO - ${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING - "Flags used by the linker during Release with Debug Info builds.") - - set (CMAKE_STATIC_LINKER_FLAGS_DEBUG ${CMAKE_STATIC_LINKER_FLAGS_DEBUG_INIT} CACHE STRING - "Flags used by the linker during debug builds.") - - set (CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL ${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL_INIT} - CACHE STRING - "Flags used by the linker during release minsize builds.") - - set (CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT} CACHE STRING - "Flags used by the linker during release builds.") - - set (CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO - ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING - "Flags used by the linker during Release with Debug Info builds.") -endif() - -# executable linker flags -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}" - CACHE STRING "Flags used by the linker.") - -# shared linker flags -set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}" - CACHE STRING "Flags used by the linker during the creation of dll's.") - -# module linker flags -set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}" - CACHE STRING "Flags used by the linker during the creation of modules.") - -# static linker flags -set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS_INIT}" - CACHE STRING "Flags used by the linker during the creation of static libraries.") +cmake_initialize_per_config_variable(CMAKE_EXE_LINKER_FLAGS "Flags used by the linker") +cmake_initialize_per_config_variable(CMAKE_SHARED_LINKER_FLAGS "Flags used by the linker during the creation of shared libraries") +cmake_initialize_per_config_variable(CMAKE_MODULE_LINKER_FLAGS "Flags used by the linker during the creation of modules") +cmake_initialize_per_config_variable(CMAKE_STATIC_LINKER_FLAGS "Flags used by the linker during the creation of static libraries") # Alias the build tool variable for backward compatibility. set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM}) mark_as_advanced( CMAKE_VERBOSE_MAKEFILE - -CMAKE_EXE_LINKER_FLAGS -CMAKE_EXE_LINKER_FLAGS_DEBUG -CMAKE_EXE_LINKER_FLAGS_MINSIZEREL -CMAKE_EXE_LINKER_FLAGS_RELEASE -CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO - -CMAKE_SHARED_LINKER_FLAGS -CMAKE_SHARED_LINKER_FLAGS_DEBUG -CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL -CMAKE_SHARED_LINKER_FLAGS_RELEASE -CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO - -CMAKE_MODULE_LINKER_FLAGS -CMAKE_MODULE_LINKER_FLAGS_DEBUG -CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL -CMAKE_MODULE_LINKER_FLAGS_RELEASE -CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO - -CMAKE_STATIC_LINKER_FLAGS -CMAKE_STATIC_LINKER_FLAGS_DEBUG -CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL -CMAKE_STATIC_LINKER_FLAGS_RELEASE -CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ) diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index d422578..8e5c027 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -159,12 +159,7 @@ set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}") -foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_Fortran_FLAGS${c}_INIT}" CMAKE_Fortran_FLAGS${c}_INIT) -endforeach() - -set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_INIT}" CACHE STRING - "Flags used by the compiler during all build types.") +cmake_initialize_per_config_variable(CMAKE_Fortran_FLAGS "Flags used by the Fortran compiler") include(CMakeCommonLanguageInclude) @@ -216,24 +211,5 @@ if(CMAKE_Fortran_STANDARD_LIBRARIES_INIT) mark_as_advanced(CMAKE_Fortran_STANDARD_LIBRARIES) endif() -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags used by the compiler during debug builds.") - set (CMAKE_Fortran_FLAGS_MINSIZEREL "${CMAKE_Fortran_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release builds for minimum size.") - set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds.") - set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during release builds with debug info.") - -endif() - -mark_as_advanced( -CMAKE_Fortran_FLAGS -CMAKE_Fortran_FLAGS_DEBUG -CMAKE_Fortran_FLAGS_MINSIZEREL -CMAKE_Fortran_FLAGS_RELEASE -CMAKE_Fortran_FLAGS_RELWITHDEBINFO) - # set this variable so we can avoid loading this more than once. set(CMAKE_Fortran_INFORMATION_LOADED 1) diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 324a279..3eb86f9 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -1,6 +1,7 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +include(CMakeInitializeConfigs) set(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared diff --git a/Modules/CMakeInitializeConfigs.cmake b/Modules/CMakeInitializeConfigs.cmake new file mode 100644 index 0000000..9dfe040 --- /dev/null +++ b/Modules/CMakeInitializeConfigs.cmake @@ -0,0 +1,39 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include_guard(GLOBAL) + +# Initializes `<_PREFIX>_<CONFIG>` variables from the corresponding +# `<_PREFIX>_<CONFIG>_INIT`, for the configurations currently used. +function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING) + string(STRIP "${${_PREFIX}_INIT}" _INIT) + set("${_PREFIX}" "${_INIT}" + CACHE STRING "${_DOCSTRING} during all build types.") + mark_as_advanced("${_PREFIX}") + + if (NOT CMAKE_NOT_USING_CONFIG_FLAGS) + set(_CONFIGS Debug Release MinSizeRel RelWithDebInfo) + + get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if (_GENERATOR_IS_MULTI_CONFIG) + list(APPEND _CONFIGS ${CMAKE_CONFIGURATION_TYPES}) + else() + if (NOT CMAKE_NO_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_INIT}" CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...") + endif() + list(APPEND _CONFIGS ${CMAKE_BUILD_TYPE}) + endif() + + list(REMOVE_DUPLICATES _CONFIGS) + foreach(_BUILD_TYPE IN LISTS _CONFIGS) + if (NOT "${_BUILD_TYPE}" STREQUAL "") + string(TOUPPER "${_BUILD_TYPE}" _BUILD_TYPE) + string(STRIP "${${_PREFIX}_${_BUILD_TYPE}_INIT}" _INIT) + set("${_PREFIX}_${_BUILD_TYPE}" "${_INIT}" + CACHE STRING "${_DOCSTRING} during ${_BUILD_TYPE} builds.") + mark_as_advanced("${_PREFIX}_${_BUILD_TYPE}") + endif() + endforeach() + endif() +endfunction() diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index a340288..1227fdf 100644 --- a/Modules/CMakeRCInformation.cmake +++ b/Modules/CMakeRCInformation.cmake @@ -19,23 +19,7 @@ include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) set(CMAKE_RC_FLAGS_INIT "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}") -foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) - string(STRIP "${CMAKE_RC_FLAGS${c}_INIT}" CMAKE_RC_FLAGS${c}_INIT) -endforeach() - -set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_INIT}" CACHE STRING - "Flags for Windows Resource Compiler.") - -if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) - set (CMAKE_RC_FLAGS_DEBUG "${CMAKE_RC_FLAGS_DEBUG_INIT}" CACHE STRING - "Flags for Windows Resource Compiler during debug builds.") - set (CMAKE_RC_FLAGS_MINSIZEREL "${CMAKE_RC_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags for Windows Resource Compiler during release builds for minimum size.") - set (CMAKE_RC_FLAGS_RELEASE "${CMAKE_RC_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags for Windows Resource Compiler during release builds.") - set (CMAKE_RC_FLAGS_RELWITHDEBINFO "${CMAKE_RC_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags for Windows Resource Compiler during release builds with debug info.") -endif() +cmake_initialize_per_config_variable(CMAKE_RC_FLAGS "Flags for Windows Resource Compiler") # These are the only types of flags that should be passed to the rc # command, if COMPILE_FLAGS is used on a target this will be used @@ -51,12 +35,5 @@ if(NOT CMAKE_RC_COMPILE_OBJECT) "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo<OBJECT> <SOURCE>") endif() -mark_as_advanced( -CMAKE_RC_FLAGS -CMAKE_RC_FLAGS_DEBUG -CMAKE_RC_FLAGS_MINSIZEREL -CMAKE_RC_FLAGS_RELEASE -CMAKE_RC_FLAGS_RELWITHDEBINFO -) # set this variable so we can avoid loading this more than once. set(CMAKE_RC_INFORMATION_LOADED 1) diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 03f348d..66f1722 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -37,7 +37,6 @@ if(NOT _INCLUDED_SYSTEM_INFO_FILE) endif() endif() - # optionally include a file which can do extra-generator specific things, e.g. # CMakeFindEclipseCDT4.cmake asks gcc for the system include dirs for the Eclipse CDT4 generator if(CMAKE_EXTRA_GENERATOR) diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index 28054f8..e758f3a 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -298,8 +298,14 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig OR CMAKE_BUILD_TYPE) - install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel") + set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}") + if (_RELEASE_CONFIGS) + list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]") + endif() + string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}") + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}") install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug") + unset(_RELEASE_CONFIGS) if(CMAKE_BUILD_TYPE MATCHES "^Debug$") set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug}) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 4f4453b..32aa454 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -524,7 +524,7 @@ set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output fil option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) # Extra user settable flags -set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.") +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") if(CMAKE_GENERATOR MATCHES "Visual Studio") set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC") @@ -578,23 +578,6 @@ mark_as_advanced( CUDA_SEPARABLE_COMPILATION ) -# Single config generators like Makefiles or Ninja don't usually have -# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by -# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for -# single config generators (and should not be defined for multi-config -# generators). To ensure we get a complete superset of all possible -# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and -# all of the standard configurations, then weed out duplicates with -# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have -# each configuration-specific set of nvcc flags defined and marked as advanced. -set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) -list(REMOVE_DUPLICATES CUDA_configuration_types) -foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - set(CUDA_NVCC_FLAGS_${config_upper} "" CACHE STRING "Semi-colon delimit multiple arguments.") - mark_as_advanced(CUDA_NVCC_FLAGS_${config_upper}) -endforeach() - ############################################################################### ############################################################################### # Locate CUDA, Set Build Type, etc. |