diff options
author | TheLastRar <TheLastRar@users.noreply.github.com> | 2023-01-23 19:03:12 +0000 |
---|---|---|
committer | TheLastRar <TheLastRar@users.noreply.github.com> | 2023-01-23 22:36:26 +0000 |
commit | 322f317a5b4908348b92f65a611f474382f83069 (patch) | |
tree | 5d7a235cb3769d42cd5c7e2b74b0b74fe0f09ee3 /CMakeLists.txt | |
parent | cefa1662ef822323940fabc18fc48bee1937eb4f (diff) | |
download | PrismLauncher-322f317a5b4908348b92f65a611f474382f83069.tar.gz PrismLauncher-322f317a5b4908348b92f65a611f474382f83069.tar.bz2 PrismLauncher-322f317a5b4908348b92f65a611f474382f83069.zip |
fix: Undo zlibs file rename when using bundled zlib
Signed-off-by: TheLastRar <TheLastRar@users.noreply.github.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f32a73d1..37bb49ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,8 +391,18 @@ if(FORCE_BUNDLED_ZLIB) set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # Suppress cmake warnings and allow INTERPROCEDURAL_OPTIMIZATION for zlib set(SKIP_INSTALL_ALL ON) add_subdirectory(libraries/zlib EXCLUDE_FROM_ALL) - - set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib" "${CMAKE_CURRENT_BINARY_DIR}/libraries/zlib" CACHE STRING "" FORCE) + + # On OS where unistd.h exists, zlib's generated header defines `Z_HAVE_UNISTD_H`, while the included header does not. + # We cannot safely undo the rename on those systems, and they generally have packages for zlib anyway. + check_include_file(unistd.h NEED_GENERATED_ZCONF) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib/zconf.h.included" AND NOT NEED_GENERATED_ZCONF) + # zlib's cmake script renames a file, dirtying the submodule, see https://github.com/madler/zlib/issues/162 + message(STATUS "Undoing Rename") + message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib/zconf.h") + file(RENAME "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib/zconf.h.included" "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib/zconf.h") + endif() + + set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libraries/zlib" "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib" CACHE STRING "" FORCE) set_target_properties(zlibstatic PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}") add_library(ZLIB::ZLIB ALIAS zlibstatic) set(ZLIB_LIBRARY ZLIB::ZLIB CACHE STRING "zlib library name") |