diff options
author | Ross Kilgariff <ross@ninjakiwi.com> | 2023-01-25 19:37:08 +0000 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-01-25 15:15:03 -0500 |
commit | 01c1d81527aec261445fa533d5f92ca473f77160 (patch) | |
tree | 7368616a49310767abfd634ee749a8e55239ad0d /Tests/RunCMake/XcodeProject | |
parent | 950effe434623b50a1c85e2c53ed592210e79ceb (diff) | |
download | cmake-01c1d81527aec261445fa533d5f92ca473f77160.tar.gz |
Xcode: Inherit Swift flags and compilation conditions
Extend the change from commit dfaf55fbfd (Xcode: add extra
'$(inherited)' entries using InheritBuildSettingAttribute, 2021-05-03,
v3.21.0-rc1~182^2) to cover Swift flags and compilation conditions,
allowing CocoaPods and CMake to interoperate when used in the same
project.
Diffstat (limited to 'Tests/RunCMake/XcodeProject')
-rw-r--r-- | Tests/RunCMake/XcodeProject/InheritedParameters-check.cmake | 24 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/InheritedParameters.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 2 |
3 files changed, 30 insertions, 1 deletions
diff --git a/Tests/RunCMake/XcodeProject/InheritedParameters-check.cmake b/Tests/RunCMake/XcodeProject/InheritedParameters-check.cmake index 4fe42acb0a..59e3f4be23 100644 --- a/Tests/RunCMake/XcodeProject/InheritedParameters-check.cmake +++ b/Tests/RunCMake/XcodeProject/InheritedParameters-check.cmake @@ -7,6 +7,8 @@ endif() set(found_inherited_GCC_PREPROCESSOR_DEFINITIONS 1) set(found_inherited_OTHER_CFLAGS 1) set(found_inherited_OTHER_LDFLAGS 1) +set(found_inherited_OTHER_SWIFT_FLAGS 1) +set(found_inherited_SWIFT_ACTIVE_COMPILATION_CONDITIONS 1) file(STRINGS "${xcProjectFile}" lines) foreach(line IN LISTS lines) @@ -32,6 +34,20 @@ foreach(line IN LISTS lines) endif() endif() + if(line MATCHES [[OTHER_SWIFT_FLAGS]]) + if(NOT line MATCHES [["\$\(inherited\)"]]) + string(APPEND relevant_lines " ${line}\n") + set(found_inherited_OTHER_SWIFT_FLAGS 0) + endif() + endif() + + if(line MATCHES [[SWIFT_ACTIVE_COMPILATION_CONDITIONS]]) + if(NOT line MATCHES [["\$\(inherited\)"]]) + string(APPEND relevant_lines " ${line}\n") + set(found_inherited_SWIFT_ACTIVE_COMPILATION_CONDITIONS 0) + endif() + endif() + endforeach() if(NOT found_inherited_GCC_PREPROCESSOR_DEFINITIONS) @@ -43,6 +59,14 @@ endif() if(NOT found_inherited_OTHER_LDFLAGS) string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for OTHER_LDFLAGS in\n ${xcProjectFile}\n") endif() +if(CMake_TEST_Swift) + if(NOT found_inherited_OTHER_SWIFT_FLAGS) + string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for OTHER_SWIFT_FLAGS in\n ${xcProjectFile}\n") + endif() + if(NOT found_inherited_SWIFT_ACTIVE_COMPILATION_CONDITIONS) + string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for SWIFT_ACTIVE_COMPILATION_CONDITIONS in\n ${xcProjectFile}\n") + endif() +endif() if(RunCMake_TEST_FAILED) string(APPEND RunCMake_TEST_FAILED "Relevant lines include\n${relevant_lines}") diff --git a/Tests/RunCMake/XcodeProject/InheritedParameters.cmake b/Tests/RunCMake/XcodeProject/InheritedParameters.cmake index 5b8ec7117d..e2cc2a75c3 100644 --- a/Tests/RunCMake/XcodeProject/InheritedParameters.cmake +++ b/Tests/RunCMake/XcodeProject/InheritedParameters.cmake @@ -1,4 +1,9 @@ enable_language(C) +if(CMake_TEST_Swift) + enable_language(Swift) + string(APPEND CMAKE_Swift_FLAGS " -DSWIFTFLAG") + add_executable(swift_inherit_test dummy_main.swift) +endif() add_compile_definitions(TEST_INHERITTEST) string(APPEND CMAKE_C_FLAGS " -DTESTFLAG=\\\"TEST_INHERITTEST\\\"") diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 573d5f7198..3910127912 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -13,7 +13,7 @@ run_cmake(ExplicitCMakeLists) run_cmake(ImplicitCMakeLists) run_cmake(InterfaceLibSources) run_cmake_with_options(SearchPaths -DCMAKE_CONFIGURATION_TYPES=Debug) -run_cmake(InheritedParameters) +run_cmake_with_options(InheritedParameters -DCMake_TEST_Swift=${CMake_TEST_Swift}) run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) |