Skip to content

Commit 2df8a18

Browse files
committed
[cmake] Add private build extension points
Adding vendor-specific extension points to the build system, giving vendors a place to put their internal settings and defaults, without having to modify the build directly. This helps reduce the chances of merge conflicts and public changes breaking internal settings. The location of the macros are set with `SwiftCore_PRIVATE_MODULE_DIR`, so vendors can keep their private extensions in a separate location if desired. Otherwise, it defaults to `cmake/modules/private`, which intentionally does not exist at this time. Currently, we have extensions for the default settings and global settings.
1 parent 148a910 commit 2df8a18

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
cmake_minimum_required(VERSION 3.26...3.29)
3333

34-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
34+
set(SwiftCore_CMAKE_MODULES_DIR "${CMAKE_SOURCE_DIR}/cmake/modules")
35+
list(APPEND CMAKE_MODULE_PATH ${SwiftCore_CMAKE_MODULES_DIR})
3536
include(CMakeWorkarounds)
3637
project(SwiftCore LANGUAGES C CXX Swift VERSION 6.1)
3738

@@ -47,6 +48,13 @@ set(SwiftCore_SWIFTC_SOURCE_DIR
4748
"${PROJECT_SOURCE_DIR}/../../"
4849
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
4950

51+
# Hook point for vendor-specific extensions to the build system
52+
# Allowed extension points:
53+
# - DefaultSettings.cmake
54+
# - Settings.cmake
55+
set(SwiftCore_VENDOR_MODULE_DIR "${SwiftCore_CMAKE_MODULES_DIR}/vendor"
56+
CACHE FILEPATH "Location for private build system extension")
57+
5058
include(GNUInstallDirs)
5159
include(AvailabilityMacros)
5260
include(CompilerSettings)
@@ -55,6 +63,8 @@ include(EmitSwiftInterface)
5563
include(PlatformInfo)
5664
include(gyb)
5765

66+
include("${SwiftCore_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL)
67+
5868
defaulted_option(SwiftCore_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries")
5969

6070
defaulted_option(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT "Enable Apple CrashReporter integration")

Runtimes/Core/cmake/modules/DefaultSettings.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ elseif(LINUX OR ANDROID OR BSD)
4343
elseif(WIN32)
4444
set(SwiftCore_OBJECT_FORMAT_default "coff")
4545
endif()
46+
47+
include("${SwiftCore_VENDOR_MODULE_DIR}/DefaultSettings.cmake" OPTIONAL)

0 commit comments

Comments
 (0)