summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-09-14 13:21:08 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-09-14 13:21:27 (GMT)
commitc3e68020d61ae306261b4f953947483a960edf32 (patch)
tree49ab480611211dd6ee15714192dd8e29d22cbe7f /Modules
parente457663ac15e138ce7618d2f74c9656665ab139b (diff)
parenta858466aacb046a953367aeb2ee6c456812fc2dd (diff)
downloadCMake-c3e68020d61ae306261b4f953947483a960edf32.zip
CMake-c3e68020d61ae306261b4f953947483a960edf32.tar.gz
CMake-c3e68020d61ae306261b4f953947483a960edf32.tar.bz2
Merge topic 'MsvcDebugInformationFormatAbstraction'
a858466aac MSVC: Add test for debug information format 0e96a20478 MSVC: Add abstraction for debug information format d4c8111da4 Clang/Windows: Clarify name of internal runtime library flags variables Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7606
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Platform/Windows-Clang.cmake40
-rw-r--r--Modules/Platform/Windows-Intel-Fortran.cmake2
-rw-r--r--Modules/Platform/Windows-IntelLLVM-Fortran.cmake2
-rw-r--r--Modules/Platform/Windows-MSVC.cmake21
-rw-r--r--Modules/Platform/Windows-NVIDIA-CUDA.cmake14
5 files changed, 65 insertions, 14 deletions
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index 3941311..5edcb61 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -89,17 +89,27 @@ macro(__windows_compiler_clang_gnu lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd)
if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
- set(__ADDED_FLAGS "")
- set(__ADDED_FLAGS_DEBUG "")
+ set(_RTL_FLAGS "")
+ set(_RTL_FLAGS_DEBUG "")
else()
- set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd")
- set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt")
+ set(_RTL_FLAGS_DEBUG " -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd")
+ set(_RTL_FLAGS " -D_DLL -D_MT -Xclang --dependent-lib=msvcrt")
endif()
- string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}")
- string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}")
- string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}")
- string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}")
+ if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT)
+ set(_DBG_FLAGS "")
+ else()
+ set(_DBG_FLAGS " -g -Xclang -gcodeview")
+ endif()
+
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -O0${_DBG_FLAGS}${_RTL_FLAGS_DEBUG}")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG${_RTL_FLAGS}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG${_RTL_FLAGS}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -DNDEBUG${_DBG_FLAGS}${_RTL_FLAGS}")
+
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -g -Xclang -gcodeview)
+ #set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase) # not supported by Clang
+ #set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # not supported by Clang
endif()
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON)
@@ -109,8 +119,9 @@ macro(__windows_compiler_clang_gnu lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
- unset(__ADDED_FLAGS)
- unset(__ADDED_FLAGS_DEBUG)
+ unset(_DBG_FLAGS)
+ unset(_RTL_FLAGS)
+ unset(_RTL_FLAGS_DEBUG)
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames")
@@ -190,6 +201,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
macro(__windows_compiler_clang_base lang)
set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}")
__windows_compiler_msvc(${lang})
+ unset(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # -ZI not supported by Clang
set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX")
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc")
endmacro()
@@ -202,6 +214,14 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
endif()
unset(__WINDOWS_CLANG_CMP0091)
+ cmake_policy(GET CMP0141 __WINDOWS_MSVC_CMP0141)
+ if(__WINDOWS_MSVC_CMP0141 STREQUAL "NEW")
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
+ else()
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "")
+ endif()
+ unset(__WINDOWS_MSVC_CMP0141)
+
set(CMAKE_BUILD_TYPE_INIT Debug)
__enable_llvm_rc_preprocessing("" "-x c")
diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake
index e3804fb..c9b70d5 100644
--- a/Modules/Platform/Windows-Intel-Fortran.cmake
+++ b/Modules/Platform/Windows-Intel-Fortran.cmake
@@ -33,6 +33,8 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -th
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi)
# Intel Fortran for Windows supports single-threaded RTL but it is
# not implemented by the Visual Studio integration.
diff --git a/Modules/Platform/Windows-IntelLLVM-Fortran.cmake b/Modules/Platform/Windows-IntelLLVM-Fortran.cmake
index 06d0a00..202ba23 100644
--- a/Modules/Platform/Windows-IntelLLVM-Fortran.cmake
+++ b/Modules/Platform/Windows-IntelLLVM-Fortran.cmake
@@ -33,6 +33,8 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -th
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi)
# Intel Fortran for Windows supports single-threaded RTL but it is
# not implemented by the Visual Studio integration.
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index e74ec9e..8e96bf4 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -331,6 +331,13 @@ else()
endif()
unset(__WINDOWS_MSVC_CMP0091)
+cmake_policy(GET CMP0141 __WINDOWS_MSVC_CMP0141)
+if(__WINDOWS_MSVC_CMP0141 STREQUAL "NEW")
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>")
+else()
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "")
+endif()
+unset(__WINDOWS_MSVC_CMP0141)
# Features for LINK_LIBRARY generator expression
if(MSVC_VERSION GREATER "1900")
@@ -441,6 +448,12 @@ macro(__windows_compiler_msvc lang)
endif()
unset(_cmp0092)
+ if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT)
+ set(_Zi "")
+ else()
+ set(_Zi " /Zi")
+ endif()
+
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.
@@ -451,20 +464,24 @@ macro(__windows_compiler_msvc lang)
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang
else()
string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS${_W3}${_FLAGS_${lang}}")
- string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} /Zi /Ob0 /Od ${_RTC1}")
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_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_RELWITHDEBINFO_INIT "${_MD}${_Zi} /O2 /Ob1 /DNDEBUG")
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} /O1 /Ob1 /DNDEBUG")
endif()
unset(_Wall)
unset(_W3)
unset(_MDd)
unset(_MD)
+ unset(_Zi)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -MT)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -MD)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -MTd)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -MDd)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue -ZI)
endif()
set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON)
diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake
index 6c1699b..326e715 100644
--- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake
+++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake
@@ -57,6 +57,12 @@ else()
set(_MD "-MD ")
endif()
+if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT)
+ set(_Zi "")
+else()
+ set(_Zi " -Zi")
+endif()
+
cmake_policy(GET CMP0092 _cmp0092)
if(_cmp0092 STREQUAL "NEW")
set(_W3 "")
@@ -66,11 +72,12 @@ endif()
unset(_cmp0092)
string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"${_W3}${_FLAGS_CXX}\"")
-string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}-Zi -Ob0 -Od ${_RTC1}\"")
+string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}${_Zi} -Ob0 -Od ${_RTC1}\"")
string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"${_MD}-O2 -Ob2\" -DNDEBUG")
-string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}-Zi -O2 -Ob1\" -DNDEBUG")
+string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}${_Zi} -O2 -Ob1\" -DNDEBUG")
string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=\"${_MD}-O1 -Ob1\" -DNDEBUG")
unset(_W3)
+unset(_Zi)
unset(_MDd)
unset(_MD)
@@ -78,6 +85,9 @@ set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xcomp
set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -Xcompiler=-MD)
set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -Xcompiler=-MTd)
set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -Xcompiler=-MDd)
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Xcompiler=-Z7)
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Xcompiler=-Zi)
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue -Xcompiler=-ZI)
set(CMAKE_CUDA_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")