Skip to content

Commit af7726e

Browse files
committed
[CMake] Export SwiftDriver so other CMake projects can link against it
1 parent c97f302 commit af7726e

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ find_package(Foundation QUIET)
4444
find_package(Yams CONFIG REQUIRED)
4545

4646
add_subdirectory(Sources)
47+
add_subdirectory(cmake/modules)

Sources/SwiftDriver/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,10 @@ target_link_libraries(SwiftDriver PUBLIC
6868
llbuildSwift
6969
CYaml
7070
Yams)
71+
72+
set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftDriver)
73+
74+
# NOTE: workaround for CMake not setting up include flags yet
75+
set_target_properties(SwiftDriver PROPERTIES
76+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
77+

Sources/SwiftOptions/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ add_library(SwiftOptions
1515
OptionParsing.swift
1616
Options.swift
1717
PrefixTrie.swift)
18+
1819
target_link_libraries(SwiftOptions PUBLIC
1920
TSCBasic)
2021

22+
set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftOptions)
23+
2124
# NOTE: workaround for CMake not setting up include flags yet
2225
set_target_properties(SwiftOptions PROPERTIES
2326
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

cmake/modules/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(SWIFTDRIVER_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/SwiftDriverExports.cmake)
2+
3+
configure_file(SwiftDriverConfig.cmake.in
4+
${CMAKE_CURRENT_BINARY_DIR}/SwiftDriverConfig.cmake)
5+
6+
get_property(SWIFTDRIVER_EXPORTS GLOBAL PROPERTY SWIFTDRIVER_EXPORTS)
7+
export(TARGETS ${SWIFTDRIVER_EXPORTS}
8+
FILE ${SWIFTDRIVER_EXPORTS_FILE})
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if(NOT TARGET SwiftDriver)
2+
include(@SWIFTDRIVER_EXPORTS_FILE@)
3+
endif()

0 commit comments

Comments
 (0)