Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / SwiftOnly / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.3)
2 if(POLICY CMP0126)
3   cmake_policy(SET CMP0126 NEW)
4 endif()
5
6 # NOTE: Force the Release mode configuration as there are some issues with the
7 # debug information handling on macOS on certain Xcode builds.
8 if(NOT CMAKE_CONFIGURATION_TYPES)
9   set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" FORCE)
10 endif()
11
12 # NOTE: enable shared libraries by default.  Older Xcode releases do not play
13 # well with static libraries, and Windows does not currently support static
14 # libraries in Swift.
15 set(BUILD_SHARED_LIBS YES)
16
17 project(SwiftOnly Swift)
18
19 if(NOT XCODE_VERSION VERSION_LESS 10.2)
20   set(CMAKE_Swift_LANGUAGE_VERSION 5.0)
21 elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
22   set(CMAKE_Swift_LANGUAGE_VERSION 3.0)
23 endif()
24
25 add_subdirectory(SubA)
26 add_subdirectory(SubB)
27
28 set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
29
30 add_executable(SwiftOnly main.swift)
31 target_compile_definitions(SwiftOnly PRIVATE SWIFTONLY)
32
33 add_library(L L.swift)
34
35 add_library(M M.swift)
36 target_link_libraries(M PUBLIC
37   L)
38
39 add_library(N N.swift)
40 target_link_libraries(N PUBLIC
41   M)
42
43 # Dummy to make sure generation works with such targets.
44 add_library(SwiftIface INTERFACE)
45 target_link_libraries(SwiftOnly PRIVATE SwiftIface)