Quellcode durchsuchen

Merge topic 'xcode-swift-inherited-flags'

01c1d81527 Xcode: Inherit Swift flags and compilation conditions

Acked-by: Kitware Robot <[email protected]>
Merge-request: !8122
Brad King vor 2 Jahren
Ursprung
Commit
6dca2dd86d

+ 3 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -4536,6 +4536,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
     this->InheritBuildSettingAttribute(t, "GCC_PREPROCESSOR_DEFINITIONS");
     this->InheritBuildSettingAttribute(t, "OTHER_CFLAGS");
     this->InheritBuildSettingAttribute(t, "OTHER_LDFLAGS");
+    this->InheritBuildSettingAttribute(t, "OTHER_SWIFT_FLAGS");
+    this->InheritBuildSettingAttribute(t,
+                                       "SWIFT_ACTIVE_COMPILATION_CONDITIONS");
   }
 
   if (this->XcodeBuildSystem == BuildSystem::One) {

+ 2 - 1
Tests/RunCMake/CMakeLists.txt

@@ -636,7 +636,8 @@ if(CMAKE_GENERATOR MATCHES "^Visual Studio (1[6-9]|[2-9][0-9])")
 endif()
 
 if(XCODE_VERSION)
-  add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION})
+  add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}
+                                 -DCMake_TEST_Swift=${CMake_TEST_Swift})
   add_RunCMake_test(XcodeProject-Embed -DXCODE_VERSION=${XCODE_VERSION})
 
   # This test can take a very long time due to lots of combinations.

+ 24 - 0
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}")

+ 5 - 0
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\\\"")

+ 1 - 1
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)