Skip to content

Commit

Permalink
Merged pull request "Add option to compile against shared Zlib": #389
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Apr 1, 2024
2 parents 265ae83 + d0f4fd5 commit b611a5e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ ENDIF()
OPTION(CONFIG_BUILD_GLSLANG "Build glslangValidator from source instead of using the SDK" ${DEFAULT_BUILD_GLSLANG})
OPTION(CONFIG_BUILD_IPO "Enable interprocedural optimizations" OFF)
OPTION(CONFIG_BUILD_SHADER_DEBUG_INFO "Build shaders with debug info" OFF)
OPTION(USE_SYSTEM_ZLIB "Prefer system ZLIB instead of the bundled one" OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# use dynamic zlib for steam runtime
IF(CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
SET(USE_SYSTEM_ZLIB ON)
ENDIF()

include(CheckIPOSupported)

IF(CONFIG_BUILD_IPO)
Expand Down Expand Up @@ -152,6 +158,10 @@ IF(CONFIG_LINUX_PACKAGING_SUPPORT)

set(CPACK_DEBIAN_PACKAGE_DEPENDS "libvulkan1")

IF(USE_SYSTEM_ZLIB)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g")
ENDIF()

set(CPACK_DEB_PACKAGE_COMPONENT ON)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
Expand Down
12 changes: 6 additions & 6 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# ZLIB
#

if (NOT CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
if(USE_SYSTEM_ZLIB)
find_package(ZLIB REQUIRED)
else()
add_subdirectory(zlib)
target_include_directories(zlibstatic PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/zlib> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/zlib>)

Expand Down Expand Up @@ -43,7 +45,7 @@ if (IS_64_BIT)
option(SDL_TEST OFF)

if (CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
option(INPUT_TSLIB OFF)
option(INPUT_TSLIB OFF)
endif()

add_subdirectory(SDL2)
Expand All @@ -57,9 +59,7 @@ endif()
#
# CURL
#

if(CONFIG_USE_CURL)

option(BUILD_CURL_EXE "" OFF)
option(BUILD_SHARED_LIBS "" OFF)
option(CURL_STATICLIB "" ON)
Expand All @@ -72,7 +72,7 @@ if(CONFIG_USE_CURL)
set(CURL_CA_PATH "none" CACHE PATH "")

set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Override CMAKE_DEBUG_POSTFIX, which curl sets to '-d'")

set(ZLIB_DIR "{CMAKE_CURRENT_SOURCE_DIR}/zlib")

add_subdirectory(curl)
Expand Down Expand Up @@ -111,4 +111,4 @@ if (IS_64_BIT)
set_target_properties(OpenAL PROPERTIES FOLDER extern/openal-soft)
set_target_properties(common PROPERTIES FOLDER extern/openal-soft)
set_target_properties(ex-common PROPERTIES FOLDER extern/openal-soft)
endif()
endif()
28 changes: 18 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -549,25 +549,33 @@ TARGET_INCLUDE_DIRECTORIES(game PRIVATE ../inc)

IF(TARGET client)
TARGET_INCLUDE_DIRECTORIES(client PRIVATE ../inc)
TARGET_INCLUDE_DIRECTORIES(client PRIVATE "${ZLIB_INCLUDE_DIRS}")
IF(NOT USE_SYSTEM_ZLIB)
TARGET_INCLUDE_DIRECTORIES(client PRIVATE "${ZLIB_INCLUDE_DIRS}")
ENDIF()
ENDIF()

TARGET_INCLUDE_DIRECTORIES(server PRIVATE ../inc)
TARGET_INCLUDE_DIRECTORIES(server PRIVATE "${ZLIB_INCLUDE_DIRS}")

# Use dynamic zlib for steam runtime
if (CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
IF(TARGET client)
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static z)
ENDIF()
if(NOT USE_SYSTEM_ZLIB)
TARGET_INCLUDE_DIRECTORIES(server PRIVATE "${ZLIB_INCLUDE_DIRS}")
endif()

if(TARGET client)
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static)
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()
IF(TARGET client)
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static zlibstatic)
ENDIF()
TARGET_LINK_LIBRARIES(server zlibstatic)
TARGET_LINK_LIBRARIES(game zlibstatic)
if(TARGET client)
TARGET_LINK_LIBRARIES(client zlibstatic)
endif()
endif()

IF(UNIX)
Expand Down

0 comments on commit b611a5e

Please sign in to comment.