summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBeren Minor <beren.minor+git@gmail.com>2017-11-27 18:22:11 (GMT)
committerBeren Minor <beren.minor+git@gmail.com>2018-01-08 20:15:14 (GMT)
commit48f7e2d30000dc57c31d3e3ab81077950704a587 (patch)
treee7653b43cf9d1da67b5c1285d994c9ca232056b6 /Modules
parentf7f34a46e674fcf0326b0dbbc6dbb35c9e3c022f (diff)
downloadCMake-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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeASMInformation.cmake33
-rw-r--r--Modules/CMakeCInformation.cmake32
-rw-r--r--Modules/CMakeCSharpInformation.cmake58
-rw-r--r--Modules/CMakeCUDAInformation.cmake26
-rw-r--r--Modules/CMakeCXXInformation.cmake25
-rw-r--r--Modules/CMakeCommonLanguageInclude.cmake114
-rw-r--r--Modules/CMakeFortranInformation.cmake26
-rw-r--r--Modules/CMakeGenericSystem.cmake1
-rw-r--r--Modules/CMakeInitializeConfigs.cmake39
-rw-r--r--Modules/CMakeRCInformation.cmake25
-rw-r--r--Modules/CMakeSystemSpecificInformation.cmake1
-rw-r--r--Modules/DeployQt4.cmake8
-rw-r--r--Modules/FindCUDA.cmake19
13 files changed, 62 insertions, 345 deletions
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.