diff options
author | Glen Chung <kuchung@microsoft.com> | 2022-05-24 19:14:59 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-05-26 13:06:01 (GMT) |
commit | 5fcadc481e4b60e5dbbacb026b73631b69ca3746 (patch) | |
tree | 3c121306587bd873133dfb76e190f61be937f697 /Tests/RunCMake/MSVCDebugInformationFormat | |
parent | bb500723555940a29355a71898b44be196dec2a6 (diff) | |
download | CMake-5fcadc481e4b60e5dbbacb026b73631b69ca3746.zip CMake-5fcadc481e4b60e5dbbacb026b73631b69ca3746.tar.gz CMake-5fcadc481e4b60e5dbbacb026b73631b69ca3746.tar.bz2 |
MSVC: Default to -ZI instead of /Zi for x86 and x64
Add a policy for compatibility.
For more information, see [1].
[1] https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=msvc-170
Fixes: #10189
Diffstat (limited to 'Tests/RunCMake/MSVCDebugInformationFormat')
6 files changed, 34 insertions, 0 deletions
diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-NEW.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-NEW.cmake new file mode 100644 index 0000000..7dda266 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0138 NEW) +include(CMP0138-common.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-OLD.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-OLD.cmake new file mode 100644 index 0000000..43e4668 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0138 OLD) +include(CMP0138-common.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-WARN.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-WARN.cmake new file mode 100644 index 0000000..2a0dd0e --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0138-common.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-common.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-common.cmake new file mode 100644 index 0000000..89a5ca1 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0138-common.cmake @@ -0,0 +1,20 @@ +foreach(lang C CXX) + enable_language(${lang}) + + cmake_policy(GET CMP0138 cmp0138) + if(cmp0138 STREQUAL "NEW") + if(NOT " ${CMAKE_${lang}_FLAGS_DEBUG} " MATCHES " -ZI ") + message(SEND_ERROR "CMAKE_${lang}_FLAGS_DEBUG does not have '-ZI' under NEW behavior") + endif() + if(NOT " ${CMAKE_${lang}_FLAGS_RELWITHDEBINFO} " MATCHES " -ZI ") + message(SEND_ERROR "CMAKE_${lang}_FLAGS_RELWITHDEBINFO does not have '-ZI' under NEW behavior") + endif() + else() + if(NOT " ${CMAKE_${lang}_FLAGS_DEBUG} " MATCHES " /Zi ") + message(SEND_ERROR "CMAKE_${lang}_FLAGS_DEBUG does not have '/Zi' under OLD behavior") + endif() + if(NOT " ${CMAKE_${lang}_FLAGS_RELWITHDEBINFO} " MATCHES " /Zi ") + message(SEND_ERROR "CMAKE_${lang}_FLAGS_RELWITHDEBINFO does not have '/Zi' under OLD behavior") + endif() + endif() +endforeach() diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMakeLists.txt b/Tests/RunCMake/MSVCDebugInformationFormat/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/RunCMakeTest.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/RunCMakeTest.cmake new file mode 100644 index 0000000..7210fcd --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0138-WARN) +run_cmake(CMP0138-OLD) +run_cmake(CMP0138-NEW) |