forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
289 lines (248 loc) · 9.03 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
# 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, Unix Makefiles
# Mac OS X: Ninja, Xcode 5+
# Windows: Ninja, Visual Studio 2010+
#
# 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 2.8.12.1 or newer.
#
# - Linux requirements:
# Currently supported distributions include Debian Wheezy, Ubuntu Precise, and
# related. Ubuntu 14.04 64-bit is recommended. Newer versions will likely also
# work but may not have been tested.
# Required packages include:
# build-essential
# libgtk2.0-dev
#
# - Mac OS X requirements:
# Xcode 5 or newer building on Mac OS X 10.9 (Mavericks) or newer. Xcode 7.2
# and OS X 10.11 are recommended. The Xcode command-line tools must also be
# installed. Only 64-bit builds are supported on OS X.
#
# - Windows requirements:
# Visual Studio 2010 or newer building on Windows 7 or newer. Visual Studio
# 2015 Update 2 and Windows 10 64-bit are recommended.
#
# 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 Mac OS X 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 Unix Makefiles:
# > cmake -G "Unix Makefiles" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
# > make -j4
#
# Using Ninja:
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# To perform a Windows build using a 32-bit CEF binary distribution:
# Using the Visual Studio 2015 IDE:
# > cmake -G "Visual Studio 14" ..
# Open jcef.sln in Visual Studio and select Build > Build Solution.
#
# Using Ninja with Visual Studio 2015 command-line tools:
# (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\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 2015 IDE:
# > cmake -G "Visual Studio 14 Win64" ..
# Open jcef.sln in Visual Studio and select Build > Build Solution.
#
# Using Ninja with Visual Studio 2015 command-line tools:
# (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja
#
# Shared configuration.
#
cmake_minimum_required(VERSION 2.8.12.1)
# 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 "78.2.7+g9cd8bac+chromium-78.0.3904.70")
endif()
# Determine the platform.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(CEF_PLATFORM "macosx64")
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()
#
# 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")
elseif(OS_MACOSX)
set(GS_PLATFORM "darwin")
set(GS_HASHPATH "mac/clang-format.sha1")
elseif(OS_LINUX)
set(GS_PLATFORM "linux*")
set(GS_HASHPATH "linux64/clang-format.sha1")
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}"
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}")