forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
159 lines (141 loc) · 6.99 KB
/
CMakeLists.txt
File metadata and controls
159 lines (141 loc) · 6.99 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -----------------------------------------------------------------------------
# Determine CMake version and build type.
# -----------------------------------------------------------------------------
# NOTE: cmake_minimum_required() and project() *MUST* be the two first commands
# used, see https://cmake.org/cmake/help/v3.3/command/project.html -- the
# latter in particular handles loading a bunch of shared CMake definitions
# and loading the cross-compilation settings from CMAKE_TOOLCHAIN_FILE.
cmake_minimum_required(VERSION 3.20)
if (PORT STREQUAL "IOS")
set(CMAKE_SYSTEM_NAME iOS)
if (NOT CMAKE_OSX_SYSROOT)
if (DEFINED ENV{SDKROOT} AND EXISTS "$ENV{SDKROOT}")
set(CMAKE_OSX_SYSROOT "$ENV{SDKROOT}" CACHE PATH "iOS SDK path" FORCE)
else ()
if (CMAKE_IOS_SIMULATOR)
set(_sdk_name "iphonesimulator.internal")
set(_sdk_name_fallback "iphonesimulator")
else ()
set(_sdk_name "iphoneos.internal")
set(_sdk_name_fallback "iphoneos")
endif ()
execute_process(COMMAND xcrun --sdk ${_sdk_name} --show-sdk-path
OUTPUT_VARIABLE _ios_sysroot
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _internal_sdk_result
ERROR_QUIET)
if (NOT _internal_sdk_result EQUAL 0 OR NOT _ios_sysroot)
execute_process(COMMAND xcrun --sdk ${_sdk_name_fallback} --show-sdk-path
OUTPUT_VARIABLE _ios_sysroot
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif ()
if (_ios_sysroot)
set(CMAKE_OSX_SYSROOT "${_ios_sysroot}" CACHE PATH "iOS SDK path" FORCE)
endif ()
endif ()
endif ()
if (NOT CMAKE_OSX_ARCHITECTURES)
if (CMAKE_OSX_SYSROOT MATCHES "\\.Internal\\.sdk$" AND NOT CMAKE_OSX_SYSROOT MATCHES "[Ss]imulator")
execute_process(COMMAND uname -m
OUTPUT_VARIABLE _host_arch
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (_host_arch STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64e" CACHE STRING "Target architecture" FORCE)
message(STATUS "iOS: arm64e enabled (internal device SDK detected)")
endif ()
else ()
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Target architecture" FORCE)
endif ()
endif ()
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "18.0" CACHE STRING "Minimum iOS version" FORCE)
endif ()
if (NOT CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR "aarch64" CACHE STRING "Target processor" FORCE)
endif ()
endif ()
project(WebKit LANGUAGES C CXX)
# -----------------------------------------------------------------------------
# Common configuration
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
include(WebKitCommon)
# -----------------------------------------------------------------------------
# Enable Swift - we can't do this until we've checked our configuration,
# which in turn depends on clang-related variables set by the initial
# "project()" line
#------------------------------------------------------------------------------
if (SWIFT_REQUIRED)
cmake_policy(SET CMP0157 NEW)
# CMake omits -target for swiftc during iOS cross-compilation.
if (PORT STREQUAL "IOS" AND NOT CMAKE_Swift_COMPILER_TARGET)
if (CMAKE_OSX_SYSROOT MATCHES "[Ss]imulator")
set(CMAKE_Swift_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-ios${CMAKE_OSX_DEPLOYMENT_TARGET}-simulator" CACHE STRING "Swift target triple" FORCE)
else ()
set(CMAKE_Swift_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-ios${CMAKE_OSX_DEPLOYMENT_TARGET}" CACHE STRING "Swift target triple" FORCE)
endif ()
endif ()
if (PORT STREQUAL "IOS")
execute_process(COMMAND xcrun --show-sdk-platform-path
OUTPUT_VARIABLE _ios_platform_path
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (_ios_platform_path)
execute_process(COMMAND find "${_ios_platform_path}" -name swiftc -path "*/xctoolchain/*" -type f -print -quit
OUTPUT_VARIABLE _ios_swiftc
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (_ios_swiftc AND NOT _ios_swiftc STREQUAL CMAKE_Swift_COMPILER)
set(CMAKE_Swift_COMPILER "${_ios_swiftc}" CACHE FILEPATH "Swift compiler" FORCE)
message(STATUS "iOS: using platform-specific Swift compiler: ${_ios_swiftc}")
endif ()
endif ()
endif ()
enable_language(Swift)
# -F causes Swift to find C++23 framework headers in implicit module builds.
if (PORT STREQUAL "IOS")
set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-Xcc -iquote")
endif ()
# Override Swift compiler to a wrapper script to work around the
# fact pkg-config feeds CFLAGS even to swiftc.
# Guard against cache poisoning: if CMAKE_Swift_COMPILER already IS the
# wrapper (from a previous configure), find the real compiler via 'which'.
set(_swift_wrapper "${CMAKE_SOURCE_DIR}/Tools/Scripts/swift/swiftc-wrapper.sh")
if (CMAKE_Swift_COMPILER STREQUAL _swift_wrapper)
execute_process(COMMAND which swiftc RESULT_VARIABLE _which_retcode OUTPUT_VARIABLE _real_swiftc OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT _which_retcode EQUAL 0)
message(FATAL_ERROR "swiftc not found in PATH")
endif ()
else ()
set(_real_swiftc "${CMAKE_Swift_COMPILER}")
endif ()
set(ORIGINAL_Swift_COMPILER "${_real_swiftc}" CACHE FILEPATH "Original Swift compiler" FORCE)
set(CMAKE_Swift_COMPILER "${_swift_wrapper}" CACHE FILEPATH "Swift compiler wrapper" FORCE)
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:--original-swift-compiler=${ORIGINAL_Swift_COMPILER}>)
unset(_swift_wrapper)
unset(_real_swiftc)
endif ()
# -----------------------------------------------------------------------------
# Enable API unit tests and create a target for the test runner
# -----------------------------------------------------------------------------
if (ENABLE_API_TESTS)
enable_testing()
endif ()
# -----------------------------------------------------------------------------
# Add module directories
# -----------------------------------------------------------------------------
add_subdirectory(Source)
# -----------------------------------------------------------------------------
# Add tools
# -----------------------------------------------------------------------------
if (ENABLE_TOOLS)
add_subdirectory(Tools)
endif ()
if (DEVELOPER_MODE)
add_subdirectory(PerformanceTests)
endif ()
# -----------------------------------------------------------------------------
# Print the features list last, for maximum visibility.
# -----------------------------------------------------------------------------
PRINT_WEBKIT_OPTIONS()