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 /Tests | |
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 'Tests')
4 files changed, 45 insertions, 0 deletions
diff --git a/Tests/RunCMake/ToolchainFile/FlagsInit-stdout.txt b/Tests/RunCMake/ToolchainFile/FlagsInit-stdout.txt new file mode 100644 index 0000000..e18aa8c --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/FlagsInit-stdout.txt @@ -0,0 +1,30 @@ +-- CMAKE_C_FLAGS='[^ +]*-DMY_FLAGS_INIT[^ +]*' +-- CMAKE_C_FLAGS_DEBUG='[^ +]*-DMY_FLAGS_DEBUG_INIT[^ +]*' +-- CMAKE_C_FLAGS_RELEASE='[^ +]*-DMY_FLAGS_RELEASE_INIT[^ +]*' +-- CMAKE_C_FLAGS_MINSIZEREL='[^ +]*-DMY_FLAGS_MINSIZEREL_INIT[^ +]*' +-- CMAKE_C_FLAGS_RELWITHDEBINFO='[^ +]*-DMY_FLAGS_RELWITHDEBINFO_INIT[^ +]*' +-- CMAKE_CXX_FLAGS='[^ +]*-DMY_FLAGS_INIT[^ +]*' +-- CMAKE_CXX_FLAGS_DEBUG='[^ +]*-DMY_FLAGS_DEBUG_INIT[^ +]*' +-- CMAKE_CXX_FLAGS_RELEASE='[^ +]*-DMY_FLAGS_RELEASE_INIT[^ +]*' +-- CMAKE_CXX_FLAGS_MINSIZEREL='[^ +]*-DMY_FLAGS_MINSIZEREL_INIT[^ +]*' +-- CMAKE_CXX_FLAGS_RELWITHDEBINFO='[^ +]*-DMY_FLAGS_RELWITHDEBINFO_INIT[^ +]*' diff --git a/Tests/RunCMake/ToolchainFile/FlagsInit-toolchain.cmake b/Tests/RunCMake/ToolchainFile/FlagsInit-toolchain.cmake new file mode 100644 index 0000000..4c794b6 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/FlagsInit-toolchain.cmake @@ -0,0 +1,7 @@ +foreach(lang C CXX) + set(CMAKE_${lang}_FLAGS_INIT -DMY_FLAGS_INIT) + set(CMAKE_${lang}_FLAGS_DEBUG_INIT -DMY_FLAGS_DEBUG_INIT) + set(CMAKE_${lang}_FLAGS_RELEASE_INIT -DMY_FLAGS_RELEASE_INIT) + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT -DMY_FLAGS_MINSIZEREL_INIT) + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT -DMY_FLAGS_RELWITHDEBINFO_INIT) +endforeach() diff --git a/Tests/RunCMake/ToolchainFile/FlagsInit.cmake b/Tests/RunCMake/ToolchainFile/FlagsInit.cmake new file mode 100644 index 0000000..98873bf --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/FlagsInit.cmake @@ -0,0 +1,7 @@ +enable_language(C) +enable_language(CXX) +foreach(lang C CXX) + foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + message(STATUS "CMAKE_${lang}_FLAGS${c}='${CMAKE_${lang}_FLAGS${c}}'") + endforeach() +endforeach() diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake index 75293e7..88c8216 100644 --- a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -7,3 +7,4 @@ endfunction() run_cmake_toolchain(CallEnableLanguage) run_cmake_toolchain(CallProject) +run_cmake_toolchain(FlagsInit) |