Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to compile against shared Zlib #389

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace tab with 4 spaces

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
Loading