@@ -44,38 +44,32 @@ dispatch_common_warnings()
44
44
option (ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON )
45
45
set (USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR} )
46
46
47
+ # NOTE(abdulras) this is the CMake supported way to control whether we generate
48
+ # shared or static libraries. This impacts the behaviour of `add_library` in
49
+ # what type of library it generates.
50
+ option (BUILD_SHARED_LIBS "build shared libraries" ON )
51
+
47
52
option (ENABLE_SWIFT "enable libdispatch swift overlay" OFF )
48
53
if (ENABLE_SWIFT)
49
54
if (NOT CMAKE_SWIFT_COMPILER)
50
55
message (FATAL_ERROR "CMAKE_SWIFT_COMPILER must be defined to enable swift" )
51
56
endif ()
52
57
53
- get_filename_component (SWIFT_TOOLCHAIN ${CMAKE_SWIFT_COMPILER} DIRECTORY )
54
- get_filename_component (SWIFT_TOOLCHAIN ${SWIFT_TOOLCHAIN} DIRECTORY )
55
-
56
- string (TOLOWER ${CMAKE_SYSTEM_NAME} SWIFT_OS)
57
- get_swift_host_arch(SWIFT_HOST_ARCH)
58
+ find_package (Swift REQUIRED CONFIG)
58
59
59
- set (SWIFT_RUNTIME_LIBDIR ${SWIFT_TOOLCHAIN} /${SWIFT_LIBDIR} /swift/${SWIFT_OS} /${SWIFT_HOST_ARCH} )
60
-
61
- add_library (swiftCore
62
- SHARED IMPORTED GLOBAL )
63
- set_target_properties (swiftCore
64
- PROPERTIES
65
- IMPORTED_LOCATION
66
- ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftCore${CMAKE_SHARED_LIBRARY_SUFFIX} )
60
+ string (TOLOWER ${CMAKE_SYSTEM_NAME} swift_os)
61
+ get_swift_host_arch(swift_arch)
67
62
68
- add_library (swiftSwiftOnoneSupport
69
- SHARED IMPORTED GLOBAL )
70
- set_target_properties (swiftSwiftOnoneSupport
71
- PROPERTIES
72
- IMPORTED_LOCATION
73
- ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX} )
63
+ if (BUILD_SHARED_LIBS )
64
+ set (swift_dir swift)
65
+ else ()
66
+ set (swift_dir swift_static)
67
+ endif ()
74
68
75
- set (INSTALL_TARGET_DIR "${INSTALL_LIBDIR} /swift /${SWIFT_OS } " CACHE PATH "Path where the libraries will be installed" )
76
- set (INSTALL_DISPATCH_HEADERS_DIR "${INSTALL_LIBDIR} /swift /dispatch" CACHE PATH "Path where the headers will be installed for libdispatch" )
77
- set (INSTALL_BLOCK_HEADERS_DIR "${INSTALL_LIBDIR} /swift /Block" CACHE PATH "Path where the headers will be installed for the blocks runtime" )
78
- set (INSTALL_OS_HEADERS_DIR "${INSTALL_LIBDIR} /swift /os" CACHE PATH "Path where the os/ headers will be installed" )
69
+ set (INSTALL_TARGET_DIR "${INSTALL_LIBDIR} /${swift_dir} /${swift_os } " CACHE PATH "Path where the libraries will be installed" )
70
+ set (INSTALL_DISPATCH_HEADERS_DIR "${INSTALL_LIBDIR} /${swift_dir} /dispatch" CACHE PATH "Path where the headers will be installed for libdispatch" )
71
+ set (INSTALL_BLOCK_HEADERS_DIR "${INSTALL_LIBDIR} /${swift_dir} /Block" CACHE PATH "Path where the headers will be installed for the blocks runtime" )
72
+ set (INSTALL_OS_HEADERS_DIR "${INSTALL_LIBDIR} /${swift_dir} /os" CACHE PATH "Path where the os/ headers will be installed" )
79
73
endif ()
80
74
81
75
if (NOT ENABLE_SWIFT)
@@ -87,11 +81,6 @@ endif()
87
81
88
82
option (ENABLE_DTRACE "enable dtrace support" "" )
89
83
90
- # NOTE(abdulras) this is the CMake supported way to control whether we generate
91
- # shared or static libraries. This impacts the behaviour of `add_library` in
92
- # what type of library it generates.
93
- option (BUILD_SHARED_LIBS "build shared libraries" ON )
94
-
95
84
option (ENABLE_TESTING "build libdispatch tests" ON )
96
85
97
86
option (USE_LLD_LINKER "use the lld linker" FALSE )
0 commit comments