From: Joel Rosdahl Date: Wed, 29 May 2024 18:54:31 +0000 (+0200) Subject: build: Fix zstd build for older CMake versions X-Git-Tag: v4.10~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=536a632924f4d6543d802833b60127108abb19d2;p=thirdparty%2Fccache.git build: Fix zstd build for older CMake versions With CMake 3.17.5 on CentOS7: -- Downloading Zstd from the internet since Zstd>=1.3.4 was not found locally and DEPS=AUTO CMake Error at cmake/FindZstd.cmake:60 (set_target_properties): set_target_properties Can not find target to add properties to: libzstd_static Call Stack (most recent call first): cmake/Dependencies.cmake:29 (find_package) CMakeLists.txt:88 (include) CMake Error at cmake/FindZstd.cmake:68 (add_library): add_library cannot create ALIAS target "dep_zstd" because target "libzstd_static" does not already exist. Call Stack (most recent call first): cmake/Dependencies.cmake:29 (find_package) CMakeLists.txt:88 (include) --- diff --git a/cmake/FindZstd.cmake b/cmake/FindZstd.cmake index 5622b2dd..662c1f3e 100644 --- a/cmake/FindZstd.cmake +++ b/cmake/FindZstd.cmake @@ -53,7 +53,13 @@ if(_download_zstd) SOURCE_SUBDIR build/cmake ${_zstd_patch} ) - FetchContent_MakeAvailable(Zstd) + + # When it works: Use FetchContent_MakeAvailable(Zstd) instead + FetchContent_GetProperties(zstd) + if(NOT zstd_POPULATED) + FetchContent_Populate(Zstd) + add_subdirectory("${zstd_SOURCE_DIR}/build/cmake" "${zstd_BINARY_DIR}" EXCLUDE_FROM_ALL) + endif() # Workaround until https://github.com/facebook/zstd/pull/3968 is included in a # release: