From e09a3eddb61e732728bd76d63fe8098f14c737c1 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Mon, 18 Oct 2021 06:35:11 +0100 Subject: Xcode: Support "GPU Frame Capture" scheme property Added XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE variable which sets the scheme property value for "GPU Frame Capture" in the Options section by setting the Xcode project variable "enableGPUFrameCaptureMode". Example values are "Metal" (1) and "Disabled" (3). XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE is initialized by the property CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE. Implements: #22700 --- Auxiliary/vim/syntax/cmake.vim | 2 ++ Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/XCODE_GENERATE_SCHEME.rst | 1 + .../XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst | 15 +++++++++++++++ .../dev/xcode-scheme-enable-gpu-frame-capture-mode.rst | 4 ++++ .../CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst | 15 +++++++++++++++ Source/cmTarget.cxx | 1 + Source/cmXCodeScheme.cxx | 12 ++++++++++++ 9 files changed, 52 insertions(+) create mode 100644 Help/prop_tgt/XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst create mode 100644 Help/release/dev/xcode-scheme-enable-gpu-frame-capture-mode.rst create mode 100644 Help/variable/CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index e09ecf3..80bde99 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -426,6 +426,7 @@ syn keyword cmakeProperty contained \ XCODE_SCHEME_ARGUMENTS \ XCODE_SCHEME_DEBUG_AS_ROOT \ XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING + \ XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE \ XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER \ XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS \ XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE @@ -1524,6 +1525,7 @@ syn keyword cmakeVariable contained \ CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER \ CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN \ CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING + \ CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE \ CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER \ CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS \ CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 435b2c6..4fc26ab 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -426,6 +426,7 @@ Properties on Targets /prop_tgt/XCODE_SCHEME_ARGUMENTS /prop_tgt/XCODE_SCHEME_DEBUG_AS_ROOT /prop_tgt/XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING + /prop_tgt/XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE /prop_tgt/XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER /prop_tgt/XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS /prop_tgt/XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index ad96c09..d2dc618 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -259,6 +259,7 @@ Variables that Change Behavior /variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER /variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN /variable/CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING + /variable/CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE /variable/CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER /variable/CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS /variable/CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE diff --git a/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst b/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst index 06a3cf9..8f46d2f 100644 --- a/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst +++ b/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst @@ -38,6 +38,7 @@ The following target properties will be applied on the - :prop_tgt:`XCODE_SCHEME_ARGUMENTS` - :prop_tgt:`XCODE_SCHEME_DEBUG_AS_ROOT` - :prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING` +- :prop_tgt:`XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE` - :prop_tgt:`XCODE_SCHEME_ENVIRONMENT` - :prop_tgt:`XCODE_SCHEME_EXECUTABLE` - :prop_tgt:`XCODE_SCHEME_WORKING_DIRECTORY` diff --git a/Help/prop_tgt/XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst b/Help/prop_tgt/XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst new file mode 100644 index 0000000..6ffd694 --- /dev/null +++ b/Help/prop_tgt/XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst @@ -0,0 +1,15 @@ +XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE +------------------------------------------ + +.. versionadded:: 3.23 + +Property value for ``GPU Frame Capture`` in the Options section of +the generated Xcode scheme. Example values are `Metal` and +`Disabled`. + +This property is initialized by the value of the variable +:variable:`CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE` +if it is set when a target is created. + +Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property +documentation to see all Xcode schema related properties. diff --git a/Help/release/dev/xcode-scheme-enable-gpu-frame-capture-mode.rst b/Help/release/dev/xcode-scheme-enable-gpu-frame-capture-mode.rst new file mode 100644 index 0000000..a93e4e9 --- /dev/null +++ b/Help/release/dev/xcode-scheme-enable-gpu-frame-capture-mode.rst @@ -0,0 +1,4 @@ +xcode-scheme-enable-gpu-frame-capture-mode +------------------------------------------ + +* The Xcode project generation learned the variable `XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE` to enable specifying the Xcode scheme option property `GPU Frame Capture`. diff --git a/Help/variable/CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst b/Help/variable/CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst new file mode 100644 index 0000000..3a3c847 --- /dev/null +++ b/Help/variable/CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE.rst @@ -0,0 +1,15 @@ +CMAKE_XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE +------------------------------------------------ + +.. versionadded:: 3.23 + +Property value for ``GPU Frame Capture`` in the Options section of +the generated Xcode scheme. Example values are `Metal` and +`Disabled`. + +This variable initializes the +:prop_tgt:`XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE` +property on all targets. + +Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property +documentation to see all Xcode schema related properties. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 97d60cf..11d1503 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -395,6 +395,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("XCODE_SCHEME_ADDRESS_SANITIZER"); initProp("XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN"); initProp("XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING"); + initProp("XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE"); initProp("XCODE_SCHEME_THREAD_SANITIZER"); initProp("XCODE_SCHEME_THREAD_SANITIZER_STOP"); initProp("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER"); diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index e2c0f2d..2755d2f 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -9,6 +9,8 @@ #include +#include "cmsys/String.h" + #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -148,6 +150,16 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, true); xout.Attribute("debugServiceExtension", "internal"); xout.Attribute("allowLocationSimulation", "YES"); + if (cmValue gpuFrameCaptureMode = this->Target->GetTarget()->GetProperty( + "XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE")) { + std::string value = *gpuFrameCaptureMode; + if (cmsysString_strcasecmp(value.c_str(), "Metal") == 0) { + value = "1"; + } else if (cmsysString_strcasecmp(value.c_str(), "Disabled") == 0) { + value = "3"; + } + xout.Attribute("enableGPUFrameCaptureMode", value); + } // Diagnostics tab begin -- cgit v0.12 From 0798edfb85a52eca53fd699699c47ce12a42d051 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Tue, 9 Nov 2021 06:28:33 +0000 Subject: Tests: Xcode scheme ENABLE_GPU_FRAME_CAPTURE_MODE Setting numerical value Caseless comparison of string values "Metal" is converted to value 1 "Disabled" is converted to value 3 --- .../XcodeProject/XcodeSchemaProperty-check.cmake | 6 ++++++ .../RunCMake/XcodeProject/XcodeSchemaProperty.cmake | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake index c742f50..be44ecd 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake @@ -37,6 +37,12 @@ check_property("ZOMBIE_OBJECTS" "NSZombieEnabled") check_property("MALLOC_STACK" "MallocStackLogging") check_property("DYNAMIC_LINKER_API_USAGE" "DYLD_PRINT_APIS") check_property("DYNAMIC_LIBRARY_LOADS" "DYLD_PRINT_LIBRARIES") +check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_1" "enableGPUFrameCaptureMode=\"1\"") +check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_3" "enableGPUFrameCaptureMode=\"3\"") +check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_DISABLED" "enableGPUFrameCaptureMode=\"3\"") +check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_METAL" "enableGPUFrameCaptureMode=\"1\"") +check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_DISABLED_MIXED_CASE" "enableGPUFrameCaptureMode=\"3\"") +check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_METAL_MIXED_CASE" "enableGPUFrameCaptureMode=\"1\"") check_property("EXECUTABLE" "myExecutable") check_property("ARGUMENTS" [=["--foo"]=]) diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake index ce5c0c9..126a9fc 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake @@ -26,16 +26,22 @@ create_scheme_for_variable(MALLOC_STACK) create_scheme_for_variable(DYNAMIC_LINKER_API_USAGE) create_scheme_for_variable(DYNAMIC_LIBRARY_LOADS) -function(create_scheme_for_property property value) +function(create_scheme_for_property scheme property value) set(XCODE_SCHEME_${property} ON) - add_executable(${property} main.cpp) - set_target_properties(${property} PROPERTIES XCODE_SCHEME_${property} "${value}") + add_executable(${scheme} main.cpp) + set_target_properties(${scheme} PROPERTIES XCODE_SCHEME_${property} "${value}") endfunction() -create_scheme_for_property(EXECUTABLE myExecutable) -create_scheme_for_property(ARGUMENTS "--foo;--bar=baz") -create_scheme_for_property(ENVIRONMENT "FOO=foo;BAR=bar") -create_scheme_for_property(WORKING_DIRECTORY "/working/dir") +create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_1 ENABLE_GPU_FRAME_CAPTURE_MODE 1) +create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_3 ENABLE_GPU_FRAME_CAPTURE_MODE 3) +create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_DISABLED ENABLE_GPU_FRAME_CAPTURE_MODE Disabled) +create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_METAL ENABLE_GPU_FRAME_CAPTURE_MODE Metal) +create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_DISABLED_MIXED_CASE ENABLE_GPU_FRAME_CAPTURE_MODE DISAbled) +create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_METAL_MIXED_CASE ENABLE_GPU_FRAME_CAPTURE_MODE METal) +create_scheme_for_property(EXECUTABLE EXECUTABLE myExecutable) +create_scheme_for_property(ARGUMENTS ARGUMENTS "--foo;--bar=baz") +create_scheme_for_property(ENVIRONMENT ENVIRONMENT "FOO=foo;BAR=bar") +create_scheme_for_property(WORKING_DIRECTORY WORKING_DIRECTORY "/working/dir") add_executable(NoSchema main.cpp) set_target_properties(NoSchema PROPERTIES XCODE_GENERATE_SCHEME OFF) -- cgit v0.12