Skip to content

[CMake] Add plutil to CMake build #4987

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 2 commits into from
Jun 24, 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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ add_subdirectory(_CFURLSessionInterface)
add_subdirectory(Foundation)
add_subdirectory(FoundationXML)
add_subdirectory(FoundationNetworking)
if(FOUNDATION_BUILD_TOOLS)
add_subdirectory(plutil)
endif()
29 changes: 29 additions & 0 deletions Sources/plutil/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##===----------------------------------------------------------------------===##
##
## 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)

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})