Skip to content

Commit

Permalink
Fix build failure introduced by 8df6650
Browse files Browse the repository at this point in the history
* We need absolute path for libz.a
  • Loading branch information
mtl1979 authored and Dead2 committed Sep 16, 2022
1 parent ce01b1e commit 8353094
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8353094

Please sign in to comment.