diff --git a/FCHost/CMakeLists.txt b/FCHost/CMakeLists.txt index 6384b09898bcdf1c8f46633dedc581cc3a6b7c71..c279663bf3fe00b144c25995d99f873c10c860e1 100644 --- a/FCHost/CMakeLists.txt +++ b/FCHost/CMakeLists.txt @@ -105,45 +105,73 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON) # -# CEF_ROOT setup. -# This variable must be set to locate the binary distribution. -# +# CEF configuration. +# + +# Specify the CEF distribution version. +# Visit https://cef-builds.spotifycdn.com/index.html for the list of +# supported platforms and versions. +set(CEF_VERSION "126.2.11+gb281f7a+chromium-126.0.6478.127") + +# Determine the platform. +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + if("${PROJECT_ARCH}" STREQUAL "arm64") + set(CEF_PLATFORM "macosarm64") + elseif("${PROJECT_ARCH}" STREQUAL "x86_64") + set(CEF_PLATFORM "macosx64") + elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64") + set(PROJECT_ARCH "arm64") + set(CEF_PLATFORM "macosarm64") + else() + set(PROJECT_ARCH "x86_64") + set(CEF_PLATFORM "macosx64") + endif() +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm") + set(CEF_PLATFORM "linuxarm") + elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") + set(CEF_PLATFORM "linuxarm64") + elseif(CMAKE_SIZEOF_VOID_P MATCHES 8) + set(CEF_PLATFORM "linux64") + else() + message(FATAL_ERROR "Linux x86 32-bit builds are discontinued.") + endif() +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") + if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM64") + set(CEF_PLATFORM "windowsarm64") + elseif(CMAKE_SIZEOF_VOID_P MATCHES 8) + set(CEF_PLATFORM "windows64") + else() + set(CEF_PLATFORM "windows32") + endif() +endif() -# The binary distribution is in a separate directory from your -# project. Locate the binary distribution using the CEF_ROOT -# environment variable. -# -# Set the CEF_ROOT environment variable before executing CMake. For example: -# > set CEF_ROOT=c:\path\to\cef_binary_3.2704.xxxx.gyyyyyyy_windows32 -# -# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +# Add this project's cmake/ directory to the module path. +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +# Download and extract the CEF binary distribution (executes DownloadCEF.cmake). +include(DownloadCEF) +DownloadCEF("${CEF_PLATFORM}" "${CEF_VERSION}" "${CMAKE_SOURCE_DIR}/libs") -# -# Load the CEF configuration. -# +# Add the CEF binary distribution's cmake/ directory to the module path. +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake") -# try to find system installation -find_package(CEF QUIET) +# Load the CEF configuration (executes FindCEF.cmake). +find_package(CEF REQUIRED) -if(NOT DEFINED _CEF_ROOT_EXPLICIT) # if that fails, try the standard way - include("${CMAKE_CURRENT_LIST_DIR}/cmake/FindCEF.cmake") -endif() # # Define CEF-based targets. # # 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) +# Allow includes relative to the current source directory. +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + # Include application targets. -# Comes from the <target>/CMakeLists.txt file in the current directory. -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fchost") - add_subdirectory(fchost) -endif() +add_subdirectory(fchost) # Display configuration settings. PRINT_CEF_CONFIG() diff --git a/FCHost/cmake/DownloadCEF.cmake b/FCHost/cmake/DownloadCEF.cmake new file mode 100644 index 0000000000000000000000000000000000000000..deb10ba9bcbb13d990c01aa855258894f31acab4 --- /dev/null +++ b/FCHost/cmake/DownloadCEF.cmake @@ -0,0 +1,48 @@ +# 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. + +# Download the CEF binary distribution for |platform| and |version| to +# |download_dir|. The |CEF_ROOT| variable will be set in global scope pointing +# to the extracted location. +# Visit https://cef-builds.spotifycdn.com/index.html for the list of +# supported platforms and versions. + +function(DownloadCEF platform version download_dir) + # Specify the binary distribution type and download directory. + set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}") + set(CEF_DOWNLOAD_DIR "${download_dir}") + + # The location where we expect the extracted binary distribution. + set(CEF_ROOT "${CEF_DOWNLOAD_DIR}/${CEF_DISTRIBUTION}" CACHE INTERNAL "CEF_ROOT") + + # Download and/or extract the binary distribution if necessary. + if(NOT IS_DIRECTORY "${CEF_ROOT}") + set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2") + set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}") + if(NOT EXISTS "${CEF_DOWNLOAD_PATH}") + set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}") + string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL}) + + # Download the SHA1 hash for the binary distribution. + message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...") + file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1") + file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1) + + # Download the binary distribution and verify the hash. + message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...") + file( + DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}" + EXPECTED_HASH SHA1=${CEF_SHA1} + SHOW_PROGRESS + ) + endif() + + # Extract the binary distribution. + message(STATUS "Extracting ${CEF_DOWNLOAD_PATH}...") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}" + WORKING_DIRECTORY ${CEF_DOWNLOAD_DIR} + ) + endif() +endfunction() \ No newline at end of file diff --git a/FCHost/cmake/FindCEF.cmake b/FCHost/cmake/FindCEF.cmake deleted file mode 100644 index cd33a7ddad40a52f4c7bdac62812f8c0d1a22760..0000000000000000000000000000000000000000 --- a/FCHost/cmake/FindCEF.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# 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")