diff options
author | Brad King <brad.king@kitware.com> | 2022-09-14 13:21:08 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-09-14 13:21:27 (GMT) |
commit | c3e68020d61ae306261b4f953947483a960edf32 (patch) | |
tree | 49ab480611211dd6ee15714192dd8e29d22cbe7f /Source | |
parent | e457663ac15e138ce7618d2f74c9656665ab139b (diff) | |
parent | a858466aacb046a953367aeb2ee6c456812fc2dd (diff) | |
download | CMake-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 'Source')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 11 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmPolicies.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
4 files changed, 52 insertions, 1 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 654c9a3..75aef16 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -95,6 +95,8 @@ std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES = std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED"; std::string const kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT = "CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT"; +std::string const kCMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT = + "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT"; /* GHS Multi platform variables */ std::set<std::string> const ghs_platform_vars{ @@ -498,6 +500,14 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, *cmp0123 == "NEW"_s ? "NEW" : "OLD"); } + /* Set MSVC debug information format policy to match our selection. */ + if (cmValue msvcDebugInformationFormatDefault = + this->Makefile->GetDefinition( + kCMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT)) { + fprintf(fout, "cmake_policy(SET CMP0141 %s)\n", + !msvcDebugInformationFormatDefault->empty() ? "NEW" : "OLD"); + } + /* Set cache/normal variable policy to match outer project. It may affect toolchain files. */ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) != @@ -861,6 +871,7 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, vars.insert(kCMAKE_WARN_DEPRECATED); vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s); vars.emplace("CMAKE_WATCOM_RUNTIME_LIBRARY"_s); + vars.emplace("CMAKE_MSVC_DEBUG_INFORMATION_FORMAT"_s); if (cmValue varListStr = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b44d2a0..defcba3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2041,6 +2041,41 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } } + + // Add MSVC debug information format flags. This is activated by the presence + // of a default selection whether or not it is overridden by a property. + cmValue msvcDebugInformationFormatDefault = this->Makefile->GetDefinition( + "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT"); + if (cmNonempty(msvcDebugInformationFormatDefault)) { + cmValue msvcDebugInformationFormatValue = + target->GetProperty("MSVC_DEBUG_INFORMATION_FORMAT"); + if (!msvcDebugInformationFormatValue) { + msvcDebugInformationFormatValue = msvcDebugInformationFormatDefault; + } + std::string const msvcDebugInformationFormat = + cmGeneratorExpression::Evaluate(*msvcDebugInformationFormatValue, this, + config, target); + if (!msvcDebugInformationFormat.empty()) { + if (cmValue msvcDebugInformationFormatOptions = + this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, + "_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_", + msvcDebugInformationFormat))) { + this->AppendCompileOptions(flags, *msvcDebugInformationFormatOptions); + } else if ((this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_COMPILER_ID")) == "MSVC"_s || + this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_SIMULATE_ID")) == "MSVC"_s) && + !cmSystemTools::GetErrorOccurredFlag()) { + // The compiler uses the MSVC ABI so it needs a known runtime library. + this->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("MSVC_DEBUG_INFORMATION_FORMAT value '", + msvcDebugInformationFormat, + "' not known for this ", lang, + " compiler.")); + } + } + } } void cmLocalGenerator::AddLanguageFlagsForLinking( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index fdda31e..ea25814 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -423,7 +423,11 @@ class cmMakefile; "The if() command supports path comparisons using PATH_EQUAL operator.", \ 3, 24, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0140, "The return() command checks its arguments.", 3, \ - 25, 0, cmPolicies::WARN) + 25, 0, cmPolicies::WARN) \ + SELECT( \ + POLICY, CMP0141, \ + "MSVC debug information format flags are selected by an abstraction.", 3, \ + 25, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 25ff3bf..e8fdc39 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -563,6 +563,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("AUTORCC_OPTIONS"); initProp("LINK_DEPENDS_NO_SHARED"); initProp("LINK_INTERFACE_LIBRARIES"); + initProp("MSVC_DEBUG_INFORMATION_FORMAT"); initProp("MSVC_RUNTIME_LIBRARY"); initProp("WATCOM_RUNTIME_LIBRARY"); initProp("WIN32_EXECUTABLE"); |