-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathCMakeLists.txt
67 lines (52 loc) · 2.11 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Toolchain-only build products
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake/modules)
include(AddSwiftStdlib)
set(CXX_COMPILE_FLAGS)
set(CXX_LINK_FLAGS)
set(compile_flags
# Build the runtime with -Wall to catch, e.g., uninitialized variables
# warnings.
"-Wall"
# C++ code in the runtime and standard library should generally avoid
# introducing static constructors or destructors.
"-Wglobal-constructors"
"-Wexit-time-destructors"
# We don't want runtime C++ code to export symbols we didn't explicitly
# choose to.
"-fvisibility=hidden")
# Build the runtime with -Wall to catch, e.g., uninitialized variables
# warnings.
if(SWIFT_COMPILER_IS_MSVC_LIKE)
list(APPEND compile_flags "/W3")
else()
list(APPEND compile_flags "-Wall")
endif()
foreach(flag ${compile_flags})
check_cxx_compiler_flag("${flag}" is_supported)
if(is_supported)
list(APPEND CXX_COMPILE_FLAGS "${flag}")
endif()
endforeach()
unset(compile_flags)
if("Thread" IN_LIST SWIFT_RUNTIME_USE_SANITIZERS)
list(APPEND CXX_LINK_FLAGS "-fsanitize=thread")
endif()
# Do not enforce checks for LLVM's ABI-breaking build settings.
# The Swift runtime uses some header-only code from LLVM's ADT classes,
# but we do not want to link libSupport into the runtime. These checks rely
# on the presence of symbols in libSupport to identify how the code was
# built and cause link failures for mismatches. Without linking that library,
# we get link failures regardless, so instead, this just disables the checks.
if(CMAKE_VERSION VERSION_LESS 3.12)
append("-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
add_compile_definitions(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
endif()
# Compatibility libraries build in a special alternate universe that can't
# directly link to most OS runtime libraries, and have to access the
# runtime being patched only through public ABI.
list(APPEND CXX_COMPILE_FLAGS "-DSWIFT_COMPATIBILITY_LIBRARY=1")
add_subdirectory(legacy_layouts)
add_subdirectory(Compatibility50)
add_subdirectory(Compatibility51)
add_subdirectory(CompatibilityDynamicReplacements)