Skip to content

Commit 1181ecb

Browse files
authored
[CMake] Add plutil to CMake build (#4987)
* Add plutil to CMake build * Address review comments
1 parent 67eb5cb commit 1181ecb

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
4646
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
4747
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
4848

49+
# Optionally build tools (on by default) but only when building shared libraries
50+
if(BUILD_SHARED_LIBS)
51+
option(FOUNDATION_BUILD_TOOLS "build tools" ON)
52+
endif()
53+
4954
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
5055

5156
# Fetchable dependcies

Sources/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ add_subdirectory(_CFURLSessionInterface)
1818
add_subdirectory(Foundation)
1919
add_subdirectory(FoundationXML)
2020
add_subdirectory(FoundationNetworking)
21+
if(FOUNDATION_BUILD_TOOLS)
22+
add_subdirectory(plutil)
23+
endif()

Sources/plutil/CMakeLists.txt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
##===----------------------------------------------------------------------===##
2+
##
3+
## This source file is part of the Swift open source project
4+
##
5+
## Copyright (c) 2024 Apple Inc. and the Swift project authors
6+
## Licensed under Apache License v2.0
7+
##
8+
## See LICENSE.txt for license information
9+
## See CONTRIBUTORS.md for the list of Swift project authors
10+
##
11+
## SPDX-License-Identifier: Apache-2.0
12+
##
13+
##===----------------------------------------------------------------------===##
14+
15+
add_executable(plutil
16+
main.swift)
17+
18+
target_link_libraries(plutil PRIVATE
19+
Foundation)
20+
21+
target_link_options(plutil PRIVATE
22+
"SHELL:-no-toolchain-stdlib-rpath")
23+
24+
set_target_properties(plutil PROPERTIES
25+
INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}")
26+
27+
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil)
28+
install(TARGETS plutil
29+
DESTINATION ${CMAKE_INSTALL_BINDIR})

0 commit comments

Comments
 (0)