diff options
author | Marshall Greenblatt <magreenblatt@gmail.com> | 2015-09-24 18:38:18 +0300 |
---|---|---|
committer | Marshall Greenblatt <magreenblatt@gmail.com> | 2015-09-27 13:04:50 +0300 |
commit | a1e06a4a046671b4170f47d34623f7d69b6446f4 (patch) | |
tree | 41d9d1d5a9d37a624060d53097c0fc2b8ed7b108 | |
parent | 8e7fc7e3d4934ffbb7c080c129b264e6db963ea9 (diff) | |
download | jcef-a1e06a4a046671b4170f47d34623f7d69b6446f4.tar.gz |
Add CMake configuration for native targets (issue #171)
-rw-r--r-- | CMakeLists.txt | 589 | ||||
-rw-r--r-- | jcef.gyp | 1 | ||||
-rw-r--r-- | macros.cmake | 208 | ||||
-rw-r--r-- | native/CMakeLists.txt | 364 | ||||
-rw-r--r-- | native/compatibility.manifest | 17 | ||||
-rw-r--r-- | native/resources/jcef-Info.plist | 32 | ||||
-rw-r--r-- | tools/make_distrib.bat | 10 | ||||
-rwxr-xr-x | tools/make_distrib.sh | 24 | ||||
-rw-r--r-- | tools/run.bat | 8 | ||||
-rwxr-xr-x | tools/run.sh | 10 |
10 files changed, 1241 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8bafa2c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,589 @@ +# Copyright (c) 2014 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+, Unix Makefiles +# 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. +# +# CMAKE STRUCTURE +# +# JCEF includes the following CMake files: +# +# CMakeLists.txt Bootstrap that sets up the CMake environment and +# loads the other CMake files. +# macros.cmake Helper macros for building JCEF. +# native/CMakeLists.txt Defines the JCEF native targets. +# third_party/cef/<platform>/libcef_dll/CMakeLists.txt +# Defines the libcef_dll_wrapper target. +# See third_party/cef/README.jcef for details. +# +# BUILD REQUIREMENTS +# +# The below requirements must be met to build this JCEF binary distribution. +# +# - CMake version 2.8.12.2 or newer. +# +# - Linux requirements: +# Currently supported distributions include Debian Wheezy, Ubuntu Precise, and +# related. 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.7 (Lion) or newer. The Xcode +# command-line tools must also be installed. +# +# - Windows requirements: +# Visual Studio 2010 or newer building on Windows XP SP3 or newer. 64-bit +# version of Windows 7 or newer 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 build\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 2013 IDE: +# > cmake -G "Visual Studio 12" .. +# Open build\jcef.sln in Visual Studio and select Build > Build Solution. +# +# Using Ninja with Visual Studio 2013 command-line tools: +# (this path may be different depending on your Visual Studio installation) +# > "C:\Program Files (x86)\Microsoft Visual Studio 12.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 2013 IDE: +# > cmake -G "Visual Studio 12 Win64" .. +# Open build\jcef.sln in Visual Studio and select Build > Build Solution. +# +# Using Ninja with Visual Studio 2013 command-line tools: +# (this path may be different depending on your Visual Studio installation) +# > "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat" +# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug .. +# > ninja + +# +# Shared configuration. +# + +cmake_minimum_required(VERSION 2.8.12.2) + +# 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) + +# Determine the platform. +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + set(OS_MACOSX 1) + set(OS_POSIX 1) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set(OS_LINUX 1) + set(OS_POSIX 1) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") + set(OS_WINDOWS 1) +endif() + +# Determine the project architecture. +if(NOT DEFINED PROJECT_ARCH) + if(CMAKE_SIZEOF_VOID_P MATCHES 8) + set(PROJECT_ARCH "x86_64") + else() + set(PROJECT_ARCH "x86") + endif() + + if(OS_MACOSX) + # PROJECT_ARCH should be specified on Mac OS X. + message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}") + endif() +endif() + +if(NOT CMAKE_BUILD_TYPE AND + (${CMAKE_GENERATOR} STREQUAL "Ninja" OR ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")) + # CMAKE_BUILD_TYPE should be specified when using Ninja or Unix Makefiles. + set(CMAKE_BUILD_TYPE Release) + message(WARNING "No CMAKE_BUILD_TYPE value selected, using ${CMAKE_BUILD_TYPE}") +endif() + +# Include cmake macros. +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}") +include("macros") + +# Source include directory. +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +# Allow C++ programs to use stdint.h macros specified in the C99 standard that +# aren't in the C++ standard (e.g. UINT8_MAX, INT64_MIN, etc). +add_definitions(-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS) + + +# +# 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() + + +# +# Linux configuration. +# + +if(OS_LINUX) + # Platform-specific compiler/linker flags. + set(CEF_LIBTYPE SHARED) + # -fno-strict-aliasing = Avoid assumptions regarding non-aliasing of objects of different types + # -fPIC = Generate position-independent code for shared libraries + # -fstack-protector = Protect some vulnerable functions from stack-smashing (security feature) + # -funwind-tables = Support stack unwinding for backtrace() + # -fvisibility=hidden = Give hidden visibility to declarations that are not explicitly marked as visible + # --param=ssp-buffer-size=4 = Set the minimum buffer size protected by SSP (security feature, related to stack-protector) + # -pipe = Use pipes rather than temporary files for communication between build stages + # -pthread = Use the pthread library + # -Wall = Enable all warnings + # -Werror = Treat warnings as errors + # -Wno-missing-field-initializers = Don't warn about missing field initializers + # -Wno-unused-parameter = Don't warn about unused parameters + set(CEF_COMPILER_FLAGS "-fno-strict-aliasing -fPIC -fstack-protector -funwind-tables -fvisibility=default --param=ssp-buffer-size=4 -pipe -pthread -Wall -Werror -Wno-missing-field-initializers -Wno-unused-parameter") + # -std=c99 = Use the C99 language standard + set(CEF_C_COMPILER_FLAGS "-std=c99") + # -fno-exceptions = Disable exceptions + # -fno-rtti = Disable real-time type information + # -fno-threadsafe-statics = Don't generate thread-safe statics + # -fvisibility-inlines-hidden = Give hidden visibility to inlined class member functions + # -std=gnu++11 = Use the C++11 language standard including GNU extensions + # -Wsign-compare = Warn about mixed signed/unsigned type comparisons + set(CEF_CXX_COMPILER_FLAGS "-fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11 -Wsign-compare") + # -O0 = Disable optimizations + # -g = Generate debug information + set(CEF_COMPILER_FLAGS_DEBUG "-O0 -g") + # -O2 = Optimize for maximum speed + # -fdata-sections = Enable linker optimizations to improve locality of reference for data sections + # -ffunction-sections = Enable linker optimizations to improve locality of reference for function sections + # -fno-ident = Ignore the #ident directive + # -DNDEBUG = Not a debug build + # -U_FORTIFY_SOURCE = Undefine _FORTIFY_SOURCE in case it was previously defined + # -D_FORTIFY_SOURCE=2 = Add memory and string function protection (security feature, related to stack-protector) + set(CEF_COMPILER_FLAGS_RELEASE "-O2 -fdata-sections -ffunction-sections -fno-ident -DNDEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") + # -Wl,--disable-new-dtags = Don't generate new-style dynamic tags in ELF + # -Wl,--fatal-warnings = Treat warnings as errors + # -Wl,-rpath,. = Set rpath so that libraries can be placed next to the executable + # -Wl,-z,noexecstack = Mark the stack as non-executable (security feature) + # -Wl,-z,now = Resolve symbols on program start instead of on first use (security feature) + # -Wl,-z,relro = Mark relocation sections as read-only (security feature) + set(CEF_LINKER_FLAGS "-fPIC -pthread -Wl,--disable-new-dtags -Wl,--fatal-warnings -Wl,-rpath,. -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro") + # -Wl,-O1 = Enable linker optimizations + # -Wl,--as-needed = Only link libraries that export symbols used by the binary + # -Wl,--gc-sections = Remove unused code resulting from -fdata-sections and -function-sections + set(CEF_LINKER_FLAGS_RELEASE "-Wl,-O1 -Wl,--as-needed -Wl,--gc-sections") + + include(CheckCCompilerFlag) + include(CheckCXXCompilerFlag) + + # -Wno-unused-local-typedefs = Don't warn about unused local typedefs + CHECK_C_COMPILER_FLAG(-Wno-unused-local-typedefs COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS) + if(COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS) + set(CEF_C_COMPILER_FLAGS "${CEF_C_COMPILER_FLAGS} -Wno-unused-local-typedefs") + endif() + + # -Wno-literal-suffix = Don't warn about invalid suffixes on literals + CHECK_CXX_COMPILER_FLAG(-Wno-literal-suffix COMPILER_SUPPORTS_NO_LITERAL_SUFFIX) + if(COMPILER_SUPPORTS_NO_LITERAL_SUFFIX) + set(CEF_CXX_COMPILER_FLAGS "${CEF_CXX_COMPILER_FLAGS} -Wno-literal-suffix") + endif() + + # -Wno-narrowing = Don't warn about type narrowing + CHECK_CXX_COMPILER_FLAG(-Wno-narrowing COMPILER_SUPPORTS_NO_NARROWING) + if(COMPILER_SUPPORTS_NO_NARROWING) + set(CEF_CXX_COMPILER_FLAGS "${CEF_CXX_COMPILER_FLAGS} -Wno-narrowing") + endif() + + # Target architecture. + if(PROJECT_ARCH STREQUAL "x86_64") + # 64-bit architecture. + set(CEF_DISTRIB_TYPE "linux64") + set(CEF_COMPILER_FLAGS "${CEF_COMPILER_FLAGS} -m64 -march=x86-64") + set(CEF_LINKER_FLAGS "${CEF_LINKER_FLAGS} -m64") + elseif(PROJECT_ARCH STREQUAL "x86") + # 32-bit architecture. + set(CEF_DISTRIB_TYPE "linux32") + set(CEF_COMPILER_FLAGS "${CEF_COMPILER_FLAGS} -msse2 -mfpmath=sse -mmmx -m32") + set(CEF_LINKER_FLAGS "${CEF_LINKER_FLAGS} -m32") + endif() + + # Allow the Large File Support (LFS) interface to replace the old interface. + add_definitions(-D_FILE_OFFSET_BITS=64) + + # Standard libraries. + set(CEF_STANDARD_LIBS "X11") + + # CEF directory paths. + set(CEF_DISTRIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cef/${CEF_DISTRIB_TYPE}") + set(CEF_RESOURCE_DIR "${CEF_DISTRIB_DIR}/Resources") + set(CEF_BINARY_DIR "${CEF_DISTRIB_DIR}/${CMAKE_BUILD_TYPE}") + set(CEF_BINARY_DIR_DEBUG "${CEF_DISTRIB_DIR}/Debug") + set(CEF_BINARY_DIR_RELEASE "${CEF_DISTRIB_DIR}/Release") + + # CEF library paths. + set(CEF_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/libcef.so") + set(CEF_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/libcef.so") + + # List of CEF binary files. + set(CEF_BINARY_FILES + chrome-sandbox + libcef.so + natives_blob.bin + snapshot_blob.bin + ) + + # List of CEF resource files. + set(CEF_RESOURCE_FILES + cef.pak + cef_100_percent.pak + cef_200_percent.pak + cef_extensions.pak + devtools_resources.pak + icudtl.dat + locales + ) +endif() + + +# +# Mac OS X configuration. +# + +if(OS_MACOSX) + # Platform-specific compiler/linker flags. + # See also SET_XCODE_TARGET_PROPERTIES in macros.cmake. + set(CEF_LIBTYPE SHARED) + # -fno-strict-aliasing = Avoid assumptions regarding non-aliasing of objects of different types + # -fstack-protector = Protect some vulnerable functions from stack-smashing (security feature) + # -funwind-tables = Support stack unwinding for backtrace() + # -fvisibility=hidden = Give hidden visibility to declarations that are not explicitly marked as visible + # -Wall = Enable all warnings + # -Wendif-labels = Warn whenever an #else or an #endif is followed by text + # -Werror = Treat warnings as errors + # -Wextra = Enable additional warnings + # -Wnewline-eof = Warn about no newline at end of file + # -Wno-missing-field-initializers = Don't warn about missing field initializers + # -Wno-unused-parameter = Don't warn about unused parameters + set(CEF_COMPILER_FLAGS "-fno-strict-aliasing -fstack-protector -funwind-tables -fvisibility=hidden -Wall -Wendif-labels -Werror -Wextra -Wnewline-eof -Wno-missing-field-initializers -Wno-unused-parameter") + # -std=c99 = Use the C99 language standard + set(CEF_C_COMPILER_FLAGS "-std=c99") + # -fno-exceptions = Disable exceptions + # -fno-rtti = Disable real-time type information + # -fno-threadsafe-statics = Don't generate thread-safe statics + # -fobjc-call-cxx-cdtors = Call the constructor/destructor of C++ instance variables in ObjC objects + # -fvisibility-inlines-hidden = Give hidden visibility to inlined class member functions + # -std=gnu++11 = Use the C++11 language standard including GNU extensions + # -Wno-narrowing = Don't warn about type narrowing + # -Wsign-compare = Warn about mixed signed/unsigned type comparisons + set(CEF_CXX_COMPILER_FLAGS "-fno-exceptions -fno-rtti -fno-threadsafe-statics -fobjc-call-cxx-cdtors -fvisibility-inlines-hidden -std=gnu++11 -Wno-narrowing -Wsign-compare") + # -O0 = Disable optimizations + # -g = Generate debug information + set(CEF_COMPILER_FLAGS_DEBUG "-O0 -g") + # -O3 = Optimize for maximum speed plus a few extras + set(CEF_COMPILER_FLAGS_RELEASE "-O3") + # -Wl,-search_paths_first = Search for static or shared library versions in the same pass + # -Wl,-ObjC = Support creation of creation of ObjC static libraries + # -Wl,-pie = Generate position-independent code suitable for executables only + set(CEF_LINKER_FLAGS "-Wl,-search_paths_first -Wl,-ObjC -Wl,-pie") + # -Wl,-dead_strip = Strip dead code + set(CEF_LINKER_FLAGS_RELEASE "-Wl,-dead_strip") + + # Standard libraries. + set(CEF_STANDARD_LIBS "-lpthread" "-framework Cocoa" "-framework AppKit") + + # Find the newest available base SDK. + execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) + foreach(OS_VERSION 10.10 10.9 10.8 10.7) + set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk") + if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}") + set(CMAKE_OSX_SYSROOT ${SDK}) + endif() + endforeach() + + # Target SDK. + set(CEF_TARGET_SDK "10.6") + set(CEF_COMPILER_FLAGS "${CEF_COMPILER_FLAGS} -mmacosx-version-min=${CEF_TARGET_SDK}") + set(CMAKE_OSX_DEPLOYMENT_TARGET ${CEF_TARGET_SDK}) + + # Target architecture. + if(PROJECT_ARCH STREQUAL "x86_64") + # 64-bit architecture. + set(CEF_DISTRIB_TYPE "macosx64") + set(CMAKE_OSX_ARCHITECTURES "x86_64") + else() + # 32-bit architecture. + message(FATAL_ERROR "32-bit builds are not supported on OS X") + endif() + + # CEF directory paths. + set(CEF_DISTRIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cef/${CEF_DISTRIB_TYPE}") + set(CEF_BINARY_DIR "${CEF_DISTRIB_DIR}/$<CONFIGURATION>") + set(CEF_BINARY_DIR_DEBUG "${CEF_DISTRIB_DIR}/Debug") + set(CEF_BINARY_DIR_RELEASE "${CEF_DISTRIB_DIR}/Release") + + # CEF library paths. + set(CEF_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/Chromium Embedded Framework.framework/Chromium Embedded Framework") + set(CEF_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/Chromium Embedded Framework.framework/Chromium Embedded Framework") +endif() + + +# +# Windows configuration. +# + +if(OS_WINDOWS) + # Platform-specific compiler/linker flags. + set(CEF_LIBTYPE STATIC) + # /MP = Multiprocess compilation + # /Gy = Enable function-level linking + # /GR- = Disable run-time type information + # /Zi = Enable program database + # /W4 = Warning level 4 + # /WX = Treat warnings as errors + # /wd"4100" = Ignore "unreferenced formal parameter" warning + # /wd"4127" = Ignore "conditional expression is constant" warning + # /wd"4244" = Ignore "conversion possible loss of data" warning + # /wd"4512" = Ignore "assignment operator could not be generated" warning + # /wd"4701" = Ignore "potentially uninitialized local variable" warning + # /wd"4702" = Ignore "unreachable code" warning + # /wd"4996" = Ignore "function or variable may be unsafe" warning + set(CEF_COMPILER_FLAGS "/MP /Gy /GR- /Zi /W4 /WX /wd\"4100\" /wd\"4127\" /wd\"4244\" /wd\"4512\" /wd\"4701\" /wd\"4702\" /wd\"4996\"") + # /MTd = Multithreaded debug runtime + # /Od = Disable optimizations + # /RTC1 = Enable basic run-time checks + set(CEF_COMPILER_FLAGS_DEBUG "/MTd /RTC1 /Od") + # /MT = Multithreaded release runtime + # /O2 = Optimize for maximum speed + # /Ob2 = Inline any suitable function + # /GF = Enable string pooling + # /D NDEBUG /D _NDEBUG = Not a debug build + set(CEF_COMPILER_FLAGS_RELEASE "/MT /O2 /Ob2 /GF /D NDEBUG /D _NDEBUG") + # /DEBUG = Generate debug information + set(CEF_LINKER_FLAGS_DEBUG "/DEBUG") + # /MANIFEST:NO = No default manifest (see ADD_WINDOWS_MANIFEST macro usage) + set(CEF_EXE_LINKER_FLAGS "/MANIFEST:NO") + + # Standard definitions + # -DWIN32 -D_WIN32 -D_WINDOWS = Windows platform + # -DUNICODE -D_UNICODE = Unicode build + # -DWINVER=0x0602 -D_WIN32_WINNT=0x602 = Targeting Windows 8 + # -DNOMINMAX = Use the standard's templated min/max + # -DWIN32_LEAN_AND_MEAN = Exclude less common API declarations + # -D_HAS_EXCEPTIONS=0 = Disable exceptions + add_definitions(-DWIN32 -D_WIN32 -D_WINDOWS -DUNICODE -D_UNICODE -DWINVER=0x0602 + -D_WIN32_WINNT=0x602 -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0) + + # Standard libraries. + set(CEF_STANDARD_LIBS "comctl32.lib" "rpcrt4.lib" "shlwapi.lib") + + # Target architecture. + if(PROJECT_ARCH STREQUAL "x86_64") + # 64-bit architecture. + set(CEF_DISTRIB_TYPE "win64") + else() + # 32-bit architecture. + set(CEF_DISTRIB_TYPE "win32") + endif() + + # CEF directory paths. + set(CEF_DISTRIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cef/${CEF_DISTRIB_TYPE}") + set(CEF_RESOURCE_DIR "${CEF_DISTRIB_DIR}/Resources") + set(CEF_BINARY_DIR "${CEF_DISTRIB_DIR}/$<CONFIGURATION>") + set(CEF_BINARY_DIR_DEBUG "${CEF_DISTRIB_DIR}/Debug") + set(CEF_BINARY_DIR_RELEASE "${CEF_DISTRIB_DIR}/Release") + + # CEF library paths. + set(CEF_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/libcef.lib") + set(CEF_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/libcef.lib") + + # List of CEF binary files. + set(CEF_BINARY_FILES + d3dcompiler_43.dll + d3dcompiler_47.dll + libcef.dll + libEGL.dll + libGLESv2.dll + natives_blob.bin + snapshot_blob.bin + ) + if(PROJECT_ARCH STREQUAL "x86") + # Only used on 32-bit platforms. + set(CEF_BINARY_FILES + ${CEF_BINARY_FILES} + wow_helper.exe + ) + endif() + + # List of CEF resource files. + set(CEF_RESOURCE_FILES + cef.pak + cef_100_percent.pak + cef_200_percent.pak + cef_extensions.pak + devtools_resources.pak + icudtl.dat + locales + ) +endif() + + +# +# Post-configuration actions. +# + +# CEF binary distribution include directory. +include_directories(${CEF_DISTRIB_DIR}) + +# Merge compiler/linker flags. +set(CMAKE_C_FLAGS "${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}") +set(CMAKE_C_FLAGS_DEBUG "${CEF_COMPILER_FLAGS_DEBUG} ${CEF_C_COMPILER_FLAGS_DEBUG}") +set(CMAKE_C_FLAGS_RELEASE "${CEF_COMPILER_FLAGS_RELEASE} ${CEF_C_COMPILER_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS "${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}") +set(CMAKE_CXX_FLAGS_RELEASE "${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}") +set(CMAKE_EXE_LINKER_FLAGS "${CEF_LINKER_FLAGS} ${CEF_EXE_LINKER_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CEF_LINKER_FLAGS_DEBUG} ${CEF_EXE_LINKER_FLAGS_DEBUG}") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CEF_LINKER_FLAGS_RELEASE} ${CEF_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS "${CEF_LINKER_FLAGS} ${CEF_SHARED_LINKER_FLAGS}") +set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CEF_LINKER_FLAGS_DEBUG} ${CEF_SHARED_LINKER_FLAGS_DEBUG}") +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CEF_LINKER_FLAGS_RELEASE} ${CEF_SHARED_LINKER_FLAGS_RELEASE}") + + +# +# Include target subdirectories. +# + +add_subdirectory("${CEF_DISTRIB_DIR}/libcef_dll") +add_subdirectory(native) + + +# +# Display configuration settings. +# + +message(STATUS "*** CONFIGURATION SETTINGS ***") +message(STATUS "Generator: ${CMAKE_GENERATOR}") +message(STATUS "Platform: ${CMAKE_SYSTEM_NAME}") +message(STATUS "Project architecture: ${PROJECT_ARCH}") + +if(${CMAKE_GENERATOR} STREQUAL "Ninja" OR ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") + message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") +endif() + +if(OS_MACOSX) + message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}") + message(STATUS "Target SDK: ${CEF_TARGET_SDK}") +endif() + +message(STATUS "Java directory: ${JAVA_DIR}") +message(STATUS "JNI libraries: ${JNI_LIBRARIES}") +message(STATUS "JNI include directories: ${JNI_INCLUDE_DIRS}") + +set(LIBRARIES ${CEF_STANDARD_LIBS}) +message(STATUS "Standard libraries: ${LIBRARIES}") + +get_directory_property(DEFINITIONS COMPILE_DEFINITIONS) +message(STATUS "Compiler definitions: ${DEFINITIONS}") + +message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}") +message(STATUS "C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}") +message(STATUS "C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}") +message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}") +message(STATUS "CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") +message(STATUS "CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") +message(STATUS "EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") +message(STATUS "EXE_LINKER_FLAGS_DEBUG: ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") +message(STATUS "EXE_LINKER_FLAGS_RELEASE: ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +message(STATUS "SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}") +message(STATUS "SHARED_LINKER_FLAGS_DEBUG: ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") +message(STATUS "SHARED_LINKER_FLAGS_RELEASE: ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") + +if(OS_LINUX OR OS_WINDOWS) + message(STATUS "CEF Binary files: ${CEF_BINARY_FILES}") + message(STATUS "CEF Resource files: ${CEF_RESOURCE_FILES}") +endif() + @@ -293,7 +293,6 @@ '-rf', '<(cef_directory)/$(BUILDTYPE)/chrome-sandbox', '<(cef_directory)/$(BUILDTYPE)/libcef.so', - '<(cef_directory)/$(BUILDTYPE)/libffmpegsumo.so', '<(cef_directory)/$(BUILDTYPE)/natives_blob.bin', '<(cef_directory)/$(BUILDTYPE)/snapshot_blob.bin', '<(PRODUCT_DIR)', diff --git a/macros.cmake b/macros.cmake new file mode 100644 index 0000000..f4d62e1 --- /dev/null +++ b/macros.cmake @@ -0,0 +1,208 @@ +# Copyright (c) 2014 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. + +# +# Shared macros. +# + +# Append platform specific sources to a list of sources. +macro(APPEND_PLATFORM_SOURCES name_of_list) + if(OS_LINUX AND ${name_of_list}_LINUX) + list(APPEND ${name_of_list} ${${name_of_list}_LINUX}) + endif() + if(OS_POSIX AND ${name_of_list}_POSIX) + list(APPEND ${name_of_list} ${${name_of_list}_POSIX}) + endif() + if(OS_WINDOWS AND ${name_of_list}_WINDOWS) + list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS}) + endif() + if(OS_MACOSX AND ${name_of_list}_MACOSX) + list(APPEND ${name_of_list} ${${name_of_list}_MACOSX}) + endif() +endmacro() + +# Add a logical target that can be used to link the specified libraries into an +# executable target. +macro(ADD_LOGICAL_TARGET target debug_lib release_lib) + add_library(${target} ${CEF_LIBTYPE} IMPORTED) + set_target_properties(${target} PROPERTIES + IMPORTED_LOCATION "${release_lib}" + IMPORTED_LOCATION_DEBUG "${debug_lib}" + IMPORTED_LOCATION_RELEASE "${release_lib}" + ) +endmacro() + +# Determine the target output directory based on platform and generator. +macro(SET_CEF_TARGET_OUT_DIR) + if(${CMAKE_GENERATOR} STREQUAL "Ninja" OR + ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") + # By default Ninja and Make builds don't create a subdirectory named after + # the configuration. + set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}") + + # Output binaries (executables, libraries) to the correct directory. + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR}) + else() + set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>") + endif() +endmacro() + +# Copy a list of files from one directory to another. Relative files paths are maintained. +macro(COPY_FILES target file_list source_dir target_dir) + foreach(FILENAME ${file_list}) + set(source_file ${source_dir}/${FILENAME}) + set(target_file ${target_dir}/${FILENAME}) + if(IS_DIRECTORY ${source_file}) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory "${source_file}" "${target_file}" + VERBATIM + ) + else() + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${source_file}" "${target_file}" + VERBATIM + ) + endif() + endforeach() +endmacro() + + +# +# Linux macros. +# + +if(OS_LINUX) + +# Use pkg-config to find Linux libraries and update compiler/linker variables. +macro(FIND_LINUX_LIBRARIES libraries) + # Read pkg-config info into variables. + execute_process(COMMAND pkg-config --cflags ${libraries} OUTPUT_VARIABLE FLL_CFLAGS) + execute_process(COMMAND pkg-config --libs-only-L --libs-only-other ${libraries} OUTPUT_VARIABLE FLL_LDFLAGS) + execute_process(COMMAND pkg-config --libs-only-l ${libraries} OUTPUT_VARIABLE FLL_LIBS) + + # Strip leading and trailing whitepspace. + STRING(STRIP "${FLL_CFLAGS}" FLL_CFLAGS) + STRING(STRIP "${FLL_LDFLAGS}" FLL_LDFLAGS) + STRING(STRIP "${FLL_LIBS}" FLL_LIBS) + + # Update the variables. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLL_CFLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLL_CFLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLL_LDFLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLL_LDFLAGS}") + set(CEF_STANDARD_LIBS "${CEF_STANDARD_LIBS} ${FLL_LIBS}") +endmacro() + +endif(OS_LINUX) + + +# +# Mac OS X macros. +# + +if(OS_MACOSX) + +# Set Xcode target properties. +function(SET_XCODE_TARGET_PROPERTIES target) + set_target_properties(${target} PROPERTIES + XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO + XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++11" # -std=gnu++11 + XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME NO # -fno-objc-link-runtime + XCODE_ATTRIBUTE_CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS YES # -Wobjc-missing-property-synthesis + XCODE_ATTRIBUTE_COPY_PHASE_STRIP NO + XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release] YES # -Wl,-dead_strip + XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "c99" # -std=c99 + XCODE_ATTRIBUTE_GCC_CW_ASM_SYNTAX NO # No -fasm-blocks + XCODE_ATTRIBUTE_GCC_DYNAMIC_NO_PIC NO + XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS NO # -fno-exceptions + XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI NO # -fno-rtti + XCODE_ATTRIBUTE_GCC_ENABLE_PASCAL_STRINGS NO # No -mpascal-strings + XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES # -fvisibility-inlines-hidden + XCODE_ATTRIBUTE_GCC_OBJC_CALL_CXX_CDTORS YES # -fobjc-call-cxx-cdtors + XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES # -fvisibility=hidden + XCODE_ATTRIBUTE_GCC_THREADSAFE_STATICS NO # -fno-threadsafe-statics + XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS YES # -Werror + XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0" + XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE YES # -Wnewline-eof + XCODE_ATTRIBUTE_USE_HEADERMAP NO + OSX_ARCHITECTURES_DEBUG "${CMAKE_OSX_ARCHITECTURES}" + OSX_ARCHITECTURES_RELEASE "${CMAKE_OSX_ARCHITECTURES}" + ) +endfunction() + +# Override default add_library function. +function(add_library name) + _add_library(${name} ${ARGN}) + SET_XCODE_TARGET_PROPERTIES(${name}) +endfunction() + +# Override default add_executable function. +function(add_executable name) + _add_executable(${name} ${ARGN}) + SET_XCODE_TARGET_PROPERTIES(${name}) +endfunction() + +# Fix the framework link in the helper executable. +macro(FIX_MACOSX_HELPER_FRAMEWORK_LINK target app_path) + add_custom_command(TARGET ${target} + POST_BUILD + COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework" + "@executable_path/../../../../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" + "${app_path}/Contents/MacOS/${target}" + VERBATIM + ) +endmacro() + +# Fix the framework link in the JCEF library. +macro(FIX_MACOSX_MAIN_FRAMEWORK_LINK target target_path) + add_custom_command(TARGET ${target} + POST_BUILD + COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework" + "@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" + "${target_path}" + VERBATIM + ) +endmacro() + +# Make the other helper app bundles. +macro(MAKE_MACOSX_HELPERS target app_path) + add_custom_command(TARGET ${target} + POST_BUILD + # The exported variables need to be set for generators other than Xcode. + COMMAND export BUILT_PRODUCTS_DIR=${app_path} && + export CONTENTS_FOLDER_PATH=/Contents && + ${CEF_DISTRIB_DIR}/tools/make_more_helpers.sh "Frameworks" "${target}" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + VERBATIM + ) +endmacro() + +endif(OS_MACOSX) + + +# +# Windows macros. +# + +if(OS_WINDOWS) + +# Add custom manifest files to an executable target. +macro(ADD_WINDOWS_MANIFEST manifest_path target extension) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "mt.exe" -nologo + -manifest \"${manifest_path}/${target}.${extension}.manifest\" \"${manifest_path}/compatibility.manifest\" + -outputresource:"${CEF_TARGET_OUT_DIR}/${target}.${extension}"\;\#1 + COMMENT "Adding manifest..." + ) +endmacro() + +endif(OS_WINDOWS) + diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt new file mode 100644 index 0000000..21c0d6f --- /dev/null +++ b/native/CMakeLists.txt @@ -0,0 +1,364 @@ +# Copyright (c) 2014 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. + +# +# Source files. +# + +# jcef sources. +set(JCEF_SRCS + CefApp.cpp + CefApp.h + CefAuthCallback_N.cpp + CefAuthCallback_N.h + CefBeforeDownloadCallback_N.cpp + CefBeforeDownloadCallback_N.h + CefBrowser_N.cpp + CefBrowser_N.h + CefCallback_N.cpp + CefCallback_N.h + CefClientHandler.cpp + CefClientHandler.h + CefCommandLine_N.cpp + CefCommandLine_N.h + CefContextMenuParams_N.cpp + CefContextMenuParams_N.h + CefCookieManager_N.cpp + CefCookieManager_N.h + CefDownloadItemCallback_N.cpp + CefDownloadItemCallback_N.h + CefDownloadItem_N.cpp + CefDownloadItem_N.h + CefDragData_N.cpp + CefDragData_N.h + CefFileDialogCallback_N.cpp + CefFileDialogCallback_N.h + CefGeolocationCallback_N.h + CefGeolocationCallback_N.cpp + CefJSDialogCallback_N.h + CefJSDialogCallback_N.cpp + CefMenuModel_N.cpp + CefMenuModel_N.h + CefMessageRouter_N.cpp + CefMessageRouter_N.h + CefPostData_N.cpp + CefPostData_N.h + CefPostDataElement_N.cpp + CefPostDataElement_N.h + CefPrintDialogCallback_N.cpp + CefPrintDialogCallback_N.h + CefPrintJobCallback_N.cpp + CefPrintJobCallback_N.h + CefPrintSettings_N.cpp + CefPrintSettings_N.h + CefQueryCallback_N.cpp + CefQueryCallback_N.h + CefRequest_N.cpp + CefRequest_N.h + CefRequestCallback_N.cpp + CefRequestCallback_N.h + CefRequestContext_N.cpp + CefRequestContext_N.h + CefResponse_N.cpp + CefResponse_N.h + CefSchemeRegistrar_N.cpp + CefSchemeRegistrar_N.h + CefURLRequest_N.cpp + CefURLRequest_N.h + CefWebPluginInfo_N.cpp + CefWebPluginInfo_N.h + CefWebPluginManager_N.cpp + CefWebPluginManager_N.h + browser_process_handler.cpp + browser_process_handler.h + client_app.cpp + client_app.h + client_handler.cpp + client_handler.h + completion_callback.cpp + completion_callback.h + context_menu_handler.cpp + context_menu_handler.h + cookie_visitor.cpp + cookie_visitor.h + critical_wait.h + dialog_handler.cpp + dialog_handler.h + display_handler.cpp + display_handler.h + download_handler.cpp + download_handler.h + drag_handler.cpp + drag_handler.h + focus_handler.cpp + focus_handler.h + geolocation_handler.cpp + geolocation_handler.h + jcef_version.h + jni_util.h + jni_util.cpp + jsdialog_handler.cpp + jsdialog_handler.h + keyboard_handler.cpp + keyboard_handler.h + life_span_handler.cpp + life_span_handler.h + load_handler.cpp + load_handler.h + message_router_handler.cpp + message_router_handler.h + print_handler.cpp + print_handler.h + render_handler.cpp + render_handler.h + request_context_handler.cpp + request_context_handler.h + request_handler.cpp + request_handler.h + resource_handler.cpp + resource_handler.h + run_file_dialog_callback.cpp + run_file_dialog_callback.h + scheme_handler_factory.cpp + scheme_handler_factory.h + string_visitor.cpp + string_visitor.h + url_request_client.cpp + url_request_client.h + util.h + web_plugin_unstable_callback.cpp + web_plugin_unstable_callback.h + web_plugin_visitor.cpp + web_plugin_visitor.h + window_handler.cpp + window_handler.h + write_handler.cpp + write_handler.h + ) +set(JCEF_SRCS_LINUX + critical_wait_posix.cpp + signal_restore_posix.cpp + signal_restore_posix.h + util_linux.cpp + util_posix.cpp + ) +set(JCEF_SRCS_MACOSX + critical_wait_posix.cpp + signal_restore_posix.cpp + signal_restore_posix.h + util_mac.h + util_mac.mm + util_posix.cpp + ) +set(JCEF_SRCS_WINDOWS + critical_wait_win.cpp + jni_util_win.cpp + jcef_dll.rc + util_win.cpp + ) +APPEND_PLATFORM_SOURCES(JCEF_SRCS) +source_group(jcef FILES ${JCEF_SRCS}) + +# jcef_helper sources. +set(JCEF_HELPER_SRCS + jcef_helper.cpp + util.h + ) +set(JCEF_HELPER_SRCS_LINUX + util_linux.cpp + util_posix.cpp + ) +set(JCEF_HELPER_SRCS_MACOSX + util_posix.cpp + ) +set(JCEF_HELPER_SRCS_WINDOWS + jcef_helper.rc + util_win.cpp + ) +APPEND_PLATFORM_SOURCES(JCEF_HELPER_SRCS) +source_group(jcef FILES ${JCEF_HELPER_SRCS}) + + +# +# Shared configuration. +# + +# Target binary names. +set(JCEF_TARGET "jcef") +if(OS_MACOSX) + set(JCEF_APP_NAME "jcef_app") + set(JCEF_HELPER_TARGET "jcef Helper") +else() + set(JCEF_HELPER_TARGET "jcef_helper") +endif() + +# Logical target used to link the libcef library. +ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") + +# Determine the target output directory. +SET_CEF_TARGET_OUT_DIR() + + +# +# Linux configuration. +# + +if(OS_LINUX) + # Find required libraries and update compiler/linker variables. + FIND_LINUX_LIBRARIES("gmodule-2.0 gtk+-2.0 gthread-2.0") + + # Helper executable target. + add_executable(${JCEF_HELPER_TARGET} ${JCEF_HELPER_SRCS}) + add_dependencies(${JCEF_HELPER_TARGET} libcef_dll_wrapper) + target_link_libraries(${JCEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) + + # Set rpath so that libraries can be placed next to the executable. + set_target_properties(${JCEF_HELPER_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN") + set_target_properties(${JCEF_HELPER_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) + + # JCEF library target. + add_library(${JCEF_TARGET} SHARED ${JCEF_SRCS}) + add_dependencies(${JCEF_TARGET} libcef_dll_wrapper ${JCEF_HELPER_TARGET}) + target_link_libraries(${JCEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} ${JNI_LIBRARIES}) + target_include_directories(${JCEF_TARGET} PUBLIC ${JNI_INCLUDE_DIRS}) + + # Compile flags specific to the JCEF library target. + # -DUSING_JAVA = Add the USING_JAVA define. + # -fvisibility=default = Give default visibility to declarations that are not explicitly marked as visible. + # Necessary so that JNI symbols are properly exported when building with GCC. + # Related discussion: http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-February/014446.html + # Test symbol export with: nm -D --defined-only libjcef.so | grep Java + set_target_properties(${JCEF_TARGET} PROPERTIES + COMPILE_FLAGS -DUSING_JAVA + COMPILE_FLAGS -fvisibility=default + ) + + # Set rpath so that libraries can be placed next to the library. + set_target_properties(${JCEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN") + set_target_properties(${JCEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) + + # Copy binary and resource files to the target output directory. + COPY_FILES("${JCEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") + COPY_FILES("${JCEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}") + + # TODO(jcef): Eliminate the symlink requirement once we figure out how. + # See https://bitbucket.org/chromiumembedded/java-cef/issues/137#comment-20535941 + add_custom_command( + TARGET ${JCEF_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMAND ${CMAKE_COMMAND} -E echo "*** Run the following commands manually to create necessary symlinks ***" + COMMAND ${CMAKE_COMMAND} -E echo "sudo ln -s ${CEF_RESOURCE_DIR}/icudtl.dat ${JAVA_DIR}/jre/bin/icudtl.dat" + COMMAND ${CMAKE_COMMAND} -E echo "sudo ln -s ${CEF_BINARY_DIR}/natives_blob.bin ${JAVA_DIR}/jre/bin/natives_blob.bin" + COMMAND ${CMAKE_COMMAND} -E echo "sudo ln -s ${CEF_BINARY_DIR}/snapshot_blob.bin ${JAVA_DIR}/jre/bin/snapshot_blob.bin" + COMMAND ${CMAKE_COMMAND} -E echo "" + VERBATIM + ) +endif() + + +# +# Mac OS X configuration. +# + +if(OS_MACOSX) + # Output paths for the app bundles. + set(JCEF_APP "${CEF_TARGET_OUT_DIR}/${JCEF_APP_NAME}.app") + set(JCEF_HELPER_APP "${CEF_TARGET_OUT_DIR}/${JCEF_HELPER_TARGET}.app") + + # Variable referenced from Info.plist files. + set(PRODUCT_NAME "${JCEF_APP_NAME}") + + # Helper executable target. + add_executable(${JCEF_HELPER_TARGET} MACOSX_BUNDLE ${JCEF_HELPER_SRCS}) + add_dependencies(${JCEF_HELPER_TARGET} libcef_dll_wrapper) + target_link_libraries(${JCEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) + set_target_properties(${JCEF_HELPER_TARGET} PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/jcef-Info.plist + ) + + # Fix the framework link in the helper executable. + FIX_MACOSX_HELPER_FRAMEWORK_LINK(${JCEF_HELPER_TARGET} ${JCEF_HELPER_APP}) + + # JCEF library target. + add_library(${JCEF_TARGET} SHARED ${JCEF_RESOURCES_SRCS} ${JCEF_SRCS}) + add_dependencies(${JCEF_TARGET} libcef_dll_wrapper "${JCEF_HELPER_TARGET}") + target_link_libraries(${JCEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} ${JNI_LIBRARIES}) + target_include_directories(${JCEF_TARGET} PUBLIC ${JNI_INCLUDE_DIRS}) + + # Compile flags specific to the JCEF library target. + # -DUSING_JAVA = Add the USING_JAVA define. + set_target_properties(${JCEF_TARGET} PROPERTIES + COMPILE_FLAGS -DUSING_JAVA + ) + + # Name and location of the JCEF library in the main app bundle. + set(JCEF_TARGET_LIBRARY "lib${JCEF_TARGET}.dylib") + set(JCEF_TARGET_LIBRARY_APP_PATH "${JCEF_APP}/Contents/Java/${JCEF_TARGET_LIBRARY}") + + add_custom_command( + TARGET ${JCEF_TARGET} + POST_BUILD + # Build the main app bundle. + COMMAND ant + -buildfile ${CMAKE_SOURCE_DIR} + -Djdk7.path=${JAVA_DIR} + -Dout.path=${CEF_TARGET_OUT_DIR} + -Dout.name=${JCEF_APP_NAME} + -Dout.id=org.jcef.jcef + -Dout.mainclass=tests.detailed.MainFrame + bundle + # Copy the helper app bundle into the main app bundle. + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${JCEF_HELPER_APP}" + "${JCEF_APP}/Contents/Frameworks/${JCEF_HELPER_TARGET}.app" + # Copy the CEF framework into the main app bundle. + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CEF_BINARY_DIR}/Chromium Embedded Framework.framework" + "${JCEF_APP}/Contents/Frameworks/Chromium Embedded Framework.framework" + # Copy the JCEF library into the main app bindle. + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CEF_TARGET_OUT_DIR}/${JCEF_TARGET_LIBRARY}" + "${JCEF_TARGET_LIBRARY_APP_PATH}" + VERBATIM + ) + + # Fix the framework link in the JCEF library. + FIX_MACOSX_MAIN_FRAMEWORK_LINK(${JCEF_TARGET} ${JCEF_TARGET_LIBRARY_APP_PATH}) + + # Make the other helper app bundles. + MAKE_MACOSX_HELPERS(${JCEF_TARGET} ${JCEF_APP}) +endif() + + +# +# Windows configuration. +# + +if(OS_WINDOWS) + # Helper executable target. + add_executable(${JCEF_HELPER_TARGET} WIN32 ${JCEF_HELPER_SRCS}) + add_dependencies(${JCEF_HELPER_TARGET} libcef_dll_wrapper) + target_link_libraries(${JCEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) + + # JCEF library target. + add_library(${JCEF_TARGET} SHARED ${JCEF_SRCS}) + add_dependencies(${JCEF_TARGET} libcef_dll_wrapper ${JCEF_HELPER_TARGET}) + target_link_libraries(${JCEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} ${JNI_LIBRARIES}) + target_include_directories(${JCEF_TARGET} PUBLIC ${JNI_INCLUDE_DIRS}) + + # Compile flags specific to the JCEF library target. + # -DUSING_JAVA = Add the USING_JAVA define. + set_target_properties(${JCEF_TARGET} PROPERTIES + COMPILE_FLAGS -DUSING_JAVA + ) + + # Add the custom manifest files to the executable. + ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}" "${JCEF_TARGET}" "dll") + + # Copy binary and resource files to the target output directory. + COPY_FILES("${JCEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") + COPY_FILES("${JCEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}") +endif() + diff --git a/native/compatibility.manifest b/native/compatibility.manifest new file mode 100644 index 0000000..10d10da --- /dev/null +++ b/native/compatibility.manifest @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!--The ID below indicates application support for Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!--The ID below indicates application support for Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!--The ID below indicates application support for Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!--The ID below indicates application support for Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!--The ID below indicates application support for Windows 10 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + </application> + </compatibility> +</assembly> diff --git a/native/resources/jcef-Info.plist b/native/resources/jcef-Info.plist index 2d4d270..16edf4b 100644 --- a/native/resources/jcef-Info.plist +++ b/native/resources/jcef-Info.plist @@ -2,31 +2,29 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>BuildMachineOSBuild</key> - <string>12C3012</string> <key>CFBundleDevelopmentRegion</key> <string>en</string> + <key>CFBundleDisplayName</key> + <string>${EXECUTABLE_NAME}</string> <key>CFBundleExecutable</key> - <string>Chromium Embedded Framework</string> + <string>${EXECUTABLE_NAME}</string> <key>CFBundleIdentifier</key> - <string>org.jcef.JavaChromiumEmbeddedFramework.framework</string> + <string>org.jcef.jcef.helper</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> <key>CFBundlePackageType</key> - <string>FMWK</string> - <key>CFBundleShortVersionString</key> - <string>1.0.0</string> + <string>APPL</string> <key>CFBundleSignature</key> <string>????</string> - <key>CFBundleVersion</key> - <string>1.0</string> - <key>DTSDKBuild</key> - <string>11E52</string> - <key>DTSDKName</key> - <string>macosx10.7</string> - <key>DTXcode</key> - <string>0463</string> - <key>DTXcodeBuild</key> - <string>4H1503</string> + <key>LSFileQuarantineEnabled</key> + <true/> + <key>LSMinimumSystemVersion</key> + <string>10.5.0</string> + <key>LSUIElement</key> + <string>1</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> </dict> </plist> diff --git a/tools/make_distrib.bat b/tools/make_distrib.bat index d61b5f0..63218ef 100644 --- a/tools/make_distrib.bat +++ b/tools/make_distrib.bat @@ -19,6 +19,14 @@ set DISTRIB_DOCS_PATH="%DISTRIB_PATH%\docs" set DISTRIB_LIB_PATH="%DISTRIB_PATH%\bin\lib\%1"
set OUT_PATH=".\out\%1"
set OUT_BINARY_PATH="%OUT_PATH%\Release"
+
+:: Alternately look in the CMake output path.
+if not exist %OUT_BINARY_PATH% set OUT_BINARY_PATH=".\jcef_build\native\Release"
+if not exist %OUT_BINARY_PATH% (
+echo ERROR: Native Release build output path does not exist
+goto end
+)
+
set OUT_DOCS_PATH=".\out\docs"
set SOURCE_PATH=".\java"
set JOGAMP_PATH=".\third_party\jogamp"
@@ -64,7 +72,7 @@ copy %OUT_BINARY_PATH%\libcef.dll %DISTRIB_LIB_PATH% copy %OUT_BINARY_PATH%\natives_blob.bin %DISTRIB_LIB_PATH%
copy %OUT_BINARY_PATH%\snapshot_blob.bin %DISTRIB_LIB_PATH%
if exist %OUT_BINARY_PATH%\wow_helper.exe copy %OUT_BINARY_PATH%\wow_helper.exe %DISTRIB_LIB_PATH%
-xcopy /sfy %OUT_PATH%\Release\*.pak %DISTRIB_LIB_PATH%
+xcopy /sfy %OUT_BINARY_PATH%\*.pak %DISTRIB_LIB_PATH%
:: Copy documentation to the docs directory.
xcopy /sfy %OUT_DOCS_PATH%\* %DISTRIB_DOCS_PATH%\
diff --git a/tools/make_distrib.sh b/tools/make_distrib.sh index 0f8f2e2..73a1292 100755 --- a/tools/make_distrib.sh +++ b/tools/make_distrib.sh @@ -41,6 +41,16 @@ else if [ $1 == "macosx64" ]; then export OUT_BINARY_PATH="./xcodebuild/Release" + + # Alternately look in the CMake output path. + if [ ! -d "$OUT_BINARY_PATH" ]; then + export OUT_BINARY_PATH="./jcef_build/native/Release" + fi + if [ ! -d "$OUT_BINARY_PATH" ]; then + echo "ERROR: Native Release build output path does not exist" + exit 1 + fi + export DISTRIB_TESTS_PATH="$DISTRIB_PATH/tests" if [ ! -d "$DISTRIB_TESTS_PATH" ]; then @@ -56,6 +66,15 @@ else export DISTRIB_LIB_PATH="$DISTRIB_PATH/bin/lib/$1" export JOGAMP_JAR_PATH="$JOGAMP_PATH/jar" export OUT_BINARY_PATH="$OUT_PATH/Release" + + # Alternately look in the CMake output path. + if [ ! -d "$OUT_BINARY_PATH" ]; then + export OUT_BINARY_PATH="./jcef_build/native/Release" + fi + if [ ! -d "$OUT_BINARY_PATH" ]; then + echo "ERROR: Native Release build output path does not exist" + exit 1 + fi # Create the JCEF JAR file. cd tools @@ -85,15 +104,14 @@ else fi cp -f $OUT_BINARY_PATH/chrome-sandbox $DISTRIB_LIB_PATH - cp -f $OUT_BINARY_PATH/libffmpegsumo.so $DISTRIB_LIB_PATH cp -f $OUT_BINARY_PATH/libjcef.so $DISTRIB_LIB_PATH cp -f $OUT_BINARY_PATH/jcef_helper $DISTRIB_LIB_PATH cp -f $OUT_BINARY_PATH/icudtl.dat $DISTRIB_LIB_PATH cp -f $OUT_BINARY_PATH/libcef.so $DISTRIB_LIB_PATH cp -f $OUT_BINARY_PATH/natives_blob.bin $DISTRIB_LIB_PATH cp -f $OUT_BINARY_PATH/snapshot_blob.bin $DISTRIB_LIB_PATH - cp -f $OUT_PATH/Release/*.pak $DISTRIB_LIB_PATH - cp -rf $OUT_PATH/Release/locales/ $DISTRIB_LIB_PATH + cp -f $OUT_BINARY_PATH/*.pak $DISTRIB_LIB_PATH + cp -rf $OUT_BINARY_PATH/locales/ $DISTRIB_LIB_PATH fi cd tools diff --git a/tools/run.bat b/tools/run.bat index 7e737da..96f133b 100644 --- a/tools/run.bat +++ b/tools/run.bat @@ -27,6 +27,14 @@ goto end set OUT_PATH=.\out\%~1
set LIB_PATH=%OUT_PATH%\%~2
+
+:: Alternately look in the CMake output path.
+if not exist %LIB_PATH% set LIB_PATH=.\jcef_build\native\%~2
+if not exist %LIB_PATH% (
+echo ERROR: Native build output path does not exist
+goto end
+)
+
set CLS_PATH=.\third_party\jogamp\jar\*;%OUT_PATH%
set RUN_TYPE=%~3
diff --git a/tools/run.sh b/tools/run.sh index 6538db7..9609e60 100755 --- a/tools/run.sh +++ b/tools/run.sh @@ -15,6 +15,16 @@ else else export OUT_PATH="./out" export LIB_PATH=$(readlink -f "$OUT_PATH/$2") + + # Alternately look in the CMake output path. + if [ ! -d "$LIB_PATH" ]; then + export LIB_PATH=$(readlink -f "./jcef_build/native/$2") + fi + if [ ! -d "$LIB_PATH" ]; then + echo "ERROR: Native build output path does not exist" + exit 1 + fi + export CLS_PATH="./third_party/jogamp/jar/*:$OUT_PATH/$1" export RUN_TYPE="$3" |