]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Fix zstd build for older CMake versions
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 29 May 2024 18:54:31 +0000 (20:54 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 29 May 2024 19:03:50 +0000 (21:03 +0200)
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)

cmake/FindZstd.cmake

index 5622b2dd103430acf819caeef86424ce28d6495d..662c1f3e37bf70e9c8362dcdb3d1cc70a4962b01 100644 (file)
@@ -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: