|
| 1 | +# Notes: |
| 2 | +# |
| 3 | +# The Demangling library uses `#if SWIFT_HAVE_CRASHREPORTERCLIENT` while the |
| 4 | +# runtime library uses `#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT` to toggle that |
| 5 | +# functionality. When building the demangling library, the macro should be set |
| 6 | +# to 0 or 1 to indicate the presence of the crashreporter. |
| 7 | +# When building the runtime library, the existence of the macro indicates the |
| 8 | +# presence of the crashreporter. |
| 9 | +# |
| 10 | +# Runtime library pulls sources and headers from compiler sources (ThreadSanitizer) |
| 11 | +# Demangling library pulls sources and headers from compiler sources (all) |
| 12 | +# |
| 13 | +# |
| 14 | +# gyb pulls sources from compiler sources |
| 15 | +# |
| 16 | +# Stubs: |
| 17 | +# Pulls in headers from compiler |
| 18 | +# - include/swift/Basic |
| 19 | +# - include/swift/Runtime |
| 20 | +# - include/swift/Threading |
| 21 | + |
| 22 | +# TODO: |
| 23 | +# Platform support: |
| 24 | +# - Work on/Verify cross-compiling |
| 25 | +# - Work on/Verify Windows and Linux native builds |
| 26 | +# Embedded |
| 27 | +# -- -Xfrontend -emit-empty-object-file |
| 28 | +# Catalyst Support |
| 29 | +# -- Will need shadow invocations to generate swiftmodules for Swift parts |
| 30 | +# Install *.abi.json, swiftdoc, and swiftsourceinfo |
| 31 | + |
| 32 | +cmake_minimum_required(VERSION 3.26...3.29) |
| 33 | + |
| 34 | +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") |
| 35 | +include(CMakeWorkarounds) |
| 36 | +project(SwiftCore LANGUAGES C CXX Swift VERSION 6.1) |
| 37 | + |
| 38 | +# The Swift standard library is not intended for use as a sub-library as part of |
| 39 | +# another project. It is tightly coupled with the compiler version. |
| 40 | +if(NOT PROJECT_IS_TOP_LEVEL) |
| 41 | + message(FATAL_ERROR "Swift Core must build as a standalone project") |
| 42 | +endif() |
| 43 | + |
| 44 | +# FIXME: We should not need to refer back into the compiler sources. This is |
| 45 | +# needed by gyb, Demangling, Threading, the runtime (ThreadSanitizer.cpp) |
| 46 | +set(SwiftCore_SWIFTC_SOURCE_DIR |
| 47 | + "${PROJECT_SOURCE_DIR}/../../" |
| 48 | + CACHE FILEPATH "Path to the root source directory of the Swift compiler") |
| 49 | + |
| 50 | +include(GNUInstallDirs) |
| 51 | +include(AvailabilityMacros) |
| 52 | +include(CompilerSettings) |
| 53 | +include(DefaultSettings) |
| 54 | +include(EmitSwiftInterface) |
| 55 | +include(PlatformInfo) |
| 56 | +include(gyb) |
| 57 | + |
| 58 | +defaulted_option(SwiftCore_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries") |
| 59 | + |
| 60 | +defaulted_option(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT "Enable Apple CrashReporter integration") |
| 61 | +defaulted_option(SwiftCore_ENABLE_OBJC_INTEROP "Enable runtime ObjC interop") |
| 62 | +defaulted_option(SwiftCore_ENABLE_TYPE_PRINTING "Enable printing type names") |
| 63 | +defaulted_option(SwiftCore_ENABLE_VECTOR_TYPES "Enable vector support") |
| 64 | +defaulted_option(SwiftCore_ENABLE_REFLECTION "Enable runtime support for mirrors and reflection support") |
| 65 | +defaulted_option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support") |
| 66 | + |
| 67 | +defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime support") |
| 68 | +set(SwiftCore_BACKTRACER_PATH ${SwiftCore_BACKTRACER_PATH_default} CACHE STRING "Set a fixed path to the Swift backtracer") |
| 69 | + |
| 70 | +option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF) |
| 71 | +option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF) |
| 72 | + |
| 73 | +set(SwiftCore_OBJECT_FORMAT "${SwiftCore_OBJECT_FORMAT_default}" CACHE STRING "Object format") |
| 74 | + |
| 75 | +add_compile_definitions( |
| 76 | + $<$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>:-DSWIFT_OBJC_INTEROP> |
| 77 | + $<$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>:-DSWIFT_LIBRARY_EVOLUTION> |
| 78 | + $<$<BOOL:${SwiftCore_ENABLE_CRASH_REPORTER_CLIENT}>:-DSWIFT_HAVE_CRASHREPORTERCLIENT> |
| 79 | + $<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION> |
| 80 | + $<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>> |
| 81 | + $<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>>) |
| 82 | + |
| 83 | +add_compile_options( $<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>>:-enable-library-evolution>) |
| 84 | + |
| 85 | +include_directories(include) |
| 86 | + |
| 87 | +add_subdirectory(LLVMSupport) |
| 88 | +add_subdirectory(SwiftShims/swift/shims) |
| 89 | +add_subdirectory(Demangling) |
| 90 | +add_subdirectory(Threading) |
| 91 | +add_subdirectory(runtime) |
| 92 | +add_subdirectory(stubs) |
| 93 | +add_subdirectory(core) |
0 commit comments