From fdba32e63cd35112d911486651736311ca0128d0 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Mon, 18 Nov 2024 16:45:44 -0800 Subject: [PATCH] [cmake] Build with CMake on macOS * Add CXX as a language. This is required to link in the standard library on macOS, which is used by dependencies. * Set up rpath for the macOS binary. This is necessary to produce a working binary post-installation. --- CMakeLists.txt | 2 +- Sources/sourcekit-lsp/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e64d49017..4a37c0117 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16.1) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) project(SourceKit-LSP - LANGUAGES C Swift) + LANGUAGES C CXX Swift) set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) diff --git a/Sources/sourcekit-lsp/CMakeLists.txt b/Sources/sourcekit-lsp/CMakeLists.txt index e734e738a..cbd8ad3d4 100644 --- a/Sources/sourcekit-lsp/CMakeLists.txt +++ b/Sources/sourcekit-lsp/CMakeLists.txt @@ -18,5 +18,8 @@ target_compile_options(sourcekit-lsp PRIVATE target_link_libraries(sourcekit-lsp PRIVATE $<$>:FoundationXML>) +set_target_properties(sourcekit-lsp PROPERTIES + INSTALL_RPATH "$<$:@executable_path/../lib;@executable_path/../lib/swift/macosx;@executable_path/../lib/swift/host;@executable_path/../lib/swift/pm/llbuild>") + install(TARGETS sourcekit-lsp DESTINATION bin)