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.
This commit is contained in:
parent
0ae372daee
commit
67de5b7b82
@ -3155,7 +3155,10 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
|
|||||||
Options& linkOptions = *(this->LinkOptions[configName]);
|
Options& linkOptions = *(this->LinkOptions[configName]);
|
||||||
const std::string cond = this->CalcCondition(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");
|
const char* incremental = linkOptions.GetFlag("LinkIncremental");
|
||||||
e1.WritePlatformConfigTag("LinkIncremental", cond,
|
e1.WritePlatformConfigTag("LinkIncremental", cond,
|
||||||
(incremental ? incremental : "true"));
|
(incremental ? incremental : "true"));
|
||||||
@ -3500,6 +3503,23 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||||||
clOptions.RemoveFlag("CompileAs");
|
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);
|
this->ClOptions[configName] = std::move(pOptions);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,6 @@ function(verify lang src)
|
|||||||
# VS 2005 and above default to multi-threaded.
|
# VS 2005 and above default to multi-threaded.
|
||||||
target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT)
|
target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT)
|
||||||
endif()
|
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()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ macro(RuntimeLibrary_check tgt rtl_expect)
|
|||||||
|
|
||||||
file(STRINGS "${vcProjectFile}" lines)
|
file(STRINGS "${vcProjectFile}" lines)
|
||||||
foreach(line IN LISTS lines)
|
foreach(line IN LISTS lines)
|
||||||
if(line MATCHES "^ *<RuntimeLibrary>([^<>]+)</RuntimeLibrary>")
|
if(line MATCHES "^ *<RuntimeLibrary>([^<>]*)</RuntimeLibrary>")
|
||||||
set(rtl_actual "${CMAKE_MATCH_1}")
|
set(rtl_actual "${CMAKE_MATCH_1}")
|
||||||
if(NOT "${rtl_actual}" STREQUAL "${rtl_expect}")
|
if(NOT "${rtl_actual}" STREQUAL "${rtl_expect}")
|
||||||
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has RuntimeLibrary '${rtl_actual}', not '${rtl_expect}'.")
|
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has RuntimeLibrary '${rtl_actual}', not '${rtl_expect}'.")
|
||||||
|
@ -9,7 +9,7 @@ macro(VsJustMyCode_check tgt jmc_expect)
|
|||||||
|
|
||||||
file(STRINGS "${vcProjectFile}" lines)
|
file(STRINGS "${vcProjectFile}" lines)
|
||||||
foreach(line IN LISTS lines)
|
foreach(line IN LISTS lines)
|
||||||
if(line MATCHES "^ *<SupportJustMyCode>([^<>]+)</SupportJustMyCode>")
|
if(line MATCHES "^ *<SupportJustMyCode>([^<>]*)</SupportJustMyCode>")
|
||||||
set(jmc_actual "${CMAKE_MATCH_1}")
|
set(jmc_actual "${CMAKE_MATCH_1}")
|
||||||
if(NOT "${jmc_actual}" STREQUAL "${jmc_expect}")
|
if(NOT "${jmc_actual}" STREQUAL "${jmc_expect}")
|
||||||
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SupportJustMyCode> '${jmc_actual}', not '${jmc_expect}'.")
|
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SupportJustMyCode> '${jmc_actual}', not '${jmc_expect}'.")
|
||||||
|
Loading…
Reference in New Issue
Block a user