Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
cmake_minimum_required(VERSION 3.15.1)
if(POLICY CMP0028)
cmake_policy(SET CMP0028 NEW)
endif()

project(SwiftTSC LANGUAGES C Swift)
cmake_minimum_required(VERSION 3.19)

set(SWIFT_VERSION 5)
set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION})
if(CMAKE_VERSION VERSION_LESS 3.16)
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-swift-version$<SEMICOLON>${SWIFT_VERSION}>)
# Workaround for CMake 3.15 which doesn't link libraries properly on Windows
set(CMAKE_LINK_LIBRARY_FLAG "-l")
endif()
project(SwiftTSC LANGUAGES C Swift)

set(CMAKE_Swift_LANGUAGE_VERSION 5)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

if(CMAKE_VERSION VERSION_LESS 3.16 AND CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_DISABLE_IN_SOURCE_BUILD YES)

option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)

# Toolchain bundled libraries
find_package(dispatch QUIET)
find_package(Foundation QUIET)

# System Packages
find_package(Threads QUIET)
find_package(SwiftSystem CONFIG REQUIRED)

# Package Dependencies
find_package(SwiftSystem CONFIG)
if(NOT SwiftSystem_FOUND)
include(FetchContent)
message("-- Vendoring SwiftSystem")
FetchContent_Declare(SwiftSystem
GIT_REPOSITORY https://github.com/apple/swift-system
GIT_TAG 1.1.1)
FetchContent_MakeAvailable(SwiftSystem)
endif()

add_subdirectory(Sources)
add_subdirectory(cmake/modules)
4 changes: 4 additions & 0 deletions Sources/TSCBasic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

if(NOT SwiftSystem_FOUND)
add_library(SwiftSystem::SystemPackage ALIAS SystemPackage)
endif()

add_library(TSCBasic
Await.swift
ByteString.swift
Expand Down