forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
96 lines (83 loc) · 3.52 KB
/
Copy pathCMakeLists.txt
File metadata and controls
96 lines (83 loc) · 3.52 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
cmake_minimum_required(VERSION 3.29)
if(POLICY CMP0157 AND CMAKE_Swift_COMPILER_USE_OLD_DRIVER)
cmake_policy(SET CMP0157 OLD)
endif()
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/../../cmake/modules")
include(SwiftProjectVersion)
project(SwiftBacktrace
LANGUAGES CXX Swift
VERSION ${SWIFT_RUNTIME_VERSION})
if(NOT PROJECT_IS_TOP_LEVEL)
message(SEND_ERROR "Swift Backtrace must build as a standalone project")
endif()
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR
"${PROJECT_SOURCE_DIR}/../../../"
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
find_package(SwiftCore REQUIRED)
find_package(SwiftOverlay REQUIRED)
find_package(SwiftCxxOverlay REQUIRED)
find_package(SwiftRuntime REQUIRED)
if(APPLE)
find_package(SwiftDarwin)
endif()
include(GNUInstallDirs)
include(ResourceEmbedding)
# NOTE: we disable availability checking because we need to use code from the
# RuntimeModule, but we also need to build with an availability version below
# that defined by Backtracing 6.2 (for now).
#
# We can't use the same trick that we use in the RuntimeModule or stdlib,
# because we're importing those modules, but because we build *with* them, we
# want to be able to use new things that are in them. We don't have a great
# solution to this, other than just turning off availability checking for this
# code.
add_compile_options(
"$<$<COMPILE_LANGUAGE:Swift>:-parse-as-library>"
"$<$<COMPILE_LANGUAGE:Swift>:-cxx-interoperability-mode=default>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-disable-upcoming-feature MemberImportVisibility>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-concurrency-module-import>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-cxx-module-import>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-string-processing-module-import>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-availability-checking>")
# LNK4049: symbol 'symbol' defined in 'filename.obj' is imported
# LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj'
# LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function'
#
# We cannot selectively filter the linker warnings as we do not use the MSVC
# frontend and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
# a compromise, treat all linker warnings as errors.
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
# Ensure all symbols are fully resolved on Linux
add_link_options($<$<PLATFORM_ID:Android,Linux>:LINKER:-z,defs>)
# Don't build on 32-bit Windows; it doesn't work there
if(WIN32 AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86)$")
message(FATAL_ERROR "Swift C-interop does not respect calling conventions on 32-bit")
endif()
add_executable(swift-backtrace
main.swift
AnsiColor.swift
JSON.swift
TargetMacOS.swift
TargetLinux.swift
TargetWindows.swift
Themes.swift
Timing.swift
Utils.swift)
set_target_properties(swift-backtrace PROPERTIES
Swift_MODULE_NAME swift_backtrace)
target_compile_options(swift-backtrace PRIVATE
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -I${${PROJECT_NAME}_SWIFTC_SOURCE_DIR}/include>")
target_link_libraries(swift-backtrace PRIVATE
swiftShims
swiftCore
swift_Builtin_float
swiftRuntime
swiftCxx
$<$<PLATFORM_ID:Darwin>:swiftDarwin>
$<$<PLATFORM_ID:Linux>:swiftGlibc>
$<$<PLATFORM_ID:Windows>:swiftCRT>
$<$<PLATFORM_ID:Windows>:swiftWinSDK>)
install(TARGETS swift-backtrace
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/swift")
embed_version_info(swift-backtrace)