Commit 0cd45184 authored by Luca Cappa's avatar Luca Cappa

Add VS_EDIT_AND_CONTINUE_DEBUGGING variable.

parent 32a569e8
Pipeline #132504 passed with stage
......@@ -184,3 +184,9 @@ mark_as_advanced(
CMAKE_SKIP_INSTALL_RPATH
CMAKE_VERBOSE_MAKEFILE
)
# Default value for MSVC target property for passing /ZI flag to CXX flags for
# Edit and Continue functionality
if(NOT DEFINED CMAKE_VS_EDIT_AND_CONTINUE_DEBUGGING)
set(CMAKE_VS_EDIT_AND_CONTINUE_DEBUGGING "$<CONFIG:Debug>")
endif()
......@@ -358,9 +358,9 @@ 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 /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 /O2 /Ob1 /DNDEBUG")
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD /O1 /Ob1 /DNDEBUG")
endif()
endif()
......
......@@ -134,6 +134,35 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
{
std::string flags = this->GetFlags(language);
// For MSVC only
cmMakefile* mf = this->GetMakefile();
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CUDA_ARCHITECTURE_ID")) {
// If the target is a Managed C++ one. /JMC and /ZI are both not
// compatible.
if (this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME") ==
nullptr) {
// add /ZI flags if target property VS_EDIT_AND_CONTINUE_DEBUGGING is
// set to ON
std::string debugFlag = "/Zi";
if (char const* encExprGen = this->GeneratorTarget->GetProperty(
"VS_EDIT_AND_CONTINUE_DEBUGGING")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(encExprGen);
std::string isEMCEnabled =
cge->Evaluate(this->LocalGenerator, this->ConfigName);
if (cmSystemTools::IsOn(isEMCEnabled)) {
// Use /ZI if Edit and Continue is enabled.
debugFlag = "/ZI";
}
}
flags += " " + debugFlag;
}
}
// Add Fortran format flags.
if (language == "Fortran") {
this->AppendFortranFormatFlags(flags, *source);
......
......@@ -202,6 +202,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// Setup default property values.
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
this->SetPropertyDefault("VS_EDIT_AND_CONTINUE_DEBUGGING", nullptr);
this->SetPropertyDefault("ANDROID_API", nullptr);
this->SetPropertyDefault("ANDROID_API_MIN", nullptr);
this->SetPropertyDefault("ANDROID_ARCH", nullptr);
......
......@@ -2611,6 +2611,26 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
}
// Handle Edit and Continue debugging.
// If the target is a Managed C++ one. /JMC and /ZI are both not compatible.
if (this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME") ==
nullptr) {
std::string debugFlag = "/Zi"; // Defaults to /Zi
if (char const* encExprGen = this->GeneratorTarget->GetProperty(
"VS_EDIT_AND_CONTINUE_DEBUGGING")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(encExprGen);
std::string isENCEnabled =
cge->Evaluate(this->LocalGenerator, configName);
if (cmSystemTools::IsOn(isENCEnabled)) {
debugFlag = "/ZI";
}
}
flags += " " + debugFlag;
}
clOptions.Parse(flags);
clOptions.Parse(defineFlags);
std::vector<std::string> targetDefines;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment