mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 04:31:04 -06:00
VS: Add support for VS_DEBUGGER_* properties on custom targets
Visual studio itself supports the corresponding `LocalDebugger*` properties on utility targets; support generating them from CMake as well.
This commit is contained in:
6
Help/release/dev/vs-debug-utility-targets.rst
Normal file
6
Help/release/dev/vs-debug-utility-targets.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
vs-debug-utility-targets
|
||||
------------------------
|
||||
|
||||
* :ref:`Visual Studio Generators` for VS 2010 and above learned
|
||||
to support the ``VS_DEBUGGER_*`` properties on targets created
|
||||
via :command:`add_custom_target`.
|
||||
@@ -2283,6 +2283,58 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
|
||||
e1.Element("_ProjectFileVersion", "10.0.20506.1");
|
||||
for (std::string const& config : this->Configurations) {
|
||||
const std::string cond = this->CalcCondition(config);
|
||||
|
||||
if (ttype <= cmStateEnums::UTILITY) {
|
||||
if (const char* workingDir = this->GeneratorTarget->GetProperty(
|
||||
"VS_DEBUGGER_WORKING_DIRECTORY")) {
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(workingDir);
|
||||
std::string genWorkingDir =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond,
|
||||
genWorkingDir);
|
||||
}
|
||||
|
||||
if (const char* environment =
|
||||
this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) {
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(environment);
|
||||
std::string genEnvironment =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond,
|
||||
genEnvironment);
|
||||
}
|
||||
|
||||
if (const char* debuggerCommand =
|
||||
this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
|
||||
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(debuggerCommand);
|
||||
std::string genDebuggerCommand =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerCommand", cond,
|
||||
genDebuggerCommand);
|
||||
}
|
||||
|
||||
if (const char* commandArguments = this->GeneratorTarget->GetProperty(
|
||||
"VS_DEBUGGER_COMMAND_ARGUMENTS")) {
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(commandArguments);
|
||||
std::string genCommandArguments =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond,
|
||||
genCommandArguments);
|
||||
}
|
||||
}
|
||||
|
||||
if (ttype >= cmStateEnums::UTILITY) {
|
||||
e1.WritePlatformConfigTag(
|
||||
"IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\");
|
||||
@@ -2347,55 +2399,6 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
|
||||
e1.WritePlatformConfigTag("ExcludePath", cond, sdkExcludeDirectories);
|
||||
}
|
||||
|
||||
if (const char* workingDir = this->GeneratorTarget->GetProperty(
|
||||
"VS_DEBUGGER_WORKING_DIRECTORY")) {
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(workingDir);
|
||||
std::string genWorkingDir =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond,
|
||||
genWorkingDir);
|
||||
}
|
||||
|
||||
if (const char* environment =
|
||||
this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) {
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(environment);
|
||||
std::string genEnvironment =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond,
|
||||
genEnvironment);
|
||||
}
|
||||
|
||||
if (const char* debuggerCommand =
|
||||
this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
|
||||
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(debuggerCommand);
|
||||
std::string genDebuggerCommand =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerCommand", cond,
|
||||
genDebuggerCommand);
|
||||
}
|
||||
|
||||
if (const char* commandArguments = this->GeneratorTarget->GetProperty(
|
||||
"VS_DEBUGGER_COMMAND_ARGUMENTS")) {
|
||||
cmGeneratorExpression ge;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||
ge.Parse(commandArguments);
|
||||
std::string genCommandArguments =
|
||||
cge->Evaluate(this->LocalGenerator, config);
|
||||
|
||||
e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond,
|
||||
genCommandArguments);
|
||||
}
|
||||
|
||||
std::string name =
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
|
||||
e1.WritePlatformConfigTag("TargetName", cond, name);
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
foreach(target foo bar)
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(debuggerCommandSet FALSE)
|
||||
set(debuggerCommandSet FALSE)
|
||||
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo")
|
||||
message(STATUS "foo.vcxproj has debugger command set")
|
||||
set(debuggerCommandSet TRUE)
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo")
|
||||
message(STATUS "${target}.vcxproj has debugger command set")
|
||||
set(debuggerCommandSet TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerCommandSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerCommand not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerCommandSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerCommand not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
enable_language(CXX)
|
||||
add_library(foo foo.cpp)
|
||||
add_custom_target(bar)
|
||||
|
||||
set_target_properties(foo PROPERTIES
|
||||
set_target_properties(foo bar PROPERTIES
|
||||
VS_DEBUGGER_COMMAND "my-debugger-command $<TARGET_PROPERTY:foo,NAME>")
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
foreach(target foo bar)
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(debuggerCommandArgumentsSet FALSE)
|
||||
set(debuggerCommandArgumentsSet FALSE)
|
||||
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo")
|
||||
message(STATUS "foo.vcxproj has debugger command arguments set")
|
||||
set(debuggerCommandArgumentsSet TRUE)
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo")
|
||||
message(STATUS "${target}.vcxproj has debugger command arguments set")
|
||||
set(debuggerCommandArgumentsSet TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerCommandArgumentsSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerCommandArgumentsSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
enable_language(CXX)
|
||||
add_library(foo foo.cpp)
|
||||
add_custom_target(bar)
|
||||
|
||||
set_target_properties(foo PROPERTIES
|
||||
set_target_properties(foo bar PROPERTIES
|
||||
VS_DEBUGGER_COMMAND_ARGUMENTS "my-debugger-command-arguments $<TARGET_PROPERTY:foo,NAME>")
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
foreach(target foo bar)
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(debuggerEnvironmentSet FALSE)
|
||||
set(debuggerEnvironmentSet FALSE)
|
||||
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo")
|
||||
message(STATUS "foo.vcxproj has debugger environment set")
|
||||
set(debuggerEnvironmentSet TRUE)
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo")
|
||||
message(STATUS "${target}.vcxproj has debugger environment set")
|
||||
set(debuggerEnvironmentSet TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerEnvironmentSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerEnvironmentSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
enable_language(CXX)
|
||||
add_library(foo foo.cpp)
|
||||
add_custom_target(bar)
|
||||
|
||||
set_target_properties(foo PROPERTIES
|
||||
set_target_properties(foo bar PROPERTIES
|
||||
VS_DEBUGGER_ENVIRONMENT "my-debugger-environment $<TARGET_PROPERTY:foo,NAME>")
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
foreach(target foo bar)
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(debuggerWorkDirSet FALSE)
|
||||
set(debuggerWorkDirSet FALSE)
|
||||
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo")
|
||||
message(STATUS "foo.vcxproj has debugger working dir set")
|
||||
set(debuggerWorkDirSet TRUE)
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo")
|
||||
message(STATUS "${target}.vcxproj has debugger working dir set")
|
||||
set(debuggerWorkDirSet TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerWorkDirSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT debuggerWorkDirSet)
|
||||
set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
enable_language(CXX)
|
||||
add_library(foo foo.cpp)
|
||||
add_custom_target(bar)
|
||||
|
||||
set_target_properties(foo PROPERTIES
|
||||
set_target_properties(foo bar PROPERTIES
|
||||
VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory $<TARGET_PROPERTY:foo,NAME>")
|
||||
|
||||
Reference in New Issue
Block a user