File 0001-Don-t-export-libzstd_static-CMake-target.patch of Package zstd

From f40bbc53bffb905b735c2584c80da396b7a97ed0 Mon Sep 17 00:00:00 2001
From: Christophe Marin <christophe@krop.fr>
Date: Tue, 25 Mar 2025 11:44:48 +0100
Subject: [PATCH] Don't export libzstd_static CMake target

Exporting the libzstd_static means it must be present when CMake looks for zstd, which breaks openSUSE policies.
---
 build/cmake/lib/CMakeLists.txt | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt
index 4e902a1..2ce926d 100644
--- a/build/cmake/lib/CMakeLists.txt
+++ b/build/cmake/lib/CMakeLists.txt
@@ -138,7 +138,8 @@ endif ()
 if (ZSTD_BUILD_STATIC)
     add_library(libzstd_static STATIC ${Sources} ${Headers})
     target_include_directories(libzstd_static INTERFACE $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>)
-    list(APPEND library_targets libzstd_static)
+    # The static library is not added to the array to avoid requiring it when looking for zstd
+    # list(APPEND library_targets libzstd_static)
     if (ZSTD_MULTITHREAD_SUPPORT)
         set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
         if (UNIX)
@@ -207,7 +208,7 @@ if (ZSTD_BUILD_SHARED)
             OUTPUT_NAME zstd
             VERSION ${ZSTD_FULL_VERSION}
             SOVERSION ${zstd_VERSION_MAJOR})
-            
+
     if (ZSTD_FRAMEWORK)
         set_target_properties(
                 libzstd_shared
@@ -283,6 +284,18 @@ install(TARGETS ${library_targets}
     PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
     )
 
+if(ZSTD_BUILD_STATIC)
+    install(TARGETS libzstd_static
+        INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+        ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+        LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+        RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+        BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
+        FRAMEWORK DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT runtime OPTIONAL
+        PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+        )
+endif()
+
 # uninstall target
 if (NOT TARGET uninstall)
     configure_file(
-- 
2.49.0

openSUSE Build Service is sponsored by