Skip to content
Snippets Groups Projects
Commit 2fc03699 authored by ezsh's avatar ezsh
Browse files

FCHost: tune build scripts

where possible (everywhere except Windows) replace copying game file
with symlinking, on Linux do the same to CEF libraries.

Remove bundled CEF modules, leave only FindCEF for CEF_ROOT var
handling.

TRy to find system CEF module first.
parent b2b5257f
No related branches found
No related tags found
1 merge request!9085Port FCHost to Linux/X11
......@@ -89,7 +89,7 @@
# Global setup.
#
cmake_minimum_required(VERSION 2.8.12.1)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# Only generate Debug and Release configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)
......@@ -123,9 +123,12 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)
# Load the CEF configuration.
#
# Execute FindCEF.cmake which must exist in CMAKE_MODULE_PATH.
find_package(CEF REQUIRED)
# try to find system installation
find_package(CEF QUIET)
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.
......
......@@ -75,6 +75,18 @@ set(FCHOST_RESOURCES_SRCS
${FCHOST_RESOURCES_MAC_ENGLISH_LPROJ_SRCS}
)
function (symlink_or_copy_to_binary_dir _target _srcFile)
get_filename_component(_fileName "${_srcFile}" NAME)
if (WIN32)
set(action copy_if_different)
else()
set(action create_symlink)
endif()
add_custom_command(POST_BUILD
TARGET ${_target}
COMMAND ${CMAKE_COMMAND} -E ${action} "${_srcFile}" "$<TARGET_FILE_DIR:${_target}>/${_fileName}"
)
endfunction()
#
# Shared configuration.
......@@ -93,14 +105,19 @@ endif()
# Determine the target output directory.
SET_CEF_TARGET_OUT_DIR()
# Executable target.
add_executable(${CEF_TARGET} MACOSX_BUNDLE WIN32 ${FCHOST_SRCS})
set(gameHTMLFile "FC_pregmod.html")
# Link the HTML where the executable expects to find it
symlink_or_copy_to_binary_dir(${CEF_TARGET} "${CMAKE_SOURCE_DIR}/../bin/${gameHTMLFile}")
#
# Linux configuration.
#
if(OS_LINUX)
# Executable target.
add_executable(${CEF_TARGET} ${FCHOST_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})
......@@ -110,11 +127,14 @@ if(OS_LINUX)
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 binary files to the target output directory.
#COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
foreach(cefBinaryFile IN LISTS CEF_BINARY_FILES)
symlink_or_copy_to_binary_dir(${CEF_TARGET} "${CEF_BINARY_DIR}/${cefBinaryFile}")
endforeach()
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}")
symlink_or_copy_to_binary_dir(${CEF_TARGET} "${CEF_BINARY_DIR}/libminigbm.so")
endif()
endif()
......@@ -152,7 +172,7 @@ if(OS_MACOSX)
)
# Main executable target.
add_executable(${CEF_TARGET} MACOSX_BUNDLE ${FCHOST_RESOURCES_SRCS} ${FCHOST_SRCS})
target_sources(${CEF_TARGET} ${FCHOST_RESOURCES_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})
......@@ -190,7 +210,6 @@ endif()
if(OS_WINDOWS)
# Executable target.
add_executable(${CEF_TARGET} WIN32 ${FCHOST_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})
......@@ -201,5 +220,4 @@ if(OS_WINDOWS)
# 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}")
COPY_FILES("${CEF_TARGET}" "FC_pregmod.html" "../../bin" "${CEF_TARGET_OUT_DIR}")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment