Skip to content

Commit a29d2f8

Browse files
zlib...
1 parent fee4a55 commit a29d2f8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ set(ZLIB_LIBRARIES zlibstatic CACHE STRING "" FORCE)
185185

186186
# Create ZLIB::ZLIB alias target pointing to the actual zlibstatic target
187187
# This lets CMake handle the actual library path and build dependencies automatically
188-
add_library(ZLIB::ZLIB ALIAS zlibstatic)
188+
# Only create the alias if zlibstatic target exists (i.e., we're using bundled zlib)
189+
if(TARGET zlibstatic)
190+
add_library(ZLIB::ZLIB ALIAS zlibstatic)
191+
endif()
189192

190193
# Bundled libarchive
191194
set(ENABLE_WERROR OFF CACHE BOOL "")
@@ -687,9 +690,21 @@ else()
687690
install(FILES icons/openhdimagewriter.png DESTINATION share/pixmaps)
688691
endif()
689692

690-
add_dependencies(${PROJECT_NAME} ZLIB::ZLIB)
693+
# Add dependency on ZLIB only if we're using bundled zlib
694+
if(TARGET ZLIB::ZLIB)
695+
add_dependencies(${PROJECT_NAME} ZLIB::ZLIB)
696+
endif()
691697
include_directories(${CURL_INCLUDE_DIR} ${LibArchive_INCLUDE_DIR} ${LIBLZMA_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${ZSTD_INCLUDE_DIR})
692698

699+
# Set up ZLIB library variable for linking
700+
if(TARGET ZLIB::ZLIB)
701+
set(ZLIB_LINK_TARGET ZLIB::ZLIB)
702+
else()
703+
# Use system zlib via FindZLIB results
704+
find_package(ZLIB REQUIRED)
705+
set(ZLIB_LINK_TARGET ${ZLIB_LIBRARIES})
706+
endif()
707+
693708
if(WIN32)
694709
# Maximum static linking for MinGW to minimize external dependencies
695710
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -699,7 +714,7 @@ if(WIN32)
699714
# Prefer static libraries on Windows
700715
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib" ".dll.a")
701716
endif()
702-
target_link_libraries(${PROJECT_NAME} PRIVATE ${QT}::Core ${QT}::Quick ${QT}::Svg ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} ${ZSTD_LIBRARIES} ${LIBLZMA_LIBRARIES} ZLIB::ZLIB ${ATOMIC_LIBRARY} ${EXTRALIBS} crypt32 secur32 bcrypt)
717+
target_link_libraries(${PROJECT_NAME} PRIVATE ${QT}::Core ${QT}::Quick ${QT}::Svg ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} ${ZSTD_LIBRARIES} ${LIBLZMA_LIBRARIES} ${ZLIB_LINK_TARGET} ${ATOMIC_LIBRARY} ${EXTRALIBS} crypt32 secur32 bcrypt)
703718
else()
704-
target_link_libraries(${PROJECT_NAME} PRIVATE ${QT}::Core ${QT}::Quick ${QT}::Svg ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} ${ZSTD_LIBRARIES} ${LIBLZMA_LIBRARIES} ZLIB::ZLIB ${ATOMIC_LIBRARY} ${EXTRALIBS})
719+
target_link_libraries(${PROJECT_NAME} PRIVATE ${QT}::Core ${QT}::Quick ${QT}::Svg ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} ${ZSTD_LIBRARIES} ${LIBLZMA_LIBRARIES} ${ZLIB_LINK_TARGET} ${ATOMIC_LIBRARY} ${EXTRALIBS})
705720
endif()

0 commit comments

Comments
 (0)