48 lines
1.7 KiB
CMake
48 lines
1.7 KiB
CMake
# cmake/FetchDependenciesServer.cmake
|
|
#
|
|
# Downloads only what the headless GameServer needs (Eigen + Boost headers).
|
|
# Skips anything already present in thirdparty/. Works on Windows and Linux.
|
|
|
|
set(THIRDPARTY_DIR "${CMAKE_CURRENT_LIST_DIR}/../thirdparty")
|
|
file(MAKE_DIRECTORY "${THIRDPARTY_DIR}")
|
|
|
|
macro(server_check_and_download URL ARCHIVE_NAME EXTRACTED_DIR_NAME CHECK_FILE)
|
|
set(_archive_path "${THIRDPARTY_DIR}/${ARCHIVE_NAME}")
|
|
set(_src_path "${THIRDPARTY_DIR}/${EXTRACTED_DIR_NAME}")
|
|
|
|
if(NOT EXISTS "${_src_path}/${CHECK_FILE}")
|
|
if(NOT EXISTS "${_archive_path}")
|
|
message(STATUS "Downloading ${ARCHIVE_NAME}...")
|
|
file(DOWNLOAD "${URL}" "${_archive_path}"
|
|
SHOW_PROGRESS STATUS _dl_status)
|
|
list(GET _dl_status 0 _dl_code)
|
|
if(NOT _dl_code EQUAL 0)
|
|
file(REMOVE "${_archive_path}")
|
|
message(FATAL_ERROR "Failed to download ${URL}: ${_dl_status}")
|
|
endif()
|
|
endif()
|
|
message(STATUS "Extracting ${ARCHIVE_NAME}...")
|
|
execute_process(
|
|
COMMAND ${CMAKE_COMMAND} -E tar xf "${_archive_path}"
|
|
WORKING_DIRECTORY "${THIRDPARTY_DIR}"
|
|
RESULT_VARIABLE _tar_res)
|
|
if(NOT _tar_res EQUAL 0)
|
|
message(FATAL_ERROR "Failed to extract ${_archive_path}")
|
|
endif()
|
|
endif()
|
|
endmacro()
|
|
|
|
# Eigen: only needed if no system install is available.
|
|
find_package(Eigen3 3.3 CONFIG QUIET)
|
|
if(NOT TARGET Eigen3::Eigen)
|
|
server_check_and_download(
|
|
"https://gitlab.com/libeigen/eigen/-/archive/5.0.0/eigen-5.0.0.zip"
|
|
"eigen-5.0.0.zip" "eigen-5.0.0" "signature_of_eigen3_matrix_library")
|
|
endif()
|
|
|
|
# Boost (header-only usage: asio + beast). Use bundled copy always so the
|
|
# version matches the Windows build.
|
|
server_check_and_download(
|
|
"https://archives.boost.io/release/1.90.0/source/boost_1_90_0.zip"
|
|
"boost_1_90_0.zip" "boost_1_90_0" "boost/asio.hpp")
|