Skip to content

Commit 412c92a

Browse files
committed
build: add the ability to build tools with CMake
Introduce the ability to build `makeOption` via CMake if desired. This requires passing additional parameters - `-D LLVM_DIR=... -D Clang_DIR=... -D Swift_DIR=...` to the CMake invocation to allow us to find the required include paths.
1 parent 00c486c commit 412c92a

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ if(POLICY CMP0091)
1616
cmake_policy(SET CMP0091 NEW)
1717
endif()
1818

19-
project(SwiftDriver LANGUAGES C Swift)
19+
project(SwiftDriver
20+
LANGUAGES C CXX Swift)
2021

2122
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2223
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
@@ -34,6 +35,7 @@ set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
3435
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-I$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/Sources/CSwiftScan/include>)
3536

3637
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
38+
option(SWIFT_DRIVER_BUILD_TOOLS "Build makeOption" NO)
3739

3840
# Toolchain Vended Dependencies
3941
find_package(dispatch QUIET)

Sources/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ add_subdirectory(SwiftDriverExecution)
1313
add_subdirectory(swift-build-sdk-interfaces)
1414
add_subdirectory(swift-driver)
1515
add_subdirectory(swift-help)
16+
17+
if(SWIFT_DRIVER_BUILD_TOOLS)
18+
add_subdirectory(makeOptions)
19+
endif()

Sources/makeOptions/CMakeLists.txt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
find_package(LLVM CONFIG REQUIRED)
10+
find_package(Clang CONFIG REQUIRED)
11+
find_package(Swift CONFIG REQUIRED)
12+
13+
add_executable(makeOptions
14+
main.cpp
15+
makeOptions.cpp)
16+
set_target_properties(makeOptions PROPERTIES
17+
CXX_STANDARD 17)
18+
target_compile_definitions(makeOptions PRIVATE
19+
LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
20+
target_include_directories(makeOptions PRIVATE
21+
${SWIFT_INCLUDE_DIRS}
22+
${LLVM_BUILD_BINARY_DIR}/include
23+
${LLVM_BUILD_MAIN_INCLUDE_DIR})

0 commit comments

Comments
 (0)