diff options
Diffstat (limited to 'Tests/SwiftOnly')
-rw-r--r-- | Tests/SwiftOnly/CMakeLists.txt | 28 | ||||
-rw-r--r-- | Tests/SwiftOnly/SubC/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/SwiftOnly/SubC/SubC.swift | 1 | ||||
-rw-r--r-- | Tests/SwiftOnly/SubD/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/SwiftOnly/SubD/SubD.swift | 1 | ||||
-rw-r--r-- | Tests/SwiftOnly/SubE/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/SwiftOnly/SubE/main.swift | 1 | ||||
-rw-r--r-- | Tests/SwiftOnly/SwiftPlugin/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/SwiftOnly/SwiftPlugin/main.swift | 3 | ||||
-rw-r--r-- | Tests/SwiftOnly/SwiftPlugin/plugin.swift | 2 |
10 files changed, 28 insertions, 15 deletions
diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt index c5a4b83..e933ea1 100644 --- a/Tests/SwiftOnly/CMakeLists.txt +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.5) if(POLICY CMP0126) cmake_policy(SET CMP0126 NEW) endif() @@ -28,6 +28,10 @@ endif() add_subdirectory(SubA) add_subdirectory(SubB) +add_subdirectory(SubC) +add_subdirectory(SubD) +add_subdirectory(SubE) + set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) add_executable(SwiftOnly main.swift) @@ -43,6 +47,17 @@ add_library(N N.swift) target_link_libraries(N PUBLIC M) +# FIXME(#25989): The Xcode generator doesn't respect CMAKE_Swift_MODULE_DIRECTORY. +if(NOT CMAKE_GENERATOR STREQUAL "Xcode") + add_custom_command(TARGET M + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E compare_files + "${CMAKE_Swift_MODULE_DIRECTORY}/M.swiftmodule" + "${CMAKE_Swift_MODULE_DIRECTORY}/M.swiftmodule" + COMMENT "check that .swiftmodule files are generated in CMAKE_Swift_MODULE_DIRECTORY" + VERBATIM) +endif() + if(NOT XCODE_VERSION OR XCODE_VERSION VERSION_GREATER_EQUAL 9.0) # TODO: Add a wholemodule object-library test once that is working add_library(O OBJECT O.swift L.swift) @@ -57,16 +72,7 @@ add_dependencies(P SwiftOnly) add_library(SwiftIface INTERFACE) target_link_libraries(SwiftOnly PRIVATE SwiftIface) -# @_alwaysEmitIntoClient ensures that the function body is inserted into the -# swiftmodule instead of as a symbol in the binary itself. I'm doing this to -# avoid having to link the executable. There are some flags required in order to -# link an executable into a library that I didn't see CMake emitting for Swift -# on macOS. AEIC is the easiest workaround that still tests this functionality. -# Unfortunately, AEIC was only added recently (~Swift 5.2), so we need to check -# that it is available before using it. -if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.2) - add_subdirectory("SwiftPlugin") -endif() +add_subdirectory("SwiftPlugin") function(test_cmp0157_default mode) if(POLICY CMP0157) diff --git a/Tests/SwiftOnly/SubC/CMakeLists.txt b/Tests/SwiftOnly/SubC/CMakeLists.txt new file mode 100644 index 0000000..4fdb3d3 --- /dev/null +++ b/Tests/SwiftOnly/SubC/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(SubC SubC.swift) +target_link_libraries(SubC PUBLIC SubD) diff --git a/Tests/SwiftOnly/SubC/SubC.swift b/Tests/SwiftOnly/SubC/SubC.swift new file mode 100644 index 0000000..1ca44f4 --- /dev/null +++ b/Tests/SwiftOnly/SubC/SubC.swift @@ -0,0 +1 @@ +import SubD diff --git a/Tests/SwiftOnly/SubD/CMakeLists.txt b/Tests/SwiftOnly/SubD/CMakeLists.txt new file mode 100644 index 0000000..01b38d3 --- /dev/null +++ b/Tests/SwiftOnly/SubD/CMakeLists.txt @@ -0,0 +1 @@ +add_library(SubD SubD.swift) diff --git a/Tests/SwiftOnly/SubD/SubD.swift b/Tests/SwiftOnly/SubD/SubD.swift new file mode 100644 index 0000000..857d3f4 --- /dev/null +++ b/Tests/SwiftOnly/SubD/SubD.swift @@ -0,0 +1 @@ +public let x = 42 diff --git a/Tests/SwiftOnly/SubE/CMakeLists.txt b/Tests/SwiftOnly/SubE/CMakeLists.txt new file mode 100644 index 0000000..099a81c --- /dev/null +++ b/Tests/SwiftOnly/SubE/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(SubE main.swift) +target_link_libraries(SubE PUBLIC SubD) diff --git a/Tests/SwiftOnly/SubE/main.swift b/Tests/SwiftOnly/SubE/main.swift new file mode 100644 index 0000000..1ca44f4 --- /dev/null +++ b/Tests/SwiftOnly/SubE/main.swift @@ -0,0 +1 @@ +import SubD diff --git a/Tests/SwiftOnly/SwiftPlugin/CMakeLists.txt b/Tests/SwiftOnly/SwiftPlugin/CMakeLists.txt index 4069f16..2bfbc8a 100644 --- a/Tests/SwiftOnly/SwiftPlugin/CMakeLists.txt +++ b/Tests/SwiftOnly/SwiftPlugin/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(main main.swift) set_target_properties(main PROPERTIES ENABLE_EXPORTS TRUE) -add_library(plugin plugin.swift) +add_library(plugin MODULE plugin.swift) target_link_libraries(plugin PRIVATE main) diff --git a/Tests/SwiftOnly/SwiftPlugin/main.swift b/Tests/SwiftOnly/SwiftPlugin/main.swift index f5aac51..caba1fb 100644 --- a/Tests/SwiftOnly/SwiftPlugin/main.swift +++ b/Tests/SwiftOnly/SwiftPlugin/main.swift @@ -1,4 +1,3 @@ -@_alwaysEmitIntoClient -public func exported() -> Int { 32 } +public func exported() -> Int { return 32 } print(exported()) diff --git a/Tests/SwiftOnly/SwiftPlugin/plugin.swift b/Tests/SwiftOnly/SwiftPlugin/plugin.swift index e84f248..d00ca33 100644 --- a/Tests/SwiftOnly/SwiftPlugin/plugin.swift +++ b/Tests/SwiftOnly/SwiftPlugin/plugin.swift @@ -1,3 +1,3 @@ import main -public func importing() -> Int { main.exported() + 1 } +public func importing() -> Int { return main.exported() + 1 } |