From cb4e6702b26ce8fbe8b295b31c96841f2b32748a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Nov 2022 16:58:21 -0400 Subject: Xcode: Implement Swift include directories Populate Xcode's `SWIFT_INCLUDE_PATHS` build setting with the target-wide include directories. Issue: #24116 --- Source/cmGlobalXCodeGenerator.cxx | 3 +++ Tests/SwiftOnly/CMakeLists.txt | 3 +++ Tests/SwiftOnly/SubA/CMakeLists.txt | 2 ++ Tests/SwiftOnly/SubA/SubA.swift | 0 Tests/SwiftOnly/SubB/CMakeLists.txt | 2 ++ Tests/SwiftOnly/SubB/SubB.swift | 1 + 6 files changed, 11 insertions(+) create mode 100644 Tests/SwiftOnly/SubA/CMakeLists.txt create mode 100644 Tests/SwiftOnly/SubA/SubA.swift create mode 100644 Tests/SwiftOnly/SubB/CMakeLists.txt create mode 100644 Tests/SwiftOnly/SubB/SubB.swift diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e81ce22..0658021 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2780,6 +2780,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } if (!dirs.IsEmpty()) { buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); + if (languages.count("Swift")) { + buildSettings->AddAttribute("SWIFT_INCLUDE_PATHS", dirs.CreateList()); + } } if (!sysfdirs.IsEmpty()) { buildSettings->AddAttribute("SYSTEM_FRAMEWORK_SEARCH_PATHS", diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt index e92e544..fa8687d 100644 --- a/Tests/SwiftOnly/CMakeLists.txt +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -22,6 +22,9 @@ elseif(NOT XCODE_VERSION VERSION_LESS 8.0) set(CMAKE_Swift_LANGUAGE_VERSION 3.0) endif() +add_subdirectory(SubA) +add_subdirectory(SubB) + set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) add_executable(SwiftOnly main.swift) diff --git a/Tests/SwiftOnly/SubA/CMakeLists.txt b/Tests/SwiftOnly/SubA/CMakeLists.txt new file mode 100644 index 0000000..edebc16 --- /dev/null +++ b/Tests/SwiftOnly/SubA/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(SubA SubA.swift) +target_include_directories(SubA INTERFACE "$") diff --git a/Tests/SwiftOnly/SubA/SubA.swift b/Tests/SwiftOnly/SubA/SubA.swift new file mode 100644 index 0000000..e69de29 diff --git a/Tests/SwiftOnly/SubB/CMakeLists.txt b/Tests/SwiftOnly/SubB/CMakeLists.txt new file mode 100644 index 0000000..6e92927 --- /dev/null +++ b/Tests/SwiftOnly/SubB/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(SubB SubB.swift) +target_link_libraries(SubB PRIVATE SubA) diff --git a/Tests/SwiftOnly/SubB/SubB.swift b/Tests/SwiftOnly/SubB/SubB.swift new file mode 100644 index 0000000..d593c4c --- /dev/null +++ b/Tests/SwiftOnly/SubB/SubB.swift @@ -0,0 +1 @@ +import SubA -- cgit v0.12