From 74467db24e5254bddedb2ce95ac0c427b9ea588d Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 17 Apr 2024 22:09:29 +0200 Subject: [PATCH] Always provide a target 'z' for zlib --- extern/CMakeLists.txt | 7 +++++++ src/CMakeLists.txt | 23 ++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index e8edea14a..cb003b530 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -5,6 +5,9 @@ if(USE_SYSTEM_ZLIB) find_package(ZLIB REQUIRED) + + add_library(z INTERFACE IMPORTED GLOBAL) + target_link_libraries(z INTERFACE ZLIB::ZLIB) else() add_subdirectory(zlib) target_include_directories(zlibstatic PUBLIC $ $) @@ -13,6 +16,10 @@ else() set_target_properties(zlibstatic PROPERTIES FOLDER extern POSITION_INDEPENDENT_CODE ON) set_target_properties(minigzip PROPERTIES FOLDER extern) set_target_properties(example PROPERTIES FOLDER extern) + + add_library(z INTERFACE IMPORTED GLOBAL) + target_link_libraries(z INTERFACE zlibstatic) + target_include_directories(z INTERFACE "${ZLIB_INCLUDE_DIRS}") endif() # diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa5e85eeb..feaa33d7a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -549,9 +549,6 @@ TARGET_INCLUDE_DIRECTORIES(game PRIVATE ../inc) IF(TARGET client) TARGET_INCLUDE_DIRECTORIES(client PRIVATE ../inc) - IF(NOT USE_SYSTEM_ZLIB) - TARGET_INCLUDE_DIRECTORIES(client PRIVATE "${ZLIB_INCLUDE_DIRS}") - ENDIF() ENDIF() TARGET_INCLUDE_DIRECTORIES(server PRIVATE ../inc) @@ -564,22 +561,10 @@ if(TARGET client) endif() endif() -if(NOT USE_SYSTEM_ZLIB) - TARGET_INCLUDE_DIRECTORIES(server PRIVATE "${ZLIB_INCLUDE_DIRS}") -endif() - -if(USE_SYSTEM_ZLIB) - TARGET_LINK_LIBRARIES(server z) - TARGET_LINK_LIBRARIES(game z) - if(TARGET client) - TARGET_LINK_LIBRARIES(client z) - endif() -else() - TARGET_LINK_LIBRARIES(server zlibstatic) - TARGET_LINK_LIBRARIES(game zlibstatic) - if(TARGET client) - TARGET_LINK_LIBRARIES(client zlibstatic) - endif() +TARGET_LINK_LIBRARIES(server z) +TARGET_LINK_LIBRARIES(game z) +if(TARGET client) + TARGET_LINK_LIBRARIES(client z) endif() IF(UNIX)