1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 17:31:57 +08:00

Xcode: Support for test action 'Build Configuration' scheme property

Also allow scoped property checking on Xcode scheme tests to
 be able to distinguish between launch and test actions build config.
This commit is contained in:
Cristiano Carvalheiro
2025-01-09 14:43:08 +00:00
parent 1f4e1ccbc8
commit 7d28005244
12 changed files with 60 additions and 4 deletions

View File

@@ -500,6 +500,7 @@ syn keyword cmakeProperty contained
\ XCODE_SCHEME_ENABLE_GPU_API_VALIDATION
\ XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION
\ XCODE_SCHEME_LAUNCH_CONFIGURATION
\ XCODE_SCHEME_TEST_CONFIGURATION
\ XCODE_SCHEME_WORKING_DIRECTORY
\ XCODE_SCHEME_ZOMBIE_OBJECTS
\ XCODE_XCCONFIG
@@ -1865,6 +1866,7 @@ syn keyword cmakeVariable contained
\ CMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION
\ CMAKE_XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION
\ CMAKE_XCODE_SCHEME_LAUNCH_CONFIGURATION
\ CMAKE_XCODE_SCHEME_TEST_CONFIGURATION
\ CMAKE_XCODE_SCHEME_WORKING_DIRECTORY
\ CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS
\ CMAKE_XCODE_XCCONFIG

View File

@@ -494,6 +494,7 @@ Properties on Targets
/prop_tgt/XCODE_SCHEME_EXECUTABLE
/prop_tgt/XCODE_SCHEME_GUARD_MALLOC
/prop_tgt/XCODE_SCHEME_LAUNCH_CONFIGURATION
/prop_tgt/XCODE_SCHEME_TEST_CONFIGURATION
/prop_tgt/XCODE_SCHEME_LAUNCH_MODE
/prop_tgt/XCODE_SCHEME_LLDB_INIT_FILE
/prop_tgt/XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP

View File

@@ -296,6 +296,7 @@ Variables that Change Behavior
/variable/CMAKE_XCODE_SCHEME_ENVIRONMENT
/variable/CMAKE_XCODE_SCHEME_GUARD_MALLOC
/variable/CMAKE_XCODE_SCHEME_LAUNCH_CONFIGURATION
/variable/CMAKE_XCODE_SCHEME_TEST_CONFIGURATION
/variable/CMAKE_XCODE_SCHEME_LAUNCH_MODE
/variable/CMAKE_XCODE_SCHEME_LLDB_INIT_FILE
/variable/CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP

View File

@@ -45,5 +45,6 @@ The following target properties will be applied on the
- :prop_tgt:`XCODE_SCHEME_EXECUTABLE`
- :prop_tgt:`XCODE_SCHEME_LAUNCH_CONFIGURATION`
- :prop_tgt:`XCODE_SCHEME_LAUNCH_MODE`
- :prop_tgt:`XCODE_SCHEME_TEST_CONFIGURATION`
- :prop_tgt:`XCODE_SCHEME_LLDB_INIT_FILE`
- :prop_tgt:`XCODE_SCHEME_WORKING_DIRECTORY`

View File

@@ -0,0 +1,13 @@
XCODE_SCHEME_TEST_CONFIGURATION
-------------------------------
.. versionadded:: 3.32
Set the build configuration to test the target.
This property is initialized by the value of the variable
:variable:`CMAKE_XCODE_SCHEME_TEST_CONFIGURATION`
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.

View File

@@ -0,0 +1,7 @@
xcode-scheme-test-config
------------------------
* The :variable:`CMAKE_XCODE_SCHEME_TEST_CONFIGURATION` variable and corresponding
:prop_tgt:`XCODE_SCHEME_TEST_CONFIGURATION` target property were added to tell
the :generator:`Xcode` generator what to put in the scheme's "Build Configuration"
setting for the test action.

View File

@@ -0,0 +1,12 @@
CMAKE_XCODE_SCHEME_TEST_CONFIGURATION
-------------------------------------
.. versionadded:: 3.32
Set the build configuration to test the target.
This variable initializes the :prop_tgt:`XCODE_SCHEME_TEST_CONFIGURATION`
property on all targets.
Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
documentation to see all Xcode schema related properties.

View File

@@ -621,6 +621,7 @@ TargetProperty const StaticTargetProperties[] = {
{ "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER"_s, IC::NeedsXcodeAndCanCompileSources },
{ "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP"_s, IC::NeedsXcodeAndCanCompileSources },
{ "XCODE_SCHEME_LAUNCH_CONFIGURATION"_s, IC::NeedsXcodeAndCanCompileSources },
{ "XCODE_SCHEME_TEST_CONFIGURATION"_s, IC::NeedsXcodeAndCanCompileSources },
{ "XCODE_SCHEME_ENABLE_GPU_API_VALIDATION"_s, IC::NeedsXcodeAndCanCompileSources },
{ "XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION"_s, IC::NeedsXcodeAndCanCompileSources },
{ "XCODE_SCHEME_WORKING_DIRECTORY"_s, IC::NeedsXcodeAndCanCompileSources },

View File

@@ -74,8 +74,13 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
std::string launchConfiguration =
!propDftCfg.IsEmpty() ? *propDftCfg : "Debug";
cmValue propTstCfg =
Target->GetTarget()->GetProperty("XCODE_SCHEME_TEST_CONFIGURATION");
std::string testConfiguration =
!propTstCfg.IsEmpty() ? *propTstCfg : "Debug";
WriteBuildAction(xout, container);
WriteTestAction(xout, FindConfiguration("Debug"), container);
WriteTestAction(xout, FindConfiguration(testConfiguration), container);
WriteLaunchAction(xout, FindConfiguration(launchConfiguration), container);
WriteProfileAction(xout, FindConfiguration("Release"), container);
WriteAnalyzeAction(xout, FindConfiguration("Debug"));

View File

@@ -1,8 +1,8 @@
function(check_property property matcher)
set(schema "${RunCMake_TEST_BINARY_DIR}/XcodeSchemaProperty.xcodeproj/xcshareddata/xcschemes/${property}.xcscheme")
file(STRINGS ${schema} actual-${property}
REGEX "${matcher}" LIMIT_COUNT 1)
if(NOT actual-${property})
file(READ ${schema} schema-content-${property})
string(REGEX MATCHALL "${matcher}" matched-${property} ${schema-content-${property}})
if(NOT matched-${property})
string(APPEND RunCMake_TEST_FAILED
"Xcode schema property ${property}: Could not find\n"
" ${matcher}\n"
@@ -102,6 +102,12 @@ check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_DISABLED_MIXED_CASE" "enableGPUFra
check_property("ENABLE_GPU_FRAME_CAPTURE_MODE_METAL_MIXED_CASE" "enableGPUFrameCaptureMode=\"1\"")
check_property("LAUNCH_MODE_AUTO" "launchStyle=\"0\"")
check_property("LAUNCH_MODE_WAIT" "launchStyle=\"1\"")
check_property("LAUNCH_CONFIGURATION_EMPTY" "<LaunchAction.*buildConfiguration=\"Debug\".*</LaunchAction>")
check_property("LAUNCH_CONFIGURATION_DEBUG" "<LaunchAction.*buildConfiguration=\"Debug\".*</LaunchAction>")
check_property("LAUNCH_CONFIGURATION_RELEASE" "<LaunchAction.*buildConfiguration=\"Release\".*</LaunchAction>")
check_property("TEST_CONFIGURATION_EMPTY" "<TestAction.*buildConfiguration=\"Debug\".*</TestAction>")
check_property("TEST_CONFIGURATION_DEBUG" "<TestAction.*buildConfiguration=\"Debug\".*</TestAction>")
check_property("TEST_CONFIGURATION_RELEASE" "<TestAction.*buildConfiguration=\"Release\".*</TestAction>")
check_no_property("LLDB_INIT_FILE_EMPTY" "customLLDBInitFile")
check_property_count("LLDB_INIT_FILE_EVAL" "customLLDBInitFile=\"${RunCMake_TEST_BINARY_DIR}/.lldbinit\"" 2)
check_property_count("LLDB_INIT_FILE_FULL" "customLLDBInitFile=\"/full/path/to/.lldbinit\"" 2)

View File

@@ -40,6 +40,12 @@ create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_DISABLED_MIXED_CASE ENA
create_scheme_for_property(ENABLE_GPU_FRAME_CAPTURE_MODE_METAL_MIXED_CASE ENABLE_GPU_FRAME_CAPTURE_MODE METal)
create_scheme_for_property(LAUNCH_MODE_AUTO LAUNCH_MODE AUTO)
create_scheme_for_property(LAUNCH_MODE_WAIT LAUNCH_MODE WAIT)
create_scheme_for_property(LAUNCH_CONFIGURATION_EMPTY LAUNCH_CONFIGURATION "")
create_scheme_for_property(LAUNCH_CONFIGURATION_DEBUG LAUNCH_CONFIGURATION "Debug")
create_scheme_for_property(LAUNCH_CONFIGURATION_RELEASE LAUNCH_CONFIGURATION "Release")
create_scheme_for_property(TEST_CONFIGURATION_EMPTY TEST_CONFIGURATION "")
create_scheme_for_property(TEST_CONFIGURATION_DEBUG TEST_CONFIGURATION "Debug")
create_scheme_for_property(TEST_CONFIGURATION_RELEASE TEST_CONFIGURATION "Release")
create_scheme_for_property(LLDB_INIT_FILE_EMPTY LLDB_INIT_FILE "")
create_scheme_for_property(LLDB_INIT_FILE_EVAL LLDB_INIT_FILE "${CMAKE_BINARY_DIR}/.lldbinit")
create_scheme_for_property(LLDB_INIT_FILE_FULL LLDB_INIT_FILE "/full/path/to/.lldbinit")

View File

@@ -194,6 +194,7 @@ if (CMAKE_HOST_APPLE) # compile-guarded in CMake
"XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER" "ON" "<SAME>"
"XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP" "ON" "<SAME>"
"XCODE_SCHEME_LAUNCH_CONFIGURATION" "ON" "<SAME>"
"XCODE_SCHEME_TEST_CONFIGURATION" "ON" "<SAME>"
"XCODE_SCHEME_ENABLE_GPU_API_VALIDATION" "ON" "<SAME>"
"XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION" "ON" "<SAME>"
"XCODE_SCHEME_WORKING_DIRECTORY" "ON" "<SAME>"