-
Notifications
You must be signed in to change notification settings - Fork 147
/
CMakeLists.txt
318 lines (276 loc) · 10.1 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
# OVERVIEW
#
# CMake is a cross-platform open-source build system that can generate project
# files in many different formats. It can be downloaded from
# http://www.cmake.org or installed via a platform package manager.
#
# CMake-generated project formats that have been tested with JCEF include:
#
# Linux: Ninja, GCC 7.5.0+, Unix Makefiles
# MacOS: Ninja, Xcode 12.2 to 13.0
# Windows: Ninja, Visual Studio 2019+
#
# Ninja is a cross-platform open-source tool for running fast builds using
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
# downloaded from http://martine.github.io/ninja/ or installed via a platform
# package manager.
#
# BUILD REQUIREMENTS
#
# The below requirements must be met to build JCEF.
#
# - CMake version 3.19 or newer.
#
# - Linux requirements:
# Currently supported distributions include Debian 10 (Buster), Ubuntu 18
# (Bionic Beaver), and related. Ubuntu 18.04 64-bit with GCC 7.5.0+ is
# recommended. Newer versions will likely also work but may not have been
# tested.
# Required packages include:
# build-essential
# libgtk3.0-dev (required by the cefclient target only)
#
# - MacOS requirements:
# Xcode 12.2 to 13.0 building on MacOS 10.15.4 (Catalina) or newer. Only
# 64-bit builds are supported. The Xcode command-line tools must also be
# installed. Newer Xcode versions may not have been been tested and are not
# recommended.
#
# - Windows requirements:
# Visual Studio 2019 or newer building on Windows 7 or newer. Windows 10
# 64-bit is recommended. Newer versions will likely also work but may not have
# been tested.
#
# BUILD EXAMPLES
#
# The below commands will generate project files and create a Debug build of all
# JCEF native targets using CMake and the platform toolchain.
#
# Start by creating and entering the CMake build output directory. The
#`jcef_build` directory name is required by other JCEF tooling (specifically the
# tools/make_distrib.[bat|sh] and tools/run.[bat|sh] scripts) and should not be
# changed.
# > cd path/to/java-cef/src
# > mkdir jcef_build && cd jcef_build
#
# To perform a Linux build using a 32-bit CEF binary distribution on a 32-bit
# Linux platform or a 64-bit CEF binary distribution on a 64-bit Linux platform:
# Using Unix Makefiles:
# > cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
# > make -j4
#
# Using Ninja:
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# To perform a MacOS build using a 64-bit CEF binary distribution:
# Using the Xcode IDE:
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
# Open jcef.xcodeproj in Xcode and select Product > Build.
#
# Using Ninja:
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# To perform a MacOS build using an ARM64 CEF binary distribution:
# Using the Xcode IDE:
# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" ..
# Open jcef.xcodeproj in Xcode and select Product > Build.
#
# Using Ninja:
# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# To perform a Windows build using a 32-bit CEF binary distribution:
# Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 16" -A Win32 ..
# Open jcef.sln in Visual Studio and select Build > Build Solution.
#
# Using Ninja with Visual Studio 2019 command-line tools:
# (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# To perform a Windows build using a 64-bit CEF binary distribution:
# Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 16" -A x64 ..
# Open jcef.sln in Visual Studio and select Build > Build Solution.
#
# Using Ninja with Visual Studio 2019 command-line tools:
# (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# Shared configuration.
#
# For VS2019 and Xcode 12+ support.
cmake_minimum_required(VERSION 3.19)
# Only generate Debug and Release configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)
# Project name.
project(jcef)
# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY OS_FOLDERS ON)
#
# CEF configuration.
#
# Specify the CEF distribution version.
if(NOT DEFINED CEF_VERSION)
set(CEF_VERSION "130.1.9+gfc42567+chromium-130.0.6723.70")
endif()
# Determine the platform.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
if("${PROJECT_ARCH}" STREQUAL "arm64")
set(CEF_PLATFORM "macosarm64")
elseif("${PROJECT_ARCH}" STREQUAL "x86_64")
set(CEF_PLATFORM "macosx64")
elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(PROJECT_ARCH "arm64")
set(CEF_PLATFORM "macosarm64")
else()
set(PROJECT_ARCH "x86_64")
set(CEF_PLATFORM "macosx64")
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(CEF_PLATFORM "linux64")
else()
set(CEF_PLATFORM "linux32")
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(CEF_PLATFORM "windows64")
else()
set(CEF_PLATFORM "windows32")
endif()
endif()
# Add this project's cmake/ directory to the module path.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Download and extract the CEF binary distribution (executes DownloadCEF.cmake).
include(DownloadCEF)
DownloadCEF("${CEF_PLATFORM}" "${CEF_VERSION}" "${CMAKE_SOURCE_DIR}/third_party/cef")
# Add the CEF binary distribution's cmake/ directory to the module path.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
# Load the CEF configuration (executes FindCEF.cmake).
find_package(CEF REQUIRED)
#
# Python configuration.
#
# Support specification of the Python executable path via the command-line.
if(DEFINED ENV{PYTHON_EXECUTABLE})
file(TO_CMAKE_PATH "$ENV{PYTHON_EXECUTABLE}" PYTHON_EXECUTABLE)
endif()
if(NOT PYTHON_EXECUTABLE)
unset(PYTHON_EXECUTABLE)
# Find the python interpreter.
find_package(PythonInterp)
if(NOT ${PYTHONINTERP_FOUND})
message(FATAL_ERROR "A Python installation is required. Set the "
"PYTHON_EXECUTABLE environment variable to explicitly "
"specify the Python executable path.")
endif()
endif()
message(STATUS "Using Python: ${PYTHON_EXECUTABLE}")
#
# Java configuration.
#
# Minimum required Java version.
set(JDK_MIN_VERSION 1.7)
set(JAVA_FATAL_ERROR "A Java installation is required. Set the JAVA_HOME "
"environment variable to explicitly specify the Java "
"installation directory.")
# Find the Java Native Interface (JNI) installation.
find_package(JNI ${JDK_MIN_VERSION})
if(NOT ${JNI_FOUND})
message(FATAL_ERROR ${JAVA_FATAL_ERROR})
endif()
if(OS_MACOSX)
# OS X stores the Java binaries separately from the JNI includes/libraries.
# Find the Java development installation.
find_package(Java ${JDK_MIN_VERSION} COMPONENTS Development)
if(NOT ${Java_FOUND})
message(FATAL_ERROR ${JAVA_FATAL_ERROR})
endif()
# Determine the root path for the Java installation.
# Remove "bin/javac" from the path.
get_filename_component(JAVA_DIR ${Java_JAVAC_EXECUTABLE} DIRECTORY)
get_filename_component(JAVA_DIR ${JAVA_DIR} DIRECTORY)
else()
# Determine the root path for the Java installation.
# Remove "include" from the path.
get_filename_component(JAVA_DIR ${JAVA_INCLUDE_PATH} DIRECTORY)
endif()
#
# Post-configuration actions.
#
# Generate the JCEF version header.
message(STATUS "Generating native/jcef_version.h file...")
execute_process(
COMMAND "${PYTHON_EXECUTABLE}"
"tools/make_version_header.py"
"--header"
"native/jcef_version.h"
"--cef-path"
"${CEF_ROOT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE EXECUTE_RV
)
if(NOT EXECUTE_RV STREQUAL "0")
message(FATAL_ERROR "Execution failed with unexpected result: ${EXECUTE_RV}")
endif()
# Copy the CEF README.txt file to the cmake build directory for use by the
# make_readme.py script.
file(COPY "${CEF_ROOT}/README.txt" DESTINATION "${CMAKE_BINARY_DIR}")
# Download clang-format from Google Storage.
if(OS_WINDOWS)
set(GS_PLATFORM "win32")
set(GS_HASHPATH "win/clang-format.exe.sha1")
set(GS_OUTPATH "win/clang-format.exe")
elseif(OS_MACOSX)
set(GS_PLATFORM "darwin")
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(GS_HASHPATH "mac/clang-format.arm64.sha1")
else()
set(GS_HASHPATH "mac/clang-format.x64.sha1")
endif()
set(GS_OUTPATH "mac/clang-format")
elseif(OS_LINUX)
set(GS_PLATFORM "linux*")
set(GS_HASHPATH "linux64/clang-format.sha1")
set(GS_OUTPATH "linux64/clang-format")
endif()
message(STATUS "Downloading clang-format from Google Storage...")
execute_process(
COMMAND "${PYTHON_EXECUTABLE}"
"tools/buildtools/download_from_google_storage.py"
"--no_resume"
"--platform=${GS_PLATFORM}"
"--no_auth"
"--bucket" "chromium-clang-format"
"-s" "tools/buildtools/${GS_HASHPATH}"
"-o" "tools/buildtools/${GS_OUTPATH}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE EXECUTE_RV
)
if(NOT EXECUTE_RV STREQUAL "0")
message(FATAL_ERROR "Execution failed with unexpected result: ${EXECUTE_RV}")
endif()
#
# Include target subdirectories.
#
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
add_subdirectory(native)
#
# Display configuration settings.
#
PRINT_CEF_CONFIG()
message(STATUS "*** JCEF CONFIGURATION SETTINGS ***")
message(STATUS "Python executable: ${PYTHON_EXECUTABLE}")
message(STATUS "Java directory: ${JAVA_DIR}")
message(STATUS "JNI libraries: ${JNI_LIBRARIES}")
message(STATUS "JNI include directories: ${JNI_INCLUDE_DIRS}")