From 915493bc3a4383ac21f239043e7162b13da170ed Mon Sep 17 00:00:00 2001 From: Cayleb-Ordo Date: Thu, 2 Apr 2026 22:39:14 +0200 Subject: [PATCH] Add a module to fetch and setup Windows prebuild libraries This module downloads the given svn revision based on the current architecture selected. It also sets up the `CMAKE_PREFIX_PATH`. Add new option to disable fetching, which assumes that the libraries are already in the correct folders. --- CMakeLists.txt | 10 ++++++++++ cmake/SetupWindowsLibs.cmake | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 cmake/SetupWindowsLibs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 628b22ef88..f9f7100ab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,11 @@ option(without-nvtt "Disable use of NVTT") option(without-pch "Disable generation and usage of precompiled headers") option(without-tests "Disable generation of test projects") +# Windows specific options +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + option(fetch-prebuild-libs "Fetch prebuild libraries from SVN. Defaults to ON." ON) +endif() + # OS X specific options if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") option(macosx-version-min "Set minimum required version of the OS X API, the build will possibly fail if an older SDK is used, while newer API functions will be weakly linked (i.e. resolved at runtime)") @@ -134,3 +139,8 @@ endif() # Include the BuildFlags target only once after all setup is finished include(0ad-BuildFlags) + +# +++++++++++++++++++++ Windows specific ++++++++++++++++++++ +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + include(SetupWindowsLibs) +endif() diff --git a/cmake/SetupWindowsLibs.cmake b/cmake/SetupWindowsLibs.cmake new file mode 100644 index 0000000000..50bcd43c76 --- /dev/null +++ b/cmake/SetupWindowsLibs.cmake @@ -0,0 +1,33 @@ +# Checks out the SVN Revision of windows libraries. Additionally sets up the environment for cmake. +# To update the libraries change the 'SVN_REVISION'. Important: the '-r' in the Revision must be retained. +message(STATUS "Fetching Windows prebuild Libraries for ${ARCH}") +if(fetch-prebuild-libs) + include(FetchContent) + if(ARCH STREQUAL "amd64") + set(REPO_NAME windows-libs-amd64) + else() + set(REPO_NAME windows-libs) + endif() + + FetchContent_Populate( + prebuild_libs + SVN_REPOSITORY https://svn.wildfiregames.com/public/${REPO_NAME}/trunk + SVN_REVISION -r28278 + SOURCE_DIR ${0AD_EXT_LIBDIR} + ) +endif() +message(STATUS "Copy dependencies' binaries to 'binaries/system/' and adding to 'CMAKE_PREFIX_PATH'") +set(DIR_LIST cpp-httplib enet fcollada freetype gloox iconv icu libcurl libpng libsodium libxml2 microsoft miniupnpc nvtt openal sdl2 spidermonkey vorbis zlib) +foreach(dir ${DIR_LIST}) + file(COPY ${0AD_EXT_LIBDIR}/${dir}/bin DESTINATION ${CMAKE_SOURCE_DIR}/binaries/system) + list(APPEND CMAKE_PREFIX_PATH ${0AD_EXT_LIBDIR}/${dir}) +endforeach() +# Add the whole libraries directory to CMAKE_PREFIX_PATH. May be redundand but needed for wxWidgets +list(APPEND CMAKE_PREFIX_PATH ${0AD_EXT_LIBDIR}) +# Add libraries not set during binary copy +list(APPEND CMAKE_PREFIX_PATH ${0AD_EXT_LIBDIR}/fmt) +list(APPEND CMAKE_PREFIX_PATH ${0AD_EXT_LIBDIR}/libzip) +list(APPEND CMAKE_PREFIX_PATH ${0AD_EXT_LIBDIR}/cxxtest-4.4) + +message(STATUS "Copy build tools to 'build/bin'") +file(COPY ${0AD_EXT_LIBDIR}/cxxtest-4.4/bin DESTINATION ${CMAKE_SOURCE_DIR}/build/bin)