mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-01-19 05:04:08 +01:00
019611c764
Under ARC (Automatic Reference Counting), assigning to an Objective-C pointer has different semantics than assigning to a void* pointer. This makes it dangerous to treat the same memory address as an Objective-C pointer in some cases and as a "regular C pointer" in other cases. This change removes the conditional type defines and instead uses void* everywhere. Explicit type casting in combination with ARC annotations makes it safe to get typed Objective-C pointers from the void* pointers. This change enables ARC by default in the CEF binary distribution CMake configuration for the cefclient and cefsimple sample applications. It can be disabled by adding `-DOPTION_USE_ARC=Off` to the CMake command line. ARC is not supported when building Chromium due to the substantial number of changes that would be required in the Chromium code base.
180 lines
6.0 KiB
CMake
180 lines
6.0 KiB
CMake
# 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.
|
|
#
|
|
|
|
# cefsimple sources.
|
|
{{
|
|
'prefix': 'cefsimple',
|
|
'set': 'CEFSIMPLE_SRCS',
|
|
'includes': [
|
|
'cefsimple_sources_common',
|
|
'cefsimple_sources_win:WINDOWS',
|
|
'cefsimple_sources_mac:MACOSX',
|
|
'cefsimple_sources_linux:LINUX',
|
|
],
|
|
}}
|
|
|
|
# cefsimple helper sources.
|
|
{{
|
|
'prefix': 'cefsimple_helper',
|
|
'includes': [
|
|
'cefsimple_sources_mac_helper:MACOSX',
|
|
],
|
|
}}
|
|
|
|
# cefsimple resources.
|
|
{{
|
|
'prefix': 'cefsimple_resources',
|
|
'set': 'CEFSIMPLE_RESOURCES_SRCS',
|
|
'includes': [
|
|
'cefsimple_bundle_resources_mac:MACOSX',
|
|
],
|
|
}}
|
|
|
|
|
|
#
|
|
# Shared configuration.
|
|
#
|
|
|
|
# Target executable names.
|
|
set(CEF_TARGET "cefsimple")
|
|
if(OS_MACOSX)
|
|
set(CEF_HELPER_TARGET "cefsimple_Helper")
|
|
set(CEF_HELPER_OUTPUT_NAME "cefsimple Helper")
|
|
else()
|
|
# Logical target used to link the libcef library.
|
|
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
|
|
endif()
|
|
|
|
# Determine the target output directory.
|
|
SET_CEF_TARGET_OUT_DIR()
|
|
|
|
|
|
#
|
|
# Linux configuration.
|
|
#
|
|
|
|
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})
|
|
|
|
# Set rpath so that libraries can be placed next to the executable.
|
|
set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
|
|
set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
|
set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
|
|
|
|
# Copy binary and resource files to the target output directory.
|
|
COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
|
|
COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
|
|
if (EXISTS "${CEF_BINARY_DIR}/libminigbm.so")
|
|
COPY_FILES("${CEF_TARGET}" "libminigbm.so" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
|
|
endif()
|
|
|
|
# Set SUID permissions on the chrome-sandbox target.
|
|
SET_LINUX_SUID_PERMISSIONS("${CEF_TARGET}" "${CEF_TARGET_OUT_DIR}/chrome-sandbox")
|
|
endif()
|
|
|
|
|
|
#
|
|
# Mac OS X configuration.
|
|
#
|
|
|
|
if(OS_MACOSX)
|
|
option(OPTION_USE_ARC "Build with ARC (automatic Reference Counting) on macOS." ON)
|
|
if(OPTION_USE_ARC)
|
|
list(APPEND CEF_COMPILER_FLAGS
|
|
-fobjc-arc
|
|
)
|
|
set_target_properties(${target} PROPERTIES
|
|
CLANG_ENABLE_OBJC_ARC "YES"
|
|
)
|
|
endif()
|
|
|
|
# Output paths for the app bundles.
|
|
set(CEF_APP "${CEF_TARGET_OUT_DIR}/${CEF_TARGET}.app")
|
|
set(CEF_HELPER_APP "${CEF_TARGET_OUT_DIR}/${CEF_HELPER_OUTPUT_NAME}.app")
|
|
|
|
# Variable referenced from Info.plist files.
|
|
set(PRODUCT_NAME "${CEF_TARGET}")
|
|
|
|
# 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_dll_wrapper ${CEF_STANDARD_LIBS})
|
|
set_target_properties(${CEF_HELPER_TARGET} PROPERTIES
|
|
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist
|
|
OUTPUT_NAME ${CEF_HELPER_OUTPUT_NAME}
|
|
)
|
|
|
|
if(USE_SANDBOX)
|
|
# Logical target used to link the cef_sandbox library.
|
|
ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
|
|
target_link_libraries(${CEF_HELPER_TARGET} cef_sandbox_lib)
|
|
endif()
|
|
|
|
# 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_dll_wrapper ${CEF_STANDARD_LIBS})
|
|
set_target_properties(${CEF_TARGET} PROPERTIES
|
|
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist
|
|
)
|
|
|
|
# Copy files into the main app bundle.
|
|
add_custom_command(
|
|
TARGET ${CEF_TARGET}
|
|
POST_BUILD
|
|
# Copy the helper app bundle into the Frameworks directory.
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
"${CEF_HELPER_APP}"
|
|
"${CEF_APP}/Contents/Frameworks/${CEF_HELPER_OUTPUT_NAME}.app"
|
|
# Copy the CEF framework into the Frameworks directory.
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
"${CEF_BINARY_DIR}/Chromium Embedded Framework.framework"
|
|
"${CEF_APP}/Contents/Frameworks/Chromium Embedded Framework.framework"
|
|
VERBATIM
|
|
)
|
|
|
|
# Manually process and copy over resource files.
|
|
# The Xcode generator can support this via the set_target_properties RESOURCE
|
|
# directive but that doesn't properly handle nested resource directories.
|
|
# Remove these prefixes from input file paths.
|
|
set(PREFIXES "mac/")
|
|
COPY_MACOSX_RESOURCES("${CEFSIMPLE_RESOURCES_SRCS}" "${PREFIXES}" "${CEF_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_APP}")
|
|
endif()
|
|
|
|
|
|
#
|
|
# Windows configuration.
|
|
#
|
|
|
|
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)
|
|
# Logical target used to link the cef_sandbox library.
|
|
ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
|
|
target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS})
|
|
endif()
|
|
|
|
# Add the custom manifest files to the executable.
|
|
ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_TARGET}" "exe")
|
|
|
|
# Copy binary and resource files to the target output directory.
|
|
COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
|
|
COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
|
|
endif()
|