@@ -12,6 +12,18 @@ cmake_minimum_required(VERSION 3.26...3.29)
1212project (SwiftBuild
1313 LANGUAGES C CXX Swift)
1414
15+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
16+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
17+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin)
18+
19+ set (CMAKE_INSTALL_RPATH "$<IF:$<PLATFORM_ID:Darwin>,@loader_path/..,$ORIGIN>" )
20+ set (CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH YES )
21+
22+ set (CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
23+ set (CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} /swift)
24+
25+ option (BUILD_SHARED_LIBS "Build shared libraries by default" YES )
26+
1527set (CMAKE_C_VISIBILITY hidden)
1628set (CMAKE_CXX_VISIBILITY hidden)
1729set (CMAKE_CXX_STANDARD 17)
@@ -35,7 +47,33 @@ add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-package-name SwiftBuild>
3547 # rdar://137809703
3648 # "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature RegionBasedIsolation>"
3749 "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ExistentialAny>"
38- "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>" )
50+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>"
51+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-no-toolchain-stdlib-rpath>"
52+ # Turn off autolinking within this project to reduce linker overhead.
53+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBLibc>"
54+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBAndroidPlatform>"
55+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBApplePlatform>"
56+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBBuildService>"
57+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCLibc>"
58+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBGenericUnixPlatform>"
59+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBTaskConstruction>"
60+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBUtil>"
61+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBUniversalPlatform>"
62+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBWindowsPlatform>"
63+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SwiftBuild>"
64+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBWebAssemblyPlatform>"
65+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCSupport>"
66+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBMacro>"
67+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBProjectModel>"
68+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBTaskExecution>"
69+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBServiceCore>"
70+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBQNXPlatform>"
71+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBProtocol>"
72+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBLLBuild>"
73+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCore>"
74+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCAS>"
75+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBBuildSystem>"
76+ "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCore>" )
3977
4078# Prefer the static initialization for the plugins.
4179add_compile_definitions (USE_STATIC_PLUGIN_INITIALIZATION)
@@ -50,3 +88,4 @@ find_package(Threads)
5088find_package (SQLite3)
5189
5290add_subdirectory (Sources )
91+ add_subdirectory (cmake/modules)
0 commit comments