From 553d13572667d67732465afde53eb33e546b2851 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 11 Nov 2024 10:17:11 +0000 Subject: [PATCH] CMake: FetchContent `EXCLUDE_FROM_ALL` fixes On CMake v3.28+, `EXCLUDE_FROM_ALL` is supported natively as an argument to `FetchContent_Declare`. On CMake v3.30+, `FetchContent_Populate`, which we use to polyfill `EXCLUDE_FROM_ALL` support for older versions of CMake, is deprecated and triggers a noisy warning. Avoids the warning by using the native `EXCLUDE_FROM_ALL` support on CMake v3.28+. --- 3rdParty/Lua/CMakeLists.txt | 6 ++--- 3rdParty/SDL2/CMakeLists.txt | 6 ++--- 3rdParty/SDL_audiolib/CMakeLists.txt | 6 ++--- 3rdParty/SDL_image/CMakeLists.txt | 6 ++--- 3rdParty/asio/CMakeLists.txt | 6 ++--- 3rdParty/benchmark/CMakeLists.txt | 6 ++--- 3rdParty/bzip2/CMakeLists.txt | 6 ++--- 3rdParty/discord/CMakeLists.txt | 8 +++--- 3rdParty/find_steam_game/CMakeLists.txt | 6 ++--- 3rdParty/googletest/CMakeLists.txt | 6 ++--- 3rdParty/libfmt/CMakeLists.txt | 6 ++--- 3rdParty/libmpq/CMakeLists.txt | 6 ++--- 3rdParty/libpng/CMakeLists.txt | 6 ++--- 3rdParty/libsmackerdec/CMakeLists.txt | 6 ++--- 3rdParty/libsodium/CMakeLists.txt | 6 ++--- 3rdParty/libzt/CMakeLists.txt | 6 ++--- 3rdParty/sol2/CMakeLists.txt | 6 ++--- 3rdParty/tolk/CMakeLists.txt | 6 ++--- 3rdParty/unordered_dense/CMakeLists.txt | 8 +++--- 3rdParty/zlib/CMakeLists.txt | 6 ++--- ...FetchContent_ExcludeFromAll_backport.cmake | 25 +++++++++++++++++++ ...hContent_MakeAvailableExcludeFromAll.cmake | 14 ----------- CMake/platforms/mingw/zt_defs.cmake | 6 ++--- 23 files changed, 90 insertions(+), 79 deletions(-) create mode 100644 CMake/functions/FetchContent_ExcludeFromAll_backport.cmake delete mode 100644 CMake/functions/FetchContent_MakeAvailableExcludeFromAll.cmake diff --git a/3rdParty/Lua/CMakeLists.txt b/3rdParty/Lua/CMakeLists.txt index 4d998ad303f..2689c093c17 100644 --- a/3rdParty/Lua/CMakeLists.txt +++ b/3rdParty/Lua/CMakeLists.txt @@ -1,4 +1,4 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) set(LUA_ENABLE_TESTING OFF) set(LUA_BUILD_COMPILER OFF) @@ -9,11 +9,11 @@ else() endif() include(FetchContent) -FetchContent_Declare(Lua +FetchContent_Declare_ExcludeFromAll(Lua URL https://github.com/walterschell/Lua/archive/88246d621abf7b6fba9332f49229d507f020e450.tar.gz URL_HASH MD5=03b76927cb5341ffc53bea12c37ddcca ) -FetchContent_MakeAvailableExcludeFromAll(Lua) +FetchContent_MakeAvailable_ExcludeFromAll(Lua) if(ANDROID AND ("${ANDROID_ABI}" STREQUAL "armeabi-v7a" OR "${ANDROID_ABI}" STREQUAL "x86")) target_compile_definitions(lua_internal INTERFACE -DLUA_USE_C89) diff --git a/3rdParty/SDL2/CMakeLists.txt b/3rdParty/SDL2/CMakeLists.txt index d566192ef6d..9e0e70ed8f4 100644 --- a/3rdParty/SDL2/CMakeLists.txt +++ b/3rdParty/SDL2/CMakeLists.txt @@ -12,10 +12,10 @@ else() endif() set(SDL_TEST_ENABLED_BY_DEFAULT OFF) -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(SDL2 +FetchContent_Declare_ExcludeFromAll(SDL2 URL https://github.com/libsdl-org/SDL/releases/download/release-2.30.9/SDL2-2.30.9.tar.gz URL_HASH SHA256=24b574f71c87a763f50704bbb630cbe38298d544a1f890f099a4696b1d6beba4 ) -FetchContent_MakeAvailableExcludeFromAll(SDL2) +FetchContent_MakeAvailable_ExcludeFromAll(SDL2) diff --git a/3rdParty/SDL_audiolib/CMakeLists.txt b/3rdParty/SDL_audiolib/CMakeLists.txt index b5a9c0931f0..9f411cb077e 100644 --- a/3rdParty/SDL_audiolib/CMakeLists.txt +++ b/3rdParty/SDL_audiolib/CMakeLists.txt @@ -1,4 +1,4 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) if(DEVILUTIONX_STATIC_SDL_AUDIOLIB) set(BUILD_SHARED_LIBS OFF) @@ -37,10 +37,10 @@ set(USE_DEC_ADLMIDI OFF) set(USE_DEC_DRMP3 ON) include(FetchContent) -FetchContent_Declare(SDL_audiolib +FetchContent_Declare_ExcludeFromAll(SDL_audiolib URL https://github.com/realnc/SDL_audiolib/archive/cc1bb6af8d4cf5e200259072bde1edd1c8c5137e.tar.gz URL_HASH MD5=0e8174264ac9c6b314c6b2d9a5f72efd) -FetchContent_MakeAvailableExcludeFromAll(SDL_audiolib) +FetchContent_MakeAvailable_ExcludeFromAll(SDL_audiolib) add_library(SDL_audiolib::SDL_audiolib ALIAS SDL_audiolib) diff --git a/3rdParty/SDL_image/CMakeLists.txt b/3rdParty/SDL_image/CMakeLists.txt index 957029adc14..722f5d85390 100644 --- a/3rdParty/SDL_image/CMakeLists.txt +++ b/3rdParty/SDL_image/CMakeLists.txt @@ -16,14 +16,14 @@ else() add_subdirectory(../libpng libpng) endif() -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(SDL_image +FetchContent_Declare_ExcludeFromAll(SDL_image URL https://github.com/libsdl-org/SDL_image/archive/refs/tags/release-2.0.5.tar.gz URL_HASH MD5=3446ed7ee3c700065dcb33426a9b0c6e ) -FetchContent_MakeAvailableExcludeFromAll(SDL_image) +FetchContent_MakeAvailable_ExcludeFromAll(SDL_image) if(DEVILUTIONX_STATIC_SDL_IMAGE) add_library(SDL_image STATIC ${CMAKE_CURRENT_LIST_DIR}/IMG.c ${sdl_image_SOURCE_DIR}/IMG_png.c) diff --git a/3rdParty/asio/CMakeLists.txt b/3rdParty/asio/CMakeLists.txt index ac8b0d15b62..ce0249d1b0a 100644 --- a/3rdParty/asio/CMakeLists.txt +++ b/3rdParty/asio/CMakeLists.txt @@ -1,11 +1,11 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(asio +FetchContent_Declare_ExcludeFromAll(asio URL https://github.com/diasurgical/asio/archive/4bcf552fcea3e1ae555dde2ab33bc9fa6770da4d.tar.gz URL_HASH MD5=7ffee993fc21b1115abf485958d03ac8 ) -FetchContent_MakeAvailableExcludeFromAll(asio) +FetchContent_MakeAvailable_ExcludeFromAll(asio) add_library(asio STATIC ${CMAKE_CURRENT_LIST_DIR}/asio_handle_exception.cpp) target_compile_definitions(asio PUBLIC ASIO_NO_EXCEPTIONS) diff --git a/3rdParty/benchmark/CMakeLists.txt b/3rdParty/benchmark/CMakeLists.txt index 558d571aece..f145fcc8889 100644 --- a/3rdParty/benchmark/CMakeLists.txt +++ b/3rdParty/benchmark/CMakeLists.txt @@ -1,6 +1,6 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) -FetchContent_Declare( +FetchContent_Declare_ExcludeFromAll( benchmark URL https://github.com/google/benchmark/archive/refs/tags/v1.8.5.tar.gz URL_HASH MD5=708d91ce255e8af4c1d7dfec50dff178 @@ -13,4 +13,4 @@ set(BENCHMARK_ENABLE_EXCEPTIONS OFF) set(BENCHMARK_ENABLE_WERROR OFF) set(BENCHMARK_ENABLE_INSTALL OFF) -FetchContent_MakeAvailable(benchmark) +FetchContent_MakeAvailable_ExcludeFromAll(benchmark) diff --git a/3rdParty/bzip2/CMakeLists.txt b/3rdParty/bzip2/CMakeLists.txt index 796856ec363..8fc611de59a 100644 --- a/3rdParty/bzip2/CMakeLists.txt +++ b/3rdParty/bzip2/CMakeLists.txt @@ -1,11 +1,11 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(bzip2 +FetchContent_Declare_ExcludeFromAll(bzip2 URL https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz URL_HASH MD5=67e051268d0c475ea773822f7500d0e5 ) -FetchContent_MakeAvailableExcludeFromAll(bzip2) +FetchContent_MakeAvailable_ExcludeFromAll(bzip2) if(DEVILUTIONX_STATIC_BZIP2) set(_lib_type STATIC) diff --git a/3rdParty/discord/CMakeLists.txt b/3rdParty/discord/CMakeLists.txt index 01401881337..3fcdd8578a5 100644 --- a/3rdParty/discord/CMakeLists.txt +++ b/3rdParty/discord/CMakeLists.txt @@ -1,4 +1,4 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) find_package(Patch REQUIRED) @@ -7,18 +7,18 @@ set(Discord_SDK_URL "https://dl-game-sdk.discordapp.net/3.2.1/discord_game_sdk.z set(Discord_SDK_HASH "73e5e1b3f8413a2c7184ef17476822f2") if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - FetchContent_Declare(discordsrc + FetchContent_Declare_ExcludeFromAll(discordsrc URL ${Discord_SDK_URL} URL_HASH MD5=${Discord_SDK_HASH} ) else() - FetchContent_Declare(discordsrc + FetchContent_Declare_ExcludeFromAll(discordsrc URL ${Discord_SDK_URL} URL_HASH MD5=${Discord_SDK_HASH} PATCH_COMMAND "${Patch_EXECUTABLE}" -p1 -N < "${CMAKE_CURRENT_LIST_DIR}/fixes.patch" || true ) endif() -FetchContent_MakeAvailableExcludeFromAll(discordsrc) +FetchContent_MakeAvailable_ExcludeFromAll(discordsrc) file(GLOB discord_SRCS ${discordsrc_SOURCE_DIR}/cpp/*.cpp) add_library(discord STATIC ${discord_SRCS}) diff --git a/3rdParty/find_steam_game/CMakeLists.txt b/3rdParty/find_steam_game/CMakeLists.txt index ae5c7e6b828..b0df870cb38 100644 --- a/3rdParty/find_steam_game/CMakeLists.txt +++ b/3rdParty/find_steam_game/CMakeLists.txt @@ -1,11 +1,11 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(find_steam_game +FetchContent_Declare_ExcludeFromAll(find_steam_game URL https://github.com/cxong/find_steam_game/archive/a2bd6273fc002214052c2ee3bd48d7c1e7d3f366.tar.gz URL_HASH MD5=a6950ce5d9ced8a259752bc2dc7f5311 ) -FetchContent_MakeAvailableExcludeFromAll(find_steam_game) +FetchContent_MakeAvailable_ExcludeFromAll(find_steam_game) add_library(find_steam_game INTERFACE) target_include_directories(find_steam_game INTERFACE ${find_steam_game_SOURCE_DIR}) diff --git a/3rdParty/googletest/CMakeLists.txt b/3rdParty/googletest/CMakeLists.txt index be170aaf00d..ed3463cf2e9 100644 --- a/3rdParty/googletest/CMakeLists.txt +++ b/3rdParty/googletest/CMakeLists.txt @@ -1,6 +1,6 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) -FetchContent_Declare( +FetchContent_Declare_ExcludeFromAll( googletest URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz URL_HASH MD5=c8340a482851ef6a3fe618a082304cfc @@ -11,6 +11,6 @@ set(INSTALL_GTEST OFF) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(googletest) +FetchContent_MakeAvailable_ExcludeFromAll(googletest) add_library(GTest::gtest ALIAS gmock) diff --git a/3rdParty/libfmt/CMakeLists.txt b/3rdParty/libfmt/CMakeLists.txt index 6269400c05a..25fc4b29a9d 100644 --- a/3rdParty/libfmt/CMakeLists.txt +++ b/3rdParty/libfmt/CMakeLists.txt @@ -1,4 +1,4 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) if(NOT WIN32 AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD) # Enable POSIX extensions such as `readlink` and `ftruncate`. @@ -15,11 +15,11 @@ else() set(BUILD_SHARED_LIBS ON) endif() include(FetchContent) -FetchContent_Declare(libfmt +FetchContent_Declare_ExcludeFromAll(libfmt URL https://github.com/fmtlib/fmt/archive/02537548f3a9efb5f3b83755acf50c8a16ba58c8.tar.gz URL_HASH MD5=6901c6945cd311117d96baaa6d067380 ) -FetchContent_MakeAvailableExcludeFromAll(libfmt) +FetchContent_MakeAvailable_ExcludeFromAll(libfmt) # We do not use locale-specific features of libfmt and disabling them reduces the size. target_compile_definitions(fmt PUBLIC FMT_USE_LOCALE=0) diff --git a/3rdParty/libmpq/CMakeLists.txt b/3rdParty/libmpq/CMakeLists.txt index ca263ed63b3..ad6cd4ad227 100644 --- a/3rdParty/libmpq/CMakeLists.txt +++ b/3rdParty/libmpq/CMakeLists.txt @@ -6,14 +6,14 @@ if(NOT TARGET BZip2::BZip2) find_package(BZip2 REQUIRED) endif() -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(libmpq +FetchContent_Declare_ExcludeFromAll(libmpq URL https://github.com/diasurgical/libmpq/archive/7c2924d4553513eba1a70bbdb558198dd8c2726a.tar.gz URL_HASH MD5=315c88c02b45851cdfee8460322de044 ) -FetchContent_MakeAvailableExcludeFromAll(libmpq) +FetchContent_MakeAvailable_ExcludeFromAll(libmpq) add_library(libmpq STATIC ${libmpq_SOURCE_DIR}/libmpq/common.c diff --git a/3rdParty/libpng/CMakeLists.txt b/3rdParty/libpng/CMakeLists.txt index b0d291f920e..ff5994b1eba 100644 --- a/3rdParty/libpng/CMakeLists.txt +++ b/3rdParty/libpng/CMakeLists.txt @@ -1,4 +1,4 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) if(NOT DISABLE_LTO) # Force CMake to raise an error if INTERPROCEDURAL_OPTIMIZATION @@ -24,11 +24,11 @@ if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") endif() include(FetchContent) -FetchContent_Declare(libpng +FetchContent_Declare_ExcludeFromAll(libpng URL https://github.com/glennrp/libpng/archive/0a158f3506502dfa23edfc42790dfaed82efba17.tar.gz URL_HASH MD5=6d705417242732e8e081bff752c98c18 ) -FetchContent_MakeAvailableExcludeFromAll(libpng) +FetchContent_MakeAvailable_ExcludeFromAll(libpng) target_include_directories(${PNG_LIBRARY} INTERFACE $ diff --git a/3rdParty/libsmackerdec/CMakeLists.txt b/3rdParty/libsmackerdec/CMakeLists.txt index d5cf319d785..4a8c18e8e10 100644 --- a/3rdParty/libsmackerdec/CMakeLists.txt +++ b/3rdParty/libsmackerdec/CMakeLists.txt @@ -1,11 +1,11 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(libsmackerdec +FetchContent_Declare_ExcludeFromAll(libsmackerdec URL https://github.com/diasurgical/libsmackerdec/archive/91e732bb6953489077430572f43fc802bf2c75b2.tar.gz URL_HASH MD5=c3b1ecbe702266e149b158178a03e2b3 ) -FetchContent_MakeAvailableExcludeFromAll(libsmackerdec) +FetchContent_MakeAvailable_ExcludeFromAll(libsmackerdec) add_library(libsmackerdec STATIC ${libsmackerdec_SOURCE_DIR}/src/BitReader.cpp diff --git a/3rdParty/libsodium/CMakeLists.txt b/3rdParty/libsodium/CMakeLists.txt index 9e308d9d0f9..534f8a87aca 100644 --- a/3rdParty/libsodium/CMakeLists.txt +++ b/3rdParty/libsodium/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT DEVILUTIONX_SYSTEM_LIBSODIUM) - include(functions/FetchContent_MakeAvailableExcludeFromAll) + include(functions/FetchContent_ExcludeFromAll_backport) set(SODIUM_MINIMAL ON) set(SODIUM_ENABLE_BLOCKING_RANDOM OFF) @@ -11,9 +11,9 @@ if(NOT DEVILUTIONX_SYSTEM_LIBSODIUM) set(BUILD_SHARED_LIBS ON) endif() include(FetchContent) - FetchContent_Declare(libsodium + FetchContent_Declare_ExcludeFromAll(libsodium GIT_REPOSITORY https://github.com/robinlinden/libsodium-cmake.git GIT_TAG a8ac4509b22b84d6c2eb7d7448f08678e4a67da6 ) - FetchContent_MakeAvailableExcludeFromAll(libsodium) + FetchContent_MakeAvailable_ExcludeFromAll(libsodium) endif() diff --git a/3rdParty/libzt/CMakeLists.txt b/3rdParty/libzt/CMakeLists.txt index 4f968fa7c2a..d9d09ea022f 100644 --- a/3rdParty/libzt/CMakeLists.txt +++ b/3rdParty/libzt/CMakeLists.txt @@ -1,12 +1,12 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) set(BUILD_HOST_SELFTEST OFF) include(FetchContent) -FetchContent_Declare(libzt +FetchContent_Declare_ExcludeFromAll(libzt GIT_REPOSITORY https://github.com/diasurgical/libzt.git GIT_TAG db7b642a4ce9f0f5e0ba7f293bd7ffa7897e4831) -FetchContent_MakeAvailableExcludeFromAll(libzt) +FetchContent_MakeAvailable_ExcludeFromAll(libzt) if(NOT ANDROID) set(libzt_LIB_NAME zt-static) diff --git a/3rdParty/sol2/CMakeLists.txt b/3rdParty/sol2/CMakeLists.txt index ce74ecd5e03..80a0ec1493c 100644 --- a/3rdParty/sol2/CMakeLists.txt +++ b/3rdParty/sol2/CMakeLists.txt @@ -1,13 +1,13 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) set(SOL2_ENABLE_INSTALL OFF) include(FetchContent) -FetchContent_Declare(sol2 +FetchContent_Declare_ExcludeFromAll(sol2 URL https://github.com/ThePhD/sol2/archive/9c882a28fdb6f4ad79a53a4191b43ce48a661175.tar.gz URL_HASH MD5=2637c3fcdcce3ff34b36437c1d3b99d1 ) -FetchContent_MakeAvailableExcludeFromAll(sol2) +FetchContent_MakeAvailable_ExcludeFromAll(sol2) target_include_directories(sol2 SYSTEM BEFORE INTERFACE ${CMAKE_CURRENT_LIST_DIR}/sol_config) target_compile_definitions(sol2 INTERFACE SOL_NO_EXCEPTIONS=1) diff --git a/3rdParty/tolk/CMakeLists.txt b/3rdParty/tolk/CMakeLists.txt index 9b4cee23ce5..94e7c284741 100644 --- a/3rdParty/tolk/CMakeLists.txt +++ b/3rdParty/tolk/CMakeLists.txt @@ -1,11 +1,11 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) -FetchContent_Declare(Tolk +FetchContent_Declare_ExcludeFromAll(Tolk URL https://github.com/sig-a11y/tolk/archive/89de98779e3b6365dc1688538d5de4ecba3fdbab.tar.gz URL_HASH MD5=724f6022186573dd9c5c2c92ed9e21e6 ) -FetchContent_MakeAvailableExcludeFromAll(Tolk) +FetchContent_MakeAvailable_ExcludeFromAll(Tolk) target_include_directories(Tolk PUBLIC ${libTolk_SOURCE_DIR}/src) diff --git a/3rdParty/unordered_dense/CMakeLists.txt b/3rdParty/unordered_dense/CMakeLists.txt index f80c8cfa5e9..006a0fca42a 100644 --- a/3rdParty/unordered_dense/CMakeLists.txt +++ b/3rdParty/unordered_dense/CMakeLists.txt @@ -1,4 +1,4 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) include(FetchContent) set(unordered_dense_URL "https://github.com/martinus/unordered_dense/archive/refs/tags/v4.4.0.tar.gz") @@ -6,15 +6,15 @@ set(unordered_dense_HASH "f33c294a010540434b272754f937decf") if(MINGW_CROSS) find_package(Patch REQUIRED) - FetchContent_Declare(unordered_dense + FetchContent_Declare_ExcludeFromAll(unordered_dense URL ${unordered_dense_URL} URL_HASH MD5=${unordered_dense_HASH} PATCH_COMMAND "${Patch_EXECUTABLE}" -p1 -N < "${CMAKE_CURRENT_LIST_DIR}/0001-Disable-PMR-support-for-mingw-std-threads-compat.patch" || true ) else() - FetchContent_Declare(unordered_dense + FetchContent_Declare_ExcludeFromAll(unordered_dense URL ${unordered_dense_URL} URL_HASH MD5=${unordered_dense_HASH} ) endif() -FetchContent_MakeAvailableExcludeFromAll(unordered_dense) +FetchContent_MakeAvailable_ExcludeFromAll(unordered_dense) diff --git a/3rdParty/zlib/CMakeLists.txt b/3rdParty/zlib/CMakeLists.txt index 7d5d5838fff..d5d5ab8d3c7 100644 --- a/3rdParty/zlib/CMakeLists.txt +++ b/3rdParty/zlib/CMakeLists.txt @@ -1,15 +1,15 @@ -include(functions/FetchContent_MakeAvailableExcludeFromAll) +include(functions/FetchContent_ExcludeFromAll_backport) set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) include(FetchContent) -FetchContent_Declare(zlib +FetchContent_Declare_ExcludeFromAll(zlib URL https://www.zlib.net/zlib-1.3.tar.gz https://www.zlib.net/fossils/zlib-1.3.tar.gz https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz URL_HASH MD5=60373b133d630f74f4a1f94c1185a53f ) -FetchContent_MakeAvailableExcludeFromAll(zlib) +FetchContent_MakeAvailable_ExcludeFromAll(zlib) if(DEVILUTIONX_STATIC_ZLIB) add_library(ZLIB::ZLIB ALIAS zlibstatic) diff --git a/CMake/functions/FetchContent_ExcludeFromAll_backport.cmake b/CMake/functions/FetchContent_ExcludeFromAll_backport.cmake new file mode 100644 index 00000000000..d0a8302b01b --- /dev/null +++ b/CMake/functions/FetchContent_ExcludeFromAll_backport.cmake @@ -0,0 +1,25 @@ +if(CMAKE_VERSION VERSION_LESS "3.28.0") + macro(FetchContent_Declare_ExcludeFromAll) + FetchContent_Declare(${ARGV}) + endmacro() + # Like `FetchContent_MakeAvailable` but passes EXCLUDE_FROM_ALL to `add_subdirectory`. + macro(FetchContent_MakeAvailable_ExcludeFromAll) + foreach(name ${ARGV}) + string(TOLOWER ${name} nameLower) + FetchContent_GetProperties(${name}) + if(NOT ${${nameLower}_POPULATED}) + FetchContent_Populate(${name}) + if(EXISTS ${${nameLower}_SOURCE_DIR}/CMakeLists.txt) + add_subdirectory(${${nameLower}_SOURCE_DIR} ${${nameLower}_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() + endif() + endforeach() + endmacro() +else() + macro(FetchContent_Declare_ExcludeFromAll) + FetchContent_Declare(${ARGV} EXCLUDE_FROM_ALL) + endmacro() + macro(FetchContent_MakeAvailable_ExcludeFromAll) + FetchContent_MakeAvailable(${ARGV}) + endmacro() +endif() diff --git a/CMake/functions/FetchContent_MakeAvailableExcludeFromAll.cmake b/CMake/functions/FetchContent_MakeAvailableExcludeFromAll.cmake deleted file mode 100644 index fe6d34bccc4..00000000000 --- a/CMake/functions/FetchContent_MakeAvailableExcludeFromAll.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# Like `FetchContent_MakeAvailable` but passes EXCLUDE_FROM_ALL to `add_subdirectory`. -macro(FetchContent_MakeAvailableExcludeFromAll) - foreach(contentName IN ITEMS ${ARGV}) - string(TOLOWER ${contentName} contentNameLower) - FetchContent_GetProperties(${contentName}) - if(NOT ${contentNameLower}_POPULATED) - FetchContent_Populate(${contentName}) - if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt) - add_subdirectory(${${contentNameLower}_SOURCE_DIR} - ${${contentNameLower}_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() - endif() - endforeach() -endmacro() diff --git a/CMake/platforms/mingw/zt_defs.cmake b/CMake/platforms/mingw/zt_defs.cmake index 6410ea5e0fc..434cd3fa995 100644 --- a/CMake/platforms/mingw/zt_defs.cmake +++ b/CMake/platforms/mingw/zt_defs.cmake @@ -1,9 +1,9 @@ option(MINGW_STDTHREADS_GENERATE_STDHEADERS "" ON) -FetchContent_Declare(mingw-std-threads +FetchContent_Declare_ExcludeFromAll(mingw-std-threads GIT_REPOSITORY https://github.com/meganz/mingw-std-threads GIT_TAG bee085c0a6cb32c59f0b55c7bba976fe6dcfca7f) -FetchContent_MakeAvailableExcludeFromAll(mingw-std-threads) +FetchContent_MakeAvailable_ExcludeFromAll(mingw-std-threads) target_compile_definitions(libnatpmp_obj PRIVATE -D_WIN32_WINNT=0x601 -DSTATICLIB) target_compile_definitions(zto_obj PRIVATE -D_WIN32_WINNT=0x601) @@ -13,4 +13,4 @@ target_compile_definitions(zt_pic PRIVATE -D_WIN32_WINNT=0x601) target_compile_definitions(${libzt_LIB_NAME} PRIVATE -D_WIN32_WINNT=0x601 -DADD_EXPORTS=1) target_compile_definitions(${libzt_LIB_NAME} PUBLIC -DADD_EXPORTS=1) target_link_libraries(libzt_obj PRIVATE mingw_stdthreads) -target_link_libraries(${libzt_LIB_NAME} mingw_stdthreads) \ No newline at end of file +target_link_libraries(${libzt_LIB_NAME} mingw_stdthreads)