Skip to content

Commit

Permalink
Always provide a target 'z' for zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
res2k committed Apr 17, 2024
1 parent 6c871ee commit 74467db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
7 changes: 7 additions & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/zlib> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/zlib>)
Expand All @@ -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()

#
Expand Down
23 changes: 4 additions & 19 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 74467db

Please sign in to comment.