Skip to content

Commit 1899e01

Browse files
committed
build: explicitly link against dispatch and Foundation
On platforms where Foundation is not provided by the system and you wish to build against a custom build of Foundation, you need a number of flags. This allows you to instead opt for passing `-DFoundation_DIR=` and `-Ddispatch_DIR=` to CMake when configuring to pick up those paths.
1 parent d3892d5 commit 1899e01

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

TSC/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
cmake_minimum_required(VERSION 3.15.1)
22

33
project(SwiftTSC LANGUAGES C Swift)
4-
4+
55
set(SWIFT_VERSION 5)
66
set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION})
77
if(CMAKE_VERSION VERSION_LESS 3.16)
88
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-swift-version$<SEMICOLON>${SWIFT_VERSION}>)
99
endif()
1010

1111
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
12-
12+
1313
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1414
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1515
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1616

1717
option(BUILD_SHARED_LIBS "Build shared libraryes by default" YES)
1818

19+
find_package(dispatch QUIET)
20+
find_package(Foundation QUIET)
21+
1922
add_subdirectory(Sources)
2023
add_subdirectory(cmake/modules)

TSC/Sources/TSCBasic/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ add_library(TSCBasic
5151
Tuple.swift)
5252
target_link_libraries(TSCBasic PUBLIC
5353
TSCLibc)
54+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
55+
target_link_libraries(TSCBasic PUBLIC
56+
Foundation)
57+
endif()
5458
# NOTE(compnerd) workaround for CMake not setting up include flags yet
5559
set_target_properties(TSCBasic PROPERTIES
5660
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

0 commit comments

Comments
 (0)