Skip to content

Commit

Permalink
[CMake] Export SwiftDriver so other CMake projects can link against it
Browse files Browse the repository at this point in the history
  • Loading branch information
DougGregor committed May 8, 2020
1 parent c97f302 commit af7726e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ find_package(Foundation QUIET)
find_package(Yams CONFIG REQUIRED)

add_subdirectory(Sources)
add_subdirectory(cmake/modules)
7 changes: 7 additions & 0 deletions Sources/SwiftDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ target_link_libraries(SwiftDriver PUBLIC
llbuildSwift
CYaml
Yams)

set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftDriver)

# NOTE: workaround for CMake not setting up include flags yet
set_target_properties(SwiftDriver PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

3 changes: 3 additions & 0 deletions Sources/SwiftOptions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ add_library(SwiftOptions
OptionParsing.swift
Options.swift
PrefixTrie.swift)

target_link_libraries(SwiftOptions PUBLIC
TSCBasic)

set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftOptions)

# NOTE: workaround for CMake not setting up include flags yet
set_target_properties(SwiftOptions PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
8 changes: 8 additions & 0 deletions cmake/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(SWIFTDRIVER_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/SwiftDriverExports.cmake)

configure_file(SwiftDriverConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SwiftDriverConfig.cmake)

get_property(SWIFTDRIVER_EXPORTS GLOBAL PROPERTY SWIFTDRIVER_EXPORTS)
export(TARGETS ${SWIFTDRIVER_EXPORTS}
FILE ${SWIFTDRIVER_EXPORTS_FILE})
3 changes: 3 additions & 0 deletions cmake/modules/SwiftDriverConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(NOT TARGET SwiftDriver)
include(@SWIFTDRIVER_EXPORTS_FILE@)
endif()

0 comments on commit af7726e

Please sign in to comment.