From a65b57933c1c2a50c781f02031c58da324483a63 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Fri, 21 Jun 2024 13:26:47 -0700 Subject: [PATCH 1/2] Add plutil to CMake build --- CMakeLists.txt | 5 +++++ Sources/CMakeLists.txt | 3 +++ Sources/plutil/CMakeLists.txt | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 Sources/plutil/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 45faa45826..62b22af84d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) +# Optionally build tools (on by default) but only when building shared libraries +if(BUILD_SHARED_LIBS) + option(FOUNDATION_BUILD_TOOLS "build tools" ON) +endif() + set(CMAKE_POSITION_INDEPENDENT_CODE YES) # Fetchable dependcies diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 457edf4d2b..0ee266a4bc 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -18,3 +18,6 @@ add_subdirectory(_CFURLSessionInterface) add_subdirectory(Foundation) add_subdirectory(FoundationXML) add_subdirectory(FoundationNetworking) +if(FOUNDATION_BUILD_TOOLS) + add_subdirectory(plutil) +endif() diff --git a/Sources/plutil/CMakeLists.txt b/Sources/plutil/CMakeLists.txt new file mode 100644 index 0000000000..4a46fefac7 --- /dev/null +++ b/Sources/plutil/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable(plutil + main.swift) + +target_link_libraries(plutil PRIVATE + Foundation) + +target_link_options(plutil PRIVATE + "SHELL:-no-toolchain-stdlib-rpath") + +set_target_properties(plutil PROPERTIES + INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}") + +set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil) +install(TARGETS plutil + DESTINATION ${CMAKE_INSTALL_BINDIR}) \ No newline at end of file From 97442722cc9aa16a7d6961a86fc2d6e26a3493ad Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Fri, 21 Jun 2024 16:12:20 -0700 Subject: [PATCH 2/2] Address review comments --- Sources/plutil/CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sources/plutil/CMakeLists.txt b/Sources/plutil/CMakeLists.txt index 4a46fefac7..a6795e6894 100644 --- a/Sources/plutil/CMakeLists.txt +++ b/Sources/plutil/CMakeLists.txt @@ -1,3 +1,17 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.md for the list of Swift project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + add_executable(plutil main.swift) @@ -12,4 +26,4 @@ set_target_properties(plutil PROPERTIES set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil) install(TARGETS plutil - DESTINATION ${CMAKE_INSTALL_BINDIR}) \ No newline at end of file + DESTINATION ${CMAKE_INSTALL_BINDIR})