Skip to content

build: add the ability to build tools with CMake #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2024
Merged
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

project(SwiftDriver LANGUAGES C Swift)
project(SwiftDriver
LANGUAGES C CXX Swift)

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

option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
option(SWIFT_DRIVER_BUILD_TOOLS "Build makeOption" NO)

# Toolchain Vended Dependencies
find_package(dispatch QUIET)
Expand Down
4 changes: 4 additions & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ add_subdirectory(SwiftDriverExecution)
add_subdirectory(swift-build-sdk-interfaces)
add_subdirectory(swift-driver)
add_subdirectory(swift-help)

if(SWIFT_DRIVER_BUILD_TOOLS)
add_subdirectory(makeOptions)
endif()
23 changes: 23 additions & 0 deletions Sources/makeOptions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

find_package(LLVM CONFIG REQUIRED)
find_package(Clang CONFIG REQUIRED)
find_package(Swift CONFIG REQUIRED)

add_executable(makeOptions
main.cpp
makeOptions.cpp)
set_target_properties(makeOptions PROPERTIES
CXX_STANDARD 17)
target_compile_definitions(makeOptions PRIVATE
LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
target_include_directories(makeOptions PRIVATE
${SWIFT_INCLUDE_DIRS}
${LLVM_BUILD_BINARY_DIR}/include
${LLVM_BUILD_MAIN_INCLUDE_DIR})