summaryrefslogtreecommitdiffstats
path: root/Tests/SwiftOnly/CMakeLists.txt
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2020-02-04 05:32:51 (GMT)
committerBrad King <brad.king@kitware.com>2020-03-12 15:50:43 (GMT)
commit2026915f8f08413a04e2612483eec28d844102d7 (patch)
tree3dfb7367e7e6c70fb15092472f3a9b7083c53806 /Tests/SwiftOnly/CMakeLists.txt
parentcb8227ecbf8907c793d9e34a7aa77cbaa47c1bd8 (diff)
downloadCMake-2026915f8f08413a04e2612483eec28d844102d7.zip
CMake-2026915f8f08413a04e2612483eec28d844102d7.tar.gz
CMake-2026915f8f08413a04e2612483eec28d844102d7.tar.bz2
Swift: Propagate Swift_MODULE_DIRECTORY as include directory
Teach include directory computation for Swift to implicitly propagate the `Swift_MODULE_DIRECTORY` of all linked targets as include directories. This is required to ensure that the swiftmodule of a linked target is accessible to the compiler of the current target. Fixes: #19272
Diffstat (limited to 'Tests/SwiftOnly/CMakeLists.txt')
-rw-r--r--Tests/SwiftOnly/CMakeLists.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt
index f4cbac2..e24279b 100644
--- a/Tests/SwiftOnly/CMakeLists.txt
+++ b/Tests/SwiftOnly/CMakeLists.txt
@@ -1,4 +1,16 @@
cmake_minimum_required(VERSION 3.3)
+
+# NOTE: Force the Release mode configuration as there are some issues with the
+# debug information handling on macOS on certain Xcode builds.
+if(NOT CMAKE_CONFIGURATION_TYPES)
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" FORCE)
+endif()
+
+# NOTE: enable shared libraries by default. Older Xcode releases do not play
+# well with static libraries, and Windows does not currently support static
+# libraries in Swift.
+set(BUILD_SHARED_LIBS YES)
+
project(SwiftOnly Swift)
if(NOT XCODE_VERSION VERSION_LESS 10.2)
@@ -7,7 +19,19 @@ elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
set(CMAKE_Swift_LANGUAGE_VERSION 3.0)
endif()
+set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
+
add_executable(SwiftOnly main.swift)
+add_library(L L.swift)
+
+add_library(M M.swift)
+target_link_libraries(M PUBLIC
+ L)
+
+add_library(N N.swift)
+target_link_libraries(N PUBLIC
+ M)
+
# Dummy to make sure generation works with such targets.
add_library(SwiftIface INTERFACE)