Modernize binary distribution CMake configuration (issue #1897)

- Load CEF configuration using `find_package(CEF)`.
- Use per-target configuration via a new SET_EXECUTABLE_TARGET_PROPERTIES
  macro instead of setting global CMAKE_* variables.
- Support building projects more easily with an external binary
  distribution directory.
- Improve related documentation.
This commit is contained in:
Marshall Greenblatt 2016-05-12 17:41:30 -04:00
parent 958618359c
commit 575c968a55
12 changed files with 974 additions and 709 deletions

View File

@ -24,17 +24,14 @@
#
# This CEF binary distribution 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 a generic CEF-based
# application.
# CMakeLists.txt Bootstrap that sets up the CMake environment.
# cmake/*.cmake CEF configuration files shared by all targets.
# libcef_dll/CMakeLists.txt Defines the libcef_dll_wrapper target.
# cefclient/CMakeLists.txt Defines the cefclient target.
# cefsimple/CMakeLists.txt Defines the cefsimple target.
#
# Existing CMake projects that use this binary distribution without changing the
# directory structure can include the existing "libcef_dll/CMakeLists.txt" file
# with minimal or no changes.
# See the "TODO:" comments below for guidance on how to integrate this CEF
# binary distribution into a new or existing CMake project.
#
# BUILD REQUIREMENTS
#
@ -111,7 +108,7 @@
# > ninja cefclient cefsimple
#
# Shared configuration.
# Global setup.
#
cmake_minimum_required(VERSION 2.8.12.1)
@ -120,458 +117,91 @@ cmake_minimum_required(VERSION 2.8.12.1)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
# Project name.
# TODO: Change this line to match your project name when you copy this file.
project(cef)
# 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()
#
# CEF_ROOT setup.
# This variable must be set to locate the binary distribution.
# TODO: Choose one of the below examples and comment out the rest.
#
if(OS_MACOSX)
# PROJECT_ARCH should be specified on Mac OS X.
message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}")
endif()
endif()
# Example 1: The current directory contains both the complete binary
# distribution and your project.
# A. Comment in these lines:
#
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
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()
# Example 2: The binary distribution is in a separate directory from your
# project. Locate the binary distribution using the CEF_ROOT CMake
# variable.
# A. Create a directory structure for your project like the following:
# myproject/
# CMakeLists.txt <= top-level CMake configuration
# mytarget/
# CMakeLists.txt <= CMake configuration for `mytarget`
# ... other `mytarget` source files
# B. Copy this file to "myproject/CMakeLists.txt" as the top-level CMake
# configuration.
# C. Create the target-specific "myproject/mytarget/CMakeLists.txt" file for
# your application. See the included cefclient and cefsimple CMakeLists.txt
# files as an example.
# D. Comment in these lines:
#
# set(CEF_ROOT "c:/path/to/cef_binary_3.2704.xxxx.gyyyyyyy_windows32")
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
# 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)
# Example 3: The binary distribution is in a separate directory from your
# project. Locate the binary distribution using the CEF_ROOT
# environment variable.
# A. Create a directory structure for your project like the following:
# myproject/
# CMakeLists.txt <= top-level CMake configuration
# cmake/
# FindCEF.cmake <= CEF CMake configuration entry point
# mytarget/
# CMakeLists.txt <= CMake configuration for `mytarget`
# ... other `mytarget` source files
# B. Copy this file to "myproject/CMakeLists.txt" as the top-level CMake
# configuration.
# C. Copy the cmake/FindCEF.cmake file to "myproject/cmake/FindCEF.cmake".
# D. Create the target-specific "myproject/mytarget/CMakeLists.txt" file for
# your application. See the included cefclient and cefsimple CMakeLists.txt
# files as an example.
# E. Set the CEF_ROOT environment variable before executing CMake. For example:
# > set CEF_ROOT=c:\path\to\cef_binary_3.2704.xxxx.gyyyyyyy_windows32
# F. Comment in these lines:
#
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#
# Linux configuration.
# Load the CEF 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=hidden --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()
if(PROJECT_ARCH STREQUAL "x86_64")
# 64-bit architecture.
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_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_RESOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Resources")
set(CEF_BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_BUILD_TYPE}")
set(CEF_BINARY_DIR_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/Debug")
set(CEF_BINARY_DIR_RELEASE "${CMAKE_CURRENT_SOURCE_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()
# Execute FindCEF.cmake which must exist in CMAKE_MODULE_PATH.
find_package(CEF REQUIRED)
#
# Mac OS X configuration.
# Define CEF-based targets.
#
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")
# Include the libcef_dll_wrapper target.
# Comes from the libcef_dll/CMakeLists.txt file in the binary distribution
# directory.
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
# 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.7")
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")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
else()
set(CMAKE_OSX_ARCHITECTURES "i386")
endif()
# CEF directory paths.
set(CEF_BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/$<CONFIGURATION>")
set(CEF_BINARY_DIR_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/Debug")
set(CEF_BINARY_DIR_RELEASE "${CMAKE_CURRENT_SOURCE_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)
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
# Platform-specific compiler/linker flags.
set(CEF_LIBTYPE STATIC)
# /MP = Multiprocess compilation
# /Gy = Enable function-level linking
# /GR- = Disable run-time type information
# /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"4481" = Ignore "nonstandard extension used: override" 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- /W4 /WX /wd\"4100\" /wd\"4127\" /wd\"4244\" /wd\"4481\" /wd\"4512\" /wd\"4701\" /wd\"4702\" /wd\"4996\" ${CEF_DEBUG_INFO_FLAG}")
# /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" "ws2_32.lib")
# CEF directory paths.
set(CEF_RESOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Resources")
set(CEF_BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/$<CONFIGURATION>")
set(CEF_BINARY_DIR_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/Debug")
set(CEF_BINARY_DIR_RELEASE "${CMAKE_CURRENT_SOURCE_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
)
# Configure use of the sandbox.
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1800)
# The cef_sandbox.lib static library is currently built with VS2015. It will
# not link successfully with other VS versions.
set(USE_SANDBOX OFF)
endif()
if(USE_SANDBOX)
# Definition required by cef_sandbox.lib.
add_definitions(-DPSAPI_VERSION=1)
# Definition used by apps to test if the sandbox is enabled.
add_definitions(-DCEF_USE_SANDBOX)
# Libraries required by cef_sandbox.lib.
set(CEF_SANDBOX_STANDARD_LIBS "dbghelp.lib" "psapi.lib")
# CEF sandbox library paths.
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.lib")
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.lib")
endif()
# Configure use of ATL.
option(USE_ATL "Enable or disable use of ATL." ON)
if(USE_ATL)
# Determine if the Visual Studio install supports ATL.
get_filename_component(VC_BIN_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
get_filename_component(VC_DIR ${VC_BIN_DIR} DIRECTORY)
if(NOT IS_DIRECTORY "${VC_DIR}/atlmfc")
set(USE_ATL OFF)
endif()
endif()
if(USE_ATL)
# Definition used by apps to test if ATL support is enabled.
add_definitions(-DCEF_USE_ATL)
endif()
endif()
#
# Post-configuration actions.
#
# 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(libcef_dll)
# Include application targets.
# Comes from the <target>/CMakeLists.txt file in the current directory.
# TODO: Change these lines to match your project target when you copy this file.
add_subdirectory(cefclient)
add_subdirectory(cefsimple)
#
# 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()
if(OS_WINDOWS)
message(STATUS "CEF Windows sandbox: ${USE_SANDBOX}")
message(STATUS "Visual Studio ATL support: ${USE_ATL}")
endif()
set(LIBRARIES ${CEF_STANDARD_LIBS})
if(OS_WINDOWS AND USE_SANDBOX)
set(LIBRARIES ${LIBRARIES} ${CEF_SANDBOX_STANDARD_LIBS})
endif()
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()
PRINT_CEF_CONFIG()

39
cmake/FindCEF.cmake.in Normal file
View File

@ -0,0 +1,39 @@
# 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.
#
# This file is the CEF CMake configuration entry point and should be loaded
# using `find_package(CEF REQUIRED)`. See the top-level CMakeLists.txt file
# included with the CEF binary distribution for usage information.
#
# Find the CEF binary distribution root directory.
set(_CEF_ROOT "")
if(CEF_ROOT AND IS_DIRECTORY "${CEF_ROOT}")
set(_CEF_ROOT "${CEF_ROOT}")
set(_CEF_ROOT_EXPLICIT 1)
else()
set(_ENV_CEF_ROOT "")
if(DEFINED ENV{CEF_ROOT})
file(TO_CMAKE_PATH "$ENV{CEF_ROOT}" _ENV_CEF_ROOT)
endif()
if(_ENV_CEF_ROOT AND IS_DIRECTORY "${_ENV_CEF_ROOT}")
set(_CEF_ROOT "${_ENV_CEF_ROOT}")
set(_CEF_ROOT_EXPLICIT 1)
endif()
unset(_ENV_CEF_ROOT)
endif()
if(NOT DEFINED _CEF_ROOT_EXPLICIT)
message(FATAL_ERROR "Must specify a CEF_ROOT value via CMake or environment variable.")
endif()
if(NOT IS_DIRECTORY "${_CEF_ROOT}/cmake")
message(FATAL_ERROR "No CMake bootstrap found for CEF binary distribution at: ${CEF_ROOT}.")
endif()
# Execute additional cmake files from the CEF binary distribution.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${_CEF_ROOT}/cmake")
include("cef_variables")
include("cef_macros")

383
cmake/cef_macros.cmake.in Normal file
View File

@ -0,0 +1,383 @@
# 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.
# Must be loaded via FindCEF.cmake.
if(NOT DEFINED _CEF_ROOT_EXPLICIT)
message(FATAL_ERROR "Use find_package(CEF) to load this file.")
endif()
#
# Shared macros.
#
# Print the current CEF configuration.
macro(PRINT_CEF_CONFIG)
message(STATUS "*** CEF 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()
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
if(OS_MACOSX)
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
endif()
if(OS_WINDOWS)
message(STATUS "CEF Windows sandbox: ${USE_SANDBOX}")
message(STATUS "Visual Studio ATL support: ${USE_ATL}")
endif()
set(_libraries ${CEF_STANDARD_LIBS})
if(OS_WINDOWS AND USE_SANDBOX)
list(APPEND _libraries ${CEF_SANDBOX_STANDARD_LIBS})
endif()
message(STATUS "Standard libraries: ${_libraries}")
message(STATUS "Compile defines: ${CEF_COMPILER_DEFINES}")
message(STATUS "Compile defines (Debug): ${CEF_COMPILER_DEFINES_DEBUG}")
message(STATUS "Compile defines (Release): ${CEF_COMPILER_DEFINES_RELEASE}")
message(STATUS "C compile flags: ${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}")
message(STATUS "C compile flags (Debug): ${CEF_COMPILER_FLAGS_DEBUG} ${CEF_C_COMPILER_FLAGS_DEBUG}")
message(STATUS "C compile flags (Release): ${CEF_COMPILER_FLAGS_RELEASE} ${CEF_C_COMPILER_FLAGS_RELEASE}")
message(STATUS "C++ compile flags: ${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}")
message(STATUS "C++ compile flags (Debug): ${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}")
message(STATUS "C++ compile flags (Release): ${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}")
message(STATUS "Exe link flags: ${CEF_LINKER_FLAGS} ${CEF_EXE_LINKER_FLAGS}")
message(STATUS "Exe link flags (Debug): ${CEF_LINKER_FLAGS_DEBUG} ${CEF_EXE_LINKER_FLAGS_DEBUG}")
message(STATUS "Exe link flags (Release): ${CEF_LINKER_FLAGS_RELEASE} ${CEF_EXE_LINKER_FLAGS_RELEASE}")
message(STATUS "Shared link flags: ${CEF_LINKER_FLAGS} ${CEF_SHARED_LINKER_FLAGS}")
message(STATUS "Shared link flags (Debug): ${CEF_LINKER_FLAGS_DEBUG} ${CEF_SHARED_LINKER_FLAGS_DEBUG}")
message(STATUS "Shared link flags (Release): ${CEF_LINKER_FLAGS_RELEASE} ${CEF_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()
endmacro()
# 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()
# Determine the target output directory based on platform and generator.
macro(SET_CEF_TARGET_OUT_DIR)
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
# Ninja does not create a subdirectory named after the configuration.
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
elseif(OS_LINUX)
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
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()
# Rename a directory replacing the target if it already exists.
macro(RENAME_DIRECTORY target source_dir target_dir)
add_custom_command(
TARGET ${target}
POST_BUILD
# Remove the target directory if it already exists.
COMMAND ${CMAKE_COMMAND} -E remove_directory "${target_dir}"
# Rename the source directory to target directory.
COMMAND ${CMAKE_COMMAND} -E rename "${source_dir}" "${target_dir}"
VERBATIM
)
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)
# Convert to a list.
separate_arguments(FLL_CFLAGS)
separate_arguments(FLL_LDFLAGS)
separate_arguments(FLL_LIBS)
# Update build variables.
list(APPEND CEF_C_COMPILER_FLAGS ${FLL_CFLAGS})
list(APPEND CEF_CXX_COMPILER_FLAGS ${FLL_CFLAGS})
list(APPEND CEF_EXE_LINKER_FLAGS ${FLL_LDFLAGS})
list(APPEND CEF_SHARED_LINKER_FLAGS ${FLL_LDFLAGS})
list(APPEND CEF_STANDARD_LIBS ${FLL_LIBS})
endmacro()
# Set SUID permissions on the specified executable.
macro(SET_LINUX_SUID_PERMISSIONS target executable)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo ""
COMMAND ${CMAKE_COMMAND} -E echo "*** Run the following command manually to set SUID permissions ***"
COMMAND ${CMAKE_COMMAND} -E echo "EXE=\"${executable}\" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE"
COMMAND ${CMAKE_COMMAND} -E echo ""
VERBATIM
)
endmacro()
endif(OS_LINUX)
#
# Mac OS X macros.
#
if(OS_MACOSX)
# 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 main executable.
macro(FIX_MACOSX_MAIN_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()
# Manually process and copy over resource files.
macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path)
foreach(FILENAME ${resource_list})
# Remove one or more prefixes from the source paths.
set(TARGET_FILENAME "${FILENAME}")
foreach(PREFIX ${prefix_list})
string(REGEX REPLACE "^.*${PREFIX}" "" TARGET_FILENAME ${TARGET_FILENAME})
endforeach()
# Determine the absolute source and target paths.
set(TARGET_PATH "${app_path}/Contents/Resources/${TARGET_FILENAME}")
if(IS_ABSOLUTE ${FILENAME})
set(SOURCE_PATH ${FILENAME})
else()
set(SOURCE_PATH "${source_dir}/${FILENAME}")
endif()
if(${FILENAME} MATCHES ".xib$")
# Change the target file extension.
string(REGEX REPLACE ".xib$" ".nib" TARGET_PATH ${TARGET_PATH})
get_filename_component(TARGET_DIRECTORY ${TARGET_PATH} PATH)
add_custom_command(
TARGET ${target}
POST_BUILD
# Create the target directory.
COMMAND ${CMAKE_COMMAND} -E make_directory "${TARGET_DIRECTORY}"
# Compile the XIB file to a NIB.
COMMAND /usr/bin/ibtool --output-format binary1 --compile "${TARGET_PATH}" "${SOURCE_PATH}"
VERBATIM
)
elseif(NOT ${TARGET_FILENAME} STREQUAL "Info.plist")
# Copy the file as-is.
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${SOURCE_PATH}" "${TARGET_PATH}"
VERBATIM
)
endif()
endforeach()
endmacro()
endif(OS_MACOSX)
#
# Windows macros.
#
if(OS_WINDOWS)
# Add custom manifest files to an executable target.
macro(ADD_WINDOWS_MANIFEST manifest_path target)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "mt.exe" -nologo
-manifest \"${manifest_path}/${target}.exe.manifest\" \"${manifest_path}/compatibility.manifest\"
-outputresource:"${CEF_TARGET_OUT_DIR}/${target}.exe"\;\#1
COMMENT "Adding manifest..."
)
endmacro()
endif(OS_WINDOWS)
#
# Target configuration macros.
#
# 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()
# Set common target properties. Use SET_LIBRARY_TARGET_PROPERTIES() or
# SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly.
macro(SET_COMMON_TARGET_PROPERTIES target)
# Compile flags.
target_compile_options(${target} PUBLIC ${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS})
target_compile_options(${target} PUBLIC $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
target_compile_options(${target} PUBLIC $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
# Compile definitions.
target_compile_definitions(${target} PUBLIC ${CEF_COMPILER_DEFINES})
target_compile_definitions(${target} PUBLIC $<$<CONFIG:Debug>:${CEF_COMPILER_DEFINES_DEBUG}>)
target_compile_definitions(${target} PUBLIC $<$<CONFIG:Release>:${CEF_COMPILER_DEFINES_RELEASE}>)
# Include directories.
target_include_directories(${target} PUBLIC ${CEF_INCLUDE_PATH})
# Linker flags.
if(CEF_LINKER_FLAGS)
string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
endif()
if(CEF_LINKER_FLAGS_DEBUG)
string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_DEBUG}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
endif()
if(CEF_LINKER_FLAGS_RELEASE)
string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_RELEASE}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
endif()
if(OS_MACOSX)
# Set Xcode target properties.
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}"
)
endif()
endmacro()
# Set library-specific properties.
macro(SET_LIBRARY_TARGET_PROPERTIES target)
SET_COMMON_TARGET_PROPERTIES(${target})
# Shared library linker flags.
if(CEF_SHARED_LINKER_FLAGS)
string(REPLACE ";" " " _flags_str "${CEF_SHARED_LINKER_FLAGS}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
endif()
if(CEF_SHARED_LINKER_FLAGS_DEBUG)
string(REPLACE ";" " " _flags_str "${CEF_SHARED_LINKER_FLAGS_DEBUG}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
endif()
if(CEF_SHARED_LINKER_FLAGS_RELEASE)
string(REPLACE ";" " " _flags_str "${CEF_SHARED_LINKER_FLAGS_RELEASE}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
endif()
endmacro()
# Set executable-specific properties.
macro(SET_EXECUTABLE_TARGET_PROPERTIES target)
SET_COMMON_TARGET_PROPERTIES(${target})
# Executable linker flags.
if(CEF_EXE_LINKER_FLAGS)
string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
endif()
if(CEF_EXE_LINKER_FLAGS_DEBUG)
string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_DEBUG}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
endif()
if(CEF_EXE_LINKER_FLAGS_RELEASE)
string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_RELEASE}")
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
endif()
endmacro()

View File

@ -0,0 +1,447 @@
# 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.
# Must be loaded via FindCEF.cmake.
if(NOT DEFINED _CEF_ROOT_EXPLICIT)
message(FATAL_ERROR "Use find_package(CEF) to load this file.")
endif()
#
# Shared configuration.
#
# 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()
# Determine the build type.
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()
# Path to the include directory.
set(CEF_INCLUDE_PATH "${_CEF_ROOT}")
# Path to the libcef_dll_wrapper target.
set(CEF_LIBCEF_DLL_WRAPPER_PATH "${_CEF_ROOT}/libcef_dll")
# Shared compiler/linker flags.
list(APPEND CEF_COMPILER_DEFINES
# 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)
__STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS
)
#
# Linux configuration.
#
if(OS_LINUX)
# Platform-specific compiler/linker flags.
set(CEF_LIBTYPE SHARED)
list(APPEND CEF_COMPILER_FLAGS
-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
)
list(APPEND CEF_C_COMPILER_FLAGS
-std=c99 # Use the C99 language standard
)
list(APPEND CEF_CXX_COMPILER_FLAGS
-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
)
list(APPEND CEF_COMPILER_FLAGS_DEBUG
-O0 # Disable optimizations
-g # Generate debug information
)
list(APPEND CEF_COMPILER_FLAGS_RELEASE
-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
-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)
)
list(APPEND CEF_LINKER_FLAGS
-fPIC # Generate position-independent code for shared libraries
-pthread # Use the pthread library
-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)
)
list(APPEND CEF_LINKER_FLAGS_RELEASE
-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
)
list(APPEND CEF_COMPILER_DEFINES
_FILE_OFFSET_BITS=64 # Allow the Large File Support (LFS) interface to replace the old interface
)
list(APPEND CEF_COMPILER_DEFINES_RELEASE
NDEBUG # Not a debug build
)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
CHECK_C_COMPILER_FLAG(-Wno-unused-local-typedefs COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
if(COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
list(APPEND CEF_C_COMPILER_FLAGS
-Wno-unused-local-typedefs # Don't warn about unused local typedefs
)
endif()
CHECK_CXX_COMPILER_FLAG(-Wno-literal-suffix COMPILER_SUPPORTS_NO_LITERAL_SUFFIX)
if(COMPILER_SUPPORTS_NO_LITERAL_SUFFIX)
list(APPEND CEF_CXX_COMPILER_FLAGS
-Wno-literal-suffix # Don't warn about invalid suffixes on literals
)
endif()
CHECK_CXX_COMPILER_FLAG(-Wno-narrowing COMPILER_SUPPORTS_NO_NARROWING)
if(COMPILER_SUPPORTS_NO_NARROWING)
list(APPEND CEF_CXX_COMPILER_FLAGS
-Wno-narrowing # Don't warn about type narrowing
)
endif()
if(PROJECT_ARCH STREQUAL "x86_64")
# 64-bit architecture.
list(APPEND CEF_COMPILER_FLAGS
-m64
-march=x86-64
)
list(APPEND CEF_LINKER_FLAGS
-m64
)
elseif(PROJECT_ARCH STREQUAL "x86")
# 32-bit architecture.
list(APPEND CEF_COMPILER_FLAGS
-msse2
-mfpmath=sse
-mmmx
-m32
)
list(APPEND CEF_LINKER_FLAGS
-m32
)
endif()
# Standard libraries.
set(CEF_STANDARD_LIBS
X11
)
# CEF directory paths.
set(CEF_RESOURCE_DIR "${_CEF_ROOT}/Resources")
set(CEF_BINARY_DIR "${_CEF_ROOT}/${CMAKE_BUILD_TYPE}")
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/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 Xcode target properties in macros.cmake.
set(CEF_LIBTYPE SHARED)
list(APPEND CEF_COMPILER_FLAGS
-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
-Werror # Treat warnings as errors
-Wextra # Enable additional warnings
-Wendif-labels # Warn whenever an #else or an #endif is followed by text
-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
)
list(APPEND CEF_C_COMPILER_FLAGS
-std=c99 # Use the C99 language standard
)
list(APPEND CEF_CXX_COMPILER_FLAGS
-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
)
list(APPEND CEF_COMPILER_FLAGS_DEBUG
-O0 # Disable optimizations
-g # Generate debug information
)
list(APPEND CEF_COMPILER_FLAGS_RELEASE
-O3 # Optimize for maximum speed plus a few extras
)
list(APPEND CEF_LINKER_FLAGS
-Wl,-search_paths_first # Search for static or shared library versions in the same pass
-Wl,-ObjC # Support creation of ObjC static libraries
-Wl,-pie # Generate position-independent code suitable for executables only
)
list(APPEND CEF_LINKER_FLAGS_RELEASE
-Wl,-dead_strip # Strip dead code
)
# 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.7")
list(APPEND 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")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
else()
set(CMAKE_OSX_ARCHITECTURES "i386")
endif()
# CEF directory paths.
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/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)
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
# Platform-specific compiler/linker flags.
set(CEF_LIBTYPE STATIC)
list(APPEND CEF_COMPILER_FLAGS
/MP # Multiprocess compilation
/Gy # Enable function-level linking
/GR- # Disable run-time type information
/W4 # Warning level 4
/WX # Treat warnings as errors
/wd4100 # Ignore "unreferenced formal parameter" warning
/wd4127 # Ignore "conditional expression is constant" warning
/wd4244 # Ignore "conversion possible loss of data" warning
/wd4481 # Ignore "nonstandard extension used: override" warning
/wd4512 # Ignore "assignment operator could not be generated" warning
/wd4701 # Ignore "potentially uninitialized local variable" warning
/wd4702 # Ignore "unreachable code" warning
/wd4996 # Ignore "function or variable may be unsafe" warning
${CEF_DEBUG_INFO_FLAG}
)
list(APPEND CEF_COMPILER_FLAGS_DEBUG
/MTd # Multithreaded debug runtime
/RTC1 # Disable optimizations
/Od # Enable basic run-time checks
)
list(APPEND CEF_COMPILER_FLAGS_RELEASE
/MT # Multithreaded release runtime
/O2 # Optimize for maximum speed
/Ob2 # Inline any suitable function
/GF # Enable string pooling
)
list(APPEND CEF_LINKER_FLAGS_DEBUG
/DEBUG # Generate debug information
)
list(APPEND CEF_EXE_LINKER_FLAGS
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
)
list(APPEND CEF_COMPILER_DEFINES
WIN32 _WIN32 _WINDOWS # Windows platform
UNICODE _UNICODE # Unicode build
WINVER=0x0602 _WIN32_WINNT=0x602 # Targeting Windows 8
NOMINMAX # Use the standard's templated min/max
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
_HAS_EXCEPTIONS=0 # Disable exceptions
)
list(APPEND CEF_COMPILER_DEFINES_RELEASE
NDEBUG _NDEBUG # Not a debug build
)
# Standard libraries.
set(CEF_STANDARD_LIBS
comctl32.lib
rpcrt4.lib
shlwapi.lib
ws2_32.lib
)
# CEF directory paths.
set(CEF_RESOURCE_DIR "${_CEF_ROOT}/Resources")
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/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.
list(APPEND 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
)
# Configure use of the sandbox.
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1900)
# The cef_sandbox.lib static library is currently built with VS2015. It will
# not link successfully with other VS versions.
set(USE_SANDBOX OFF)
endif()
if(USE_SANDBOX)
list(APPEND CEF_COMPILER_DEFINES
PSAPI_VERSION=1 # Required by cef_sandbox.lib
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
)
# Libraries required by cef_sandbox.lib.
set(CEF_SANDBOX_STANDARD_LIBS
dbghelp.lib
psapi.lib
version.lib
winmm.lib
)
# CEF sandbox library paths.
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.lib")
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.lib")
endif()
# Configure use of ATL.
option(USE_ATL "Enable or disable use of ATL." ON)
if(USE_ATL)
# Determine if the Visual Studio install supports ATL.
get_filename_component(VC_BIN_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
get_filename_component(VC_DIR ${VC_BIN_DIR} DIRECTORY)
if(NOT IS_DIRECTORY "${VC_DIR}/atlmfc")
set(USE_ATL OFF)
endif()
endif()
if(USE_ATL)
list(APPEND CEF_COMPILER_DEFINES
CEF_USE_ATL # Used by apps to test if ATL support is enabled
)
endif()
endif()

View File

@ -35,6 +35,7 @@ endmacro()
'autogen_client_side',
],
}}
SET_LIBRARY_TARGET_PROPERTIES(libcef_dll_wrapper)
# Remove the default "lib" prefix from the resulting library.
set_target_properties(libcef_dll_wrapper PROPERTIES PREFIX "")

View File

@ -1,259 +0,0 @@
# 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")
# Ninja does not create a subdirectory named after the configuration.
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
elseif(OS_LINUX)
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
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()
# Rename a directory replacing the target if it already exists.
macro(RENAME_DIRECTORY target source_dir target_dir)
add_custom_command(
TARGET ${target}
POST_BUILD
# Remove the target directory if it already exists.
COMMAND ${CMAKE_COMMAND} -E remove_directory "${target_dir}"
# Rename the source directory to target directory.
COMMAND ${CMAKE_COMMAND} -E rename "${source_dir}" "${target_dir}"
VERBATIM
)
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()
# Set SUID permissions on the specified executable.
macro(SET_LINUX_SUID_PERMISSIONS target executable)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo ""
COMMAND ${CMAKE_COMMAND} -E echo "*** Run the following command manually to set SUID permissions ***"
COMMAND ${CMAKE_COMMAND} -E echo "EXE=\"${executable}\" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE"
COMMAND ${CMAKE_COMMAND} -E echo ""
VERBATIM
)
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 main executable.
macro(FIX_MACOSX_MAIN_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()
# Manually process and copy over resource files.
macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path)
foreach(FILENAME ${resource_list})
# Remove one or more prefixes from the source paths.
set(TARGET_FILENAME "${FILENAME}")
foreach(PREFIX ${prefix_list})
string(REGEX REPLACE "^.*${PREFIX}" "" TARGET_FILENAME ${TARGET_FILENAME})
endforeach()
# Determine the absolute source and target paths.
set(TARGET_PATH "${app_path}/Contents/Resources/${TARGET_FILENAME}")
if(IS_ABSOLUTE ${FILENAME})
set(SOURCE_PATH ${FILENAME})
else()
set(SOURCE_PATH "${source_dir}/${FILENAME}")
endif()
if(${FILENAME} MATCHES ".xib$")
# Change the target file extension.
string(REGEX REPLACE ".xib$" ".nib" TARGET_PATH ${TARGET_PATH})
get_filename_component(TARGET_DIRECTORY ${TARGET_PATH} PATH)
add_custom_command(
TARGET ${target}
POST_BUILD
# Create the target directory.
COMMAND ${CMAKE_COMMAND} -E make_directory "${TARGET_DIRECTORY}"
# Compile the XIB file to a NIB.
COMMAND /usr/bin/ibtool --output-format binary1 --compile "${TARGET_PATH}" "${SOURCE_PATH}"
VERBATIM
)
elseif(NOT ${TARGET_FILENAME} STREQUAL "Info.plist")
# Copy the file as-is.
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${SOURCE_PATH}" "${TARGET_PATH}"
VERBATIM
)
endif()
endforeach()
endmacro()
endif(OS_MACOSX)
#
# Windows macros.
#
if(OS_WINDOWS)
# Add custom manifest files to an executable target.
macro(ADD_WINDOWS_MANIFEST manifest_path target)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "mt.exe" -nologo
-manifest \"${manifest_path}/${target}.exe.manifest\" \"${manifest_path}/compatibility.manifest\"
-outputresource:"${CEF_TARGET_OUT_DIR}/${target}.exe"\;\#1
COMMENT "Adding manifest..."
)
endmacro()
endif(OS_WINDOWS)

View File

@ -117,6 +117,7 @@ if(OS_LINUX)
# Executable target.
add_executable(${CEF_TARGET} ${CEFCLIENT_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
@ -170,6 +171,7 @@ if(OS_MACOSX)
# Helper executable target.
add_executable(${CEF_HELPER_TARGET} MACOSX_BUNDLE ${CEFCLIENT_HELPER_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET})
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
set_target_properties(${CEF_HELPER_TARGET} PROPERTIES
@ -181,6 +183,7 @@ if(OS_MACOSX)
# Main executable target.
add_executable(${CEF_TARGET} MACOSX_BUNDLE ${CEFCLIENT_RESOURCES_SRCS} ${CEFCLIENT_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}")
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} "-framework OpenGL")
set_target_properties(${CEF_TARGET} PROPERTIES
@ -232,8 +235,9 @@ if(OS_WINDOWS)
# Executable target.
add_executable(${CEF_TARGET} WIN32 ${CEFCLIENT_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} "glu32.lib" "opengl32.lib")
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} glu32.lib opengl32.lib)
if(USE_SANDBOX)
# Logical target used to link the cef_sandbox library.

View File

@ -60,6 +60,7 @@ SET_CEF_TARGET_OUT_DIR()
if(OS_LINUX)
# Executable target.
add_executable(${CEF_TARGET} ${CEFSIMPLE_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
@ -91,6 +92,7 @@ if(OS_MACOSX)
# Helper executable target.
add_executable(${CEF_HELPER_TARGET} MACOSX_BUNDLE ${CEFSIMPLE_HELPER_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET})
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
set_target_properties(${CEF_HELPER_TARGET} PROPERTIES
@ -102,6 +104,7 @@ if(OS_MACOSX)
# Main executable target.
add_executable(${CEF_TARGET} MACOSX_BUNDLE ${CEFSIMPLE_RESOURCES_SRCS} ${CEFSIMPLE_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}")
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
set_target_properties(${CEF_TARGET} PROPERTIES
@ -144,6 +147,7 @@ if(OS_WINDOWS)
# Executable target.
add_executable(${CEF_TARGET} WIN32 ${CEFSIMPLE_SRCS})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
if(USE_SANDBOX)

View File

@ -9,6 +9,8 @@ cefsimple Contains the cefsimple sample application configured to build
using the files in this distribution. This application demonstrates
the minimal functionality required to create a browser window.
cmake Contains CMake configuration files shared by all targets.
Debug Contains libcef.so and other components required to run the debug
version of CEF-based applications. By default these files should be
placed in the same directory as the executable and will be copied

View File

@ -9,6 +9,8 @@ cefsimple Contains the cefsimple sample application configured to build
using the files in this distribution. This application demonstrates
the minimal functionality required to create a browser window.
cmake Contains CMake configuration files shared by all targets.
Debug Contains the "Chromium Embedded Framework.framework" and other
components required to run the debug version of CEF-based
applications.

View File

@ -9,6 +9,8 @@ cefsimple Contains the cefsimple sample application configured to build
using the files in this distribution. This application demonstrates
the minimal functionality required to create a browser window.
cmake Contains CMake configuration files shared by all targets.
Debug Contains libcef.dll, libcef.lib and other components required to
build and run the debug version of CEF-based applications. By
default these files should be placed in the same directory as the

View File

@ -354,9 +354,13 @@ if mode == 'standard':
cefsimple_dir = os.path.join(output_dir, 'cefsimple')
make_dir(cefsimple_dir, options.quiet)
# create the cmake directory
cmake_dir = os.path.join(output_dir, 'cmake')
make_dir(cmake_dir, options.quiet)
# create the libcef_dll_wrapper directory
wrapper_dir = os.path.join(output_dir, 'libcef_dll')
make_dir(wrapper_dir, options.quiet)
libcef_dll_dir = os.path.join(output_dir, 'libcef_dll')
make_dir(libcef_dll_dir, options.quiet)
# transfer common include files
transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \
@ -386,11 +390,11 @@ if mode == 'standard':
# transfer common libcef_dll_wrapper files
transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_base'], \
'libcef_dll/', wrapper_dir, options.quiet)
'libcef_dll/', libcef_dll_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \
'libcef_dll/', wrapper_dir, options.quiet)
'libcef_dll/', libcef_dll_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \
'libcef_dll/', wrapper_dir, options.quiet)
'libcef_dll/', libcef_dll_dir, options.quiet)
# transfer gyp files
copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet)
@ -411,17 +415,23 @@ if mode == 'standard':
process_cmake_template(os.path.join(cef_dir, 'CMakeLists.txt.in'), \
os.path.join(output_dir, 'CMakeLists.txt'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'macros.cmake.in'), \
os.path.join(output_dir, 'macros.cmake'), \
process_cmake_template(os.path.join(cef_dir, 'cmake', 'cef_macros.cmake.in'), \
os.path.join(cmake_dir, 'cef_macros.cmake'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'cmake', 'cef_variables.cmake.in'), \
os.path.join(cmake_dir, 'cef_variables.cmake'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'cmake', 'FindCEF.cmake.in'), \
os.path.join(cmake_dir, 'FindCEF.cmake'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'libcef_dll', 'CMakeLists.txt.in'), \
os.path.join(output_dir, 'libcef_dll', 'CMakeLists.txt'), \
os.path.join(libcef_dll_dir, 'CMakeLists.txt'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefclient', 'CMakeLists.txt.in'), \
os.path.join(output_dir, 'cefclient', 'CMakeLists.txt'), \
os.path.join(cefclient_dir, 'CMakeLists.txt'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefsimple', 'CMakeLists.txt.in'), \
os.path.join(output_dir, 'cefsimple', 'CMakeLists.txt'), \
os.path.join(cefsimple_dir, 'CMakeLists.txt'), \
variables, options.quiet)
if platform == 'windows':