]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix build failure introduced by 8df665005952cdbe7dc995d409ffe4f861e7a83e
authorMika Lindqvist <postmaster@raasu.org>
Sun, 11 Sep 2022 15:57:02 +0000 (18:57 +0300)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 16 Sep 2022 15:50:51 +0000 (17:50 +0200)
* We need absolute path for libz.a

.github/workflows/link.yml
test/CMakeLists.txt

index 806a934112dcc89d926a68439a4932d020dde1bf..0ac4f5cff411a864bdc55cdf9e197fcef81fafbd 100644 (file)
@@ -21,7 +21,7 @@ jobs:
       run: cmake --build zlib/build --config Release
 
     - name: Generate project files (native)
-      run: cmake -S . -B native -DZLIB_COMPAT=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DZLIB_LIBRARIES=../zlib/build/libz.a -DZLIB_INCLUDE_DIR=../zlib/build
+      run: cmake -S . -B native -DZLIB_COMPAT=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DZLIB_LIBRARIES=../zlib/build/libz.a -DZLIB_INCLUDE_DIR="../zlib/build;../zlib"
 
     - name: Compile source code (native)
       run: cmake --build native --config Release
index 51d1cf0840ac37d005b23adfdaf4c1f92553d9f7..ad002d9cefc03b4b81535fbcd9fde87b7a3fc71e 100644 (file)
@@ -180,14 +180,24 @@ else()
             -fsanitize-memory-track-origins)
     endif()
 
-    if(NOT ZLIB_COMPAT AND DEFINED ZLIB_INCLUDE_DIR AND DEFINED ZLIB_LIBRARIES)
+    if(NOT ZLIB_COMPAT AND DEFINED ZLIB_LIBRARIES AND DEFINED ZLIB_INCLUDE_DIR)
+        if(NOT IS_ABSOLUTE ${ZLIB_LIBRARIES})
+            get_filename_component(ZLIB_ABSOLUTE_PATH
+                "${CMAKE_CURRENT_SOURCE_DIR}/${ZLIB_LIBRARIES}"
+                ABSOLUTE)
+        else()
+            set(ZLIB_ABSOLUTE_PATH ${ZLIB_LIBRARIES})
+        endif()
+
+        add_library(external_zlib STATIC IMPORTED)
+        set_property(TARGET external_zlib PROPERTY IMPORTED_LOCATION ${ZLIB_ABSOLUTE_PATH})
         message(STATUS "Added dual linking tests against zlib")
         message(STATUS "  Zlib include dir: ${ZLIB_INCLUDE_DIR}")
-        message(STATUS "  Zlib libraries: ${ZLIB_LIBRARIES}")
+        message(STATUS "  Zlib libraries: ${ZLIB_ABSOLUTE_PATH}")
 
         target_sources(gtest_zlib PRIVATE test_compress_dual.cc)
         target_include_directories(gtest_zlib PRIVATE ${ZLIB_INCLUDE_DIR})
-        target_link_libraries(gtest_zlib ${ZLIB_LIBRARIES})
+        target_link_libraries(gtest_zlib external_zlib)
     endif()
 
     target_link_libraries(gtest_zlib zlibstatic GTest::GTest)