diff options
author | Brad King <brad.king@kitware.com> | 2016-07-05 17:35:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-07-06 14:13:31 (GMT) |
commit | a66004bee06023e9da4e0895ee1afbceaff33bdb (patch) | |
tree | 280b76c2204f6b3c62a1980c43d09acb3192db98 /Modules/Platform | |
parent | cdde77e5f66cee933a7b7c538c22e8c323a91d09 (diff) | |
download | CMake-a66004bee06023e9da4e0895ee1afbceaff33bdb.zip CMake-a66004bee06023e9da4e0895ee1afbceaff33bdb.tar.gz CMake-a66004bee06023e9da4e0895ee1afbceaff33bdb.tar.bz2 |
Honor CMAKE_<LANG>_FLAGS[_<CONFIG>]_INIT set in toolchain files
Document these variables.
Change our convention for setting these variables from:
set(CMAKE_C_FLAGS_INIT "...")
to
string(APPEND CMAKE_C_FLAGS_INIT " ...")
so that any value previously set by a toolchain file will be used.
Automate the conversion with:
sed -i 's/set *(\(CMAKE_\(C\|CXX\|Fortran\|RC\|ASM\|${[^}]\+}\)_FLAGS\(_[^_]\+\)\?_INIT \+"\)/string(APPEND \1 /' \
Modules/Compiler/*.cmake Modules/Platform/*.cmake
and follow up with some manual fixes (e.g. to cases that already
meant to append). Also revert the automated changes to contexts
that are not protected from running multiple times.
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/ARTOS-GNU-C.cmake | 10 | ||||
-rw-r--r-- | Modules/Platform/Generic-ADSP-C.cmake | 8 | ||||
-rw-r--r-- | Modules/Platform/Generic-ADSP-CXX.cmake | 8 | ||||
-rw-r--r-- | Modules/Platform/Generic-SDCC-C.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/HP-UX-HP-CXX.cmake | 8 | ||||
-rw-r--r-- | Modules/Platform/HP-UX-HP.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-Embarcadero.cmake | 10 | ||||
-rw-r--r-- | Modules/Platform/Windows-Intel-Fortran.cmake | 10 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 22 | ||||
-rw-r--r-- | Modules/Platform/Windows-OpenWatcom.cmake | 12 |
10 files changed, 46 insertions, 46 deletions
diff --git a/Modules/Platform/ARTOS-GNU-C.cmake b/Modules/Platform/ARTOS-GNU-C.cmake index 967d0e7..fe8d782 100644 --- a/Modules/Platform/ARTOS-GNU-C.cmake +++ b/Modules/Platform/ARTOS-GNU-C.cmake @@ -1,9 +1,9 @@ # Define ARTOS to select proper behaviour and tell preprocessor to accept C++ style comments. -set(CMAKE_C_FLAGS_INIT "-DARTOS -Xp -+") +string(APPEND CMAKE_C_FLAGS_INIT " -DARTOS -Xp -+") # ac doesn't support -g properly and doesn't support the normal gcc optimization options. Just use the defaults set by ac. -set(CMAKE_C_FLAGS_DEBUG_INIT "") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-DNDEBUG") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") # Most projects expect the stdio functions to be available. set(CMAKE_C_STANDARD_LIBRARIES_INIT "stdio.a") diff --git a/Modules/Platform/Generic-ADSP-C.cmake b/Modules/Platform/Generic-ADSP-C.cmake index 4b9ed9d..de1cee2 100644 --- a/Modules/Platform/Generic-ADSP-C.cmake +++ b/Modules/Platform/Generic-ADSP-C.cmake @@ -4,10 +4,10 @@ include(Platform/Generic-ADSP-Common) set(CMAKE_C_OUTPUT_EXTENSION ".doj") -set(CMAKE_C_FLAGS_DEBUG_INIT "-g") -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "") -set(CMAKE_C_FLAGS_RELEASE_INIT "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " ") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " ") set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_C_COMPILER> -build-lib -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -o <TARGET> <CMAKE_C_LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Platform/Generic-ADSP-CXX.cmake b/Modules/Platform/Generic-ADSP-CXX.cmake index 9673aef..0cde8f2 100644 --- a/Modules/Platform/Generic-ADSP-CXX.cmake +++ b/Modules/Platform/Generic-ADSP-CXX.cmake @@ -2,10 +2,10 @@ include(Platform/Generic-ADSP-Common) set(CMAKE_CXX_OUTPUT_EXTENSION ".doj") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " ") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " ") set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -build-lib -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -o <TARGET> <CMAKE_CXX_LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake index a1ca812..bbefe19 100644 --- a/Modules/Platform/Generic-SDCC-C.cmake +++ b/Modules/Platform/Generic-SDCC-C.cmake @@ -30,7 +30,7 @@ set(CMAKE_AR "${SDCCLIB_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) # CMAKE_C_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_INIT should be set in a CMAKE_SYSTEM_PROCESSOR file if(NOT DEFINED CMAKE_C_FLAGS_INIT) - set(CMAKE_C_FLAGS_INIT "-mmcs51 --model-small") + string(APPEND CMAKE_C_FLAGS_INIT " -mmcs51 --model-small") endif() if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT) diff --git a/Modules/Platform/HP-UX-HP-CXX.cmake b/Modules/Platform/HP-UX-HP-CXX.cmake index 6d90191..d37d2b0 100644 --- a/Modules/Platform/HP-UX-HP-CXX.cmake +++ b/Modules/Platform/HP-UX-HP-CXX.cmake @@ -8,7 +8,7 @@ set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "rm -f `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.o" ) -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "+O3 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "+O2 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -g") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " +O3 -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " +O2 -DNDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -g") diff --git a/Modules/Platform/HP-UX-HP.cmake b/Modules/Platform/HP-UX-HP.cmake index 3935c31..398d6fb 100644 --- a/Modules/Platform/HP-UX-HP.cmake +++ b/Modules/Platform/HP-UX-HP.cmake @@ -27,7 +27,7 @@ macro(__hpux_compiler_hp lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,+h") - set(CMAKE_${lang}_FLAGS_INIT "") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") set(CMAKE_${lang}_LINK_FLAGS "-Wl,+s,+nodefaultrpath") endmacro() diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index 102e3a6..8a87db3 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -132,10 +132,10 @@ macro(__embarcadero_language lang) ) # Initial configuration flags. - set(CMAKE_${lang}_FLAGS_INIT "${_tM}") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-Od -v") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O1 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O2 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-Od") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Od") set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "import32.lib") endmacro() diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake index 1b93db8..3981a09 100644 --- a/Modules/Platform/Windows-Intel-Fortran.cmake +++ b/Modules/Platform/Windows-Intel-Fortran.cmake @@ -4,8 +4,8 @@ set(_COMPILE_Fortran " /fpp") set(CMAKE_Fortran_MODDIR_FLAG "-module:") set(CMAKE_Fortran_STANDARD_LIBRARIES_INIT "user32.lib") __windows_compiler_intel(Fortran) -set (CMAKE_Fortran_FLAGS_INIT "/W1 /nologo /fpp /libs:dll /threads") -set (CMAKE_Fortran_FLAGS_DEBUG_INIT "/Od /debug:full /dbglibs") -set (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O1 /DNDEBUG") -set (CMAKE_Fortran_FLAGS_RELEASE_INIT "/O2 /DNDEBUG") -set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O2 /debug:full /DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_INIT " /W1 /nologo /fpp /libs:dll /threads") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " /Od /debug:full /dbglibs") +string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " /O1 /DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " /O2 /DNDEBUG") +string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " /O2 /debug:full /DNDEBUG") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 3fd6802..b1969a2 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -303,17 +303,17 @@ macro(__windows_compiler_msvc lang) if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects # that include MS's own headers. CMake itself is affected project too. - set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD -O2 -DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD -gline-tables-only -O2 -fno-inline -DNDEBUG") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD -O2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD -gline-tables-only -O2 -fno-inline -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang else() - set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") - set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") - set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /DNDEBUG") - set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /DNDEBUG") - set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD /O2 /Ob2 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD /Zi /O2 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD /O1 /Ob1 /DNDEBUG") endif() endif() set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) @@ -323,7 +323,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_RC_COMPILER_INIT rc) endif() if(NOT CMAKE_RC_FLAGS_INIT) - set(CMAKE_RC_FLAGS_INIT "${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}") + string(APPEND CMAKE_RC_FLAGS_INIT " ${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}") endif() enable_language(RC) diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake index 7147600..269f923 100644 --- a/Modules/Platform/Windows-OpenWatcom.cmake +++ b/Modules/Platform/Windows-OpenWatcom.cmake @@ -52,13 +52,13 @@ set(CMAKE_BUILD_TYPE_INIT Debug) # single/multi-threaded /-bm # static/DLL run-time libraries /-br # default is setup for multi-threaded + DLL run-time libraries -set (CMAKE_C_FLAGS_INIT "-bt=nt -w3 -dWIN32 -br -bm") -set (CMAKE_CXX_FLAGS_INIT "-bt=nt -xs -w3 -dWIN32 -br -bm") +string(APPEND CMAKE_C_FLAGS_INIT " -bt=nt -w3 -dWIN32 -br -bm") +string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=nt -xs -w3 -dWIN32 -br -bm") foreach(lang C CXX) - set (CMAKE_${lang}_FLAGS_DEBUG_INIT "-d2") - set (CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-s -os -d0 -dNDEBUG") - set (CMAKE_${lang}_FLAGS_RELEASE_INIT "-s -ot -d0 -dNDEBUG") - set (CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-s -ot -d1 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -d2") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -s -os -d0 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -s -ot -d0 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -s -ot -d1 -dNDEBUG") endforeach() foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) |