File: shared-zlib.patch

package info (click to toggle)
lfortran 0.57.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,208 kB
  • sloc: cpp: 295,471; python: 14,442; ansic: 5,269; yacc: 2,334; f90: 761; sh: 37; makefile: 29
file content (38 lines) | stat: -rw-r--r-- 1,310 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Description: Ensure we don't include a static copy of ZLIB
Author: Alastair McKinstry <mckinstry@debian.org>
Last-Updated: 2024-01-23
Forwarded: no

--- a/src/lfortran/CMakeLists.txt
+++ b/src/lfortran/CMakeLists.txt
@@ -66,7 +66,7 @@
 
 
 if (WITH_ZLIB)
-    target_link_libraries(lfortran_lib ZLIB::ZLIB)
+    target_link_libraries(lfortran_lib p::z)
 endif()
 
 target_include_directories(lfortran_lib BEFORE PUBLIC ${lfortran_SOURCE_DIR}/src)
--- a/cmake/FindStaticZLIB.cmake
+++ b/cmake/FindStaticZLIB.cmake
@@ -1,12 +1,9 @@
-# Backup the original value of the requested library suffixes
-set(_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
-# Static libraries end with .a on Unix and .lib on Windows
-set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib)
+find_path(ZLIB_HEADER zlib.h)
 
-# Now use CMake's built-in ZLIB finder
-find_package(ZLIB REQUIRED)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_HEADER)
+
+add_library(p::z INTERFACE IMPORTED)
+set_property(TARGET p::z PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+    ${ZLIB_HEADER})
 
-# Reset the library suffixes to the original value
-set(CMAKE_FIND_LIBRARY_SUFFIXES ${_CMAKE_FIND_LIBRARY_SUFFIXES})
-# Unset the temporary to not pollute the global namespace
-unset(_CMAKE_FIND_LIBRARY_SUFFIXES)