summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCoreTryCompile.cxx11
-rw-r--r--Source/cmLocalGenerator.cxx35
-rw-r--r--Source/cmPolicies.h6
-rw-r--r--Source/cmTarget.cxx1
4 files changed, 52 insertions, 1 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 0a6c359..85ffd3b 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -94,6 +94,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{
@@ -497,6 +499,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) !=
@@ -849,6 +859,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 eb3feaa..df2bdba 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");