Revision control

1
# -----------------------------------------------------------------------------
2
# Determine CMake version and build type.
3
# -----------------------------------------------------------------------------
4
#
5
# NOTE: cmake_minimum_required() and project() *MUST* be the two first commands
7
# latter in particular handles loading a bunch of shared CMake definitions
8
# and loading the cross-compilation settings from CMAKE_TOOLCHAIN_FILE.
9
#
10
11
cmake_minimum_required(VERSION 3.10)
12
13
project(WebKit)
14
15
if (NOT CMAKE_BUILD_TYPE)
16
message(WARNING "No CMAKE_BUILD_TYPE value specified, defaulting to RelWithDebInfo.")
17
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
18
else ()
19
message(STATUS "The CMake build type is: ${CMAKE_BUILD_TYPE}")
20
endif ()
21
22
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
23
24
set(ENABLE_WEBCORE ON)
25
26
if (NOT DEFINED ENABLE_WEBKIT)
27
set(ENABLE_WEBKIT ON)
28
endif ()
29
30
if (NOT DEFINED ENABLE_TOOLS AND EXISTS "${CMAKE_SOURCE_DIR}/Tools")
31
set(ENABLE_TOOLS ON)
32
endif ()
33
34
if (NOT DEFINED ENABLE_WEBINSPECTORUI)
35
set(ENABLE_WEBINSPECTORUI ON)
36
endif ()
37
38
# -----------------------------------------------------------------------------
39
# Determine which port will be built
40
# -----------------------------------------------------------------------------
41
set(ALL_PORTS
42
AppleWin
43
Efl
44
FTW
45
GTK
46
JSCOnly
47
Mac
48
PlayStation
49
WPE
50
WinCairo
51
)
52
set(PORT "NOPORT" CACHE STRING "choose which WebKit port to build (one of ${ALL_PORTS})")
53
54
list(FIND ALL_PORTS ${PORT} RET)
55
if (${RET} EQUAL -1)
56
message(FATAL_ERROR "Please choose which WebKit port to build (one of ${ALL_PORTS})")
57
endif ()
58
59
string(TOLOWER ${PORT} WEBKIT_PORT_DIR)
60
61
# -----------------------------------------------------------------------------
62
# Determine the compiler
63
# -----------------------------------------------------------------------------
64
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
65
set(COMPILER_IS_CLANG ON)
66
endif ()
67
68
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
69
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "7.3.0")
70
message(FATAL_ERROR "GCC 7.3 or newer is required to build WebKit. Use a newer GCC version or Clang.")
71
endif ()
72
endif ()
73
74
if (CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
75
set(COMPILER_IS_GCC_OR_CLANG ON)
76
endif ()
77
78
if (MSVC AND COMPILER_IS_CLANG)
79
set(COMPILER_IS_CLANG_CL ON)
80
endif ()
81
82
# -----------------------------------------------------------------------------
83
# Determine the target processor
84
# -----------------------------------------------------------------------------
85
# Use MSVC_CXX_ARCHITECTURE_ID instead of CMAKE_SYSTEM_PROCESSOR when defined,
86
# since the later one just resolves to the host processor on Windows.
87
if (MSVC_CXX_ARCHITECTURE_ID)
88
string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
89
else ()
90
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR)
91
endif ()
92
if (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64|^arm64)")
93
set(WTF_CPU_ARM64 1)
94
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
95
set(WTF_CPU_ARM 1)
96
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64")
97
set(WTF_CPU_MIPS64 1)
98
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
99
set(WTF_CPU_MIPS 1)
100
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(x64|x86_64|amd64)")
101
# FORCE_32BIT is set in the build script when --32-bit is passed
102
# on a Linux/intel 64bit host. This allows us to produce 32bit
103
# binaries without setting the build up as a crosscompilation,
104
# which is the only way to modify CMAKE_SYSTEM_PROCESSOR.
105
if (FORCE_32BIT)
106
set(WTF_CPU_X86 1)
107
else ()
108
set(WTF_CPU_X86_64 1)
109
endif ()
110
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86)")
111
set(WTF_CPU_X86 1)
112
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
113
set(WTF_CPU_PPC 1)
114
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
115
set(WTF_CPU_PPC64 1)
116
elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
117
set(WTF_CPU_PPC64LE 1)
118
else ()
119
set(WTF_CPU_UNKNOWN 1)
120
endif ()
121
122
# -----------------------------------------------------------------------------
123
# Determine the operating system
124
# -----------------------------------------------------------------------------
125
if (UNIX)
126
if (APPLE)
127
set(WTF_OS_MAC_OS_X 1)
128
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
129
set(WTF_OS_LINUX 1)
130
else ()
131
set(WTF_OS_UNIX 1)
132
endif ()
133
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
134
set(WTF_OS_WINDOWS 1)
135
elseif (CMAKE_SYSTEM_NAME MATCHES "Fuchsia")
136
set(WTF_OS_FUCHSIA 1)
137
else ()
138
message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'")
139
endif ()
140
141
# -----------------------------------------------------------------------------
142
# Default library types
143
# -----------------------------------------------------------------------------
144
# By default, only the highest-level libraries, WebKitLegacy and WebKit, are
145
# shared, because properly building shared libraries that depend on each other
146
# can be tricky. Override these in Options*.cmake for your port as needed.
147
set(bmalloc_LIBRARY_TYPE STATIC)
148
set(WTF_LIBRARY_TYPE STATIC)
149
set(JavaScriptCore_LIBRARY_TYPE STATIC)
150
set(PAL_LIBRARY_TYPE STATIC)
151
set(WebCore_LIBRARY_TYPE STATIC)
152
set(WebKitLegacy_LIBRARY_TYPE SHARED)
153
set(WebKit_LIBRARY_TYPE SHARED)
154
set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
155
156
set(CMAKE_POSITION_INDEPENDENT_CODE True)
157
158
# -----------------------------------------------------------------------------
159
# Install JavaScript shell
160
# -----------------------------------------------------------------------------
161
option(SHOULD_INSTALL_JS_SHELL "generate an installation rule to install the built JavaScript shell")
162
163
# -----------------------------------------------------------------------------
164
# Default output directories, which can be overwritten by ports
165
#------------------------------------------------------------------------------
166
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
167
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
168
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
169
170
# -----------------------------------------------------------------------------
171
# Common configuration
172
#------------------------------------------------------------------------------
173
include(WebKitCommon)
174
175
# -----------------------------------------------------------------------------
176
# Enable API unit tests and create a target for the test runner
177
# -----------------------------------------------------------------------------
178
if (ENABLE_API_TESTS)
179
enable_testing()
180
endif ()
181
182
# -----------------------------------------------------------------------------
183
# Add module directories
184
# -----------------------------------------------------------------------------
185
add_subdirectory(Source)
186
187
# -----------------------------------------------------------------------------
188
# Add tools
189
# -----------------------------------------------------------------------------
190
if (ENABLE_TOOLS)
191
add_subdirectory(Tools)
192
endif ()
193
194
if (DEVELOPER_MODE)
195
add_subdirectory(PerformanceTests)
196
endif ()
197
198
# -----------------------------------------------------------------------------
199
# Print the features list last, for maximum visibility.
200
# -----------------------------------------------------------------------------
201
PRINT_WEBKIT_OPTIONS()