summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-13 20:16:26 (GMT)
committerBrad King <brad.king@kitware.com>2024-02-19 15:40:40 (GMT)
commit67de5b7b82c6f61c5d349c70de81dde58bb79dd1 (patch)
treeaa04c9e284375dfd760a08fac13ba5018bdfcf97
parent0ae372daee75e6d5305ec9f934c2adce3074ca5d (diff)
downloadCMake-67de5b7b82c6f61c5d349c70de81dde58bb79dd1.zip
CMake-67de5b7b82c6f61c5d349c70de81dde58bb79dd1.tar.gz
CMake-67de5b7b82c6f61c5d349c70de81dde58bb79dd1.tar.bz2
VS: Suppress MSBuild default settings affected by UseDebugLibraries
`Microsoft.Cl.Common.props` changes some default settings based on `UseDebugLibraries`. CMake models its own controls for these settings, so if the project does not set them, explicitly suppress them to avoid letting `UseDebugLibraries` affect them.
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx22
-rw-r--r--Tests/MSVCRuntimeLibrary/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake2
-rw-r--r--Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake2
4 files changed, 23 insertions, 7 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ced7acd..8114b83 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3155,7 +3155,10 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
Options& linkOptions = *(this->LinkOptions[configName]);
const std::string cond = this->CalcCondition(configName);
- if (this->IPOEnabledConfigurations.count(configName) == 0) {
+ if (this->IPOEnabledConfigurations.count(configName) > 0) {
+ // Suppress LinkIncremental in favor of WholeProgramOptimization.
+ e1.WritePlatformConfigTag("LinkIncremental", cond, "");
+ } else {
const char* incremental = linkOptions.GetFlag("LinkIncremental");
e1.WritePlatformConfigTag("LinkIncremental", cond,
(incremental ? incremental : "true"));
@@ -3500,6 +3503,23 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.RemoveFlag("CompileAs");
}
+ if (this->ProjectType == VsProjectType::vcxproj && this->MSTools) {
+ // Suppress Microsoft.Cl.Common.props default settings for which the
+ // project specifies no flags. Do not let UseDebugLibraries affect them.
+ if (!clOptions.HasFlag("BasicRuntimeChecks")) {
+ clOptions.AddFlag("BasicRuntimeChecks", "Default");
+ }
+ if (!clOptions.HasFlag("Optimization")) {
+ clOptions.AddFlag("Optimization", "");
+ }
+ if (!clOptions.HasFlag("RuntimeLibrary")) {
+ clOptions.AddFlag("RuntimeLibrary", "");
+ }
+ if (!clOptions.HasFlag("SupportJustMyCode")) {
+ clOptions.AddFlag("SupportJustMyCode", "");
+ }
+ }
+
this->ClOptions[configName] = std::move(pOptions);
return true;
}
diff --git a/Tests/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/CMakeLists.txt
index f7d9fec..f1ed9b4 100644
--- a/Tests/MSVCRuntimeLibrary/CMakeLists.txt
+++ b/Tests/MSVCRuntimeLibrary/CMakeLists.txt
@@ -57,10 +57,6 @@ function(verify lang src)
# VS 2005 and above default to multi-threaded.
target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT)
endif()
- if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
- # VS 2010 and above have a different default runtime library for projects than 'cl'.
- target_compile_definitions(empty-${lang} PRIVATE VERIFY_DLL)
- endif()
endif()
endfunction()
diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
index 689b35f..b5b195a 100644
--- a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
+++ b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
@@ -9,7 +9,7 @@ macro(RuntimeLibrary_check tgt rtl_expect)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
- if(line MATCHES "^ *<RuntimeLibrary>([^<>]+)</RuntimeLibrary>")
+ if(line MATCHES "^ *<RuntimeLibrary>([^<>]*)</RuntimeLibrary>")
set(rtl_actual "${CMAKE_MATCH_1}")
if(NOT "${rtl_actual}" STREQUAL "${rtl_expect}")
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has RuntimeLibrary '${rtl_actual}', not '${rtl_expect}'.")
diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake
index 7119976..e76d931 100644
--- a/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake
+++ b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake
@@ -9,7 +9,7 @@ macro(VsJustMyCode_check tgt jmc_expect)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
- if(line MATCHES "^ *<SupportJustMyCode>([^<>]+)</SupportJustMyCode>")
+ if(line MATCHES "^ *<SupportJustMyCode>([^<>]*)</SupportJustMyCode>")
set(jmc_actual "${CMAKE_MATCH_1}")
if(NOT "${jmc_actual}" STREQUAL "${jmc_expect}")
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SupportJustMyCode> '${jmc_actual}', not '${jmc_expect}'.")