diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 0e547c467..1bb16ac24 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -76,10 +76,11 @@ 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}") -# avoid just having a space as the initial value for the cache -if(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT STREQUAL " ") - set(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT) -endif() + +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.") diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index fa87ca84c..98eedc42d 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -111,10 +111,11 @@ if(NOT CMAKE_MODULE_EXISTS) endif() set(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_C_FLAGS_INIT STREQUAL " ") - set(CMAKE_C_FLAGS_INIT) -endif() + +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.") diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index b35280f96..07e4f395d 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -206,10 +206,11 @@ endforeach() # use _INIT variables so that this only happens the first time # and you can set these flags in the cmake cache set(CMAKE_CXX_FLAGS_INIT "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_CXX_FLAGS_INIT STREQUAL " ") - set(CMAKE_CXX_FLAGS_INIT) -endif() + +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.") diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 1fd097235..45dbfcc5b 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -173,10 +173,11 @@ endif() set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}") -# avoid just having a space as the initial value for the cache -if(CMAKE_Fortran_FLAGS_INIT STREQUAL " ") - set(CMAKE_Fortran_FLAGS_INIT) -endif() + +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 for Fortran compiler.") diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index 94abd4be8..60276e215 100644 --- a/Modules/CMakeRCInformation.cmake +++ b/Modules/CMakeRCInformation.cmake @@ -28,9 +28,9 @@ set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) +string(STRIP "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CMAKE_RC_FLAGS_INIT) - -set (CMAKE_RC_FLAGS "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CACHE STRING +set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_INIT}" CACHE STRING "Flags for Windows Resource Compiler.") # These are the only types of flags that should be passed to the rc