Skip to content

Commit e58ef93

Browse files
committed
fix zlib issue reported by Karim which CI and my PC failed to spot and gave false positive, update 3rdparty/CMakeLists.txt and add cmake/FindZLIB.cmake
linker entry "zlibstatic" was generated but somehow CI didn't fail nor my PC, would need to fire verbose linker and I would find out it took it from different location, most probably - irrelevant anymore
1 parent 8453c88 commit e58ef93

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

3rdparty/CMakeLists.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ set(BUILD_TESTING OFF)
1313
option(NBL_FORCE_RELEASE_3RDPARTY "Force map 3rdaprty's configuration regardless Nabla configuration to Release" OFF)
1414
option(NBL_FORCE_RELWITHDEBINFO_3RDPARTY "Force map 3rdaprty's configuration regardless Nabla configuration to RelWithDebInfo" OFF)
1515

16+
# zlib
17+
set(ZLIB_BUILD_SHARED OFF)
18+
set(ZLIB_BUILD_STATIC ON)
19+
set(ZLIB_INSTALL OFF)
20+
set(ZLIB_BUILD_TESTING OFF)
21+
set(ZLIB_BUILD_MINIZIP OFF)
22+
add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
23+
get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR")
24+
set_target_properties(zlibstatic PROPERTIES
25+
ARCHIVE_OUTPUT_DIRECTORY $<1:${ZLIB_BINARY_DIR}>
26+
DEBUG_POSTFIX "d"
27+
RELWITHDEBINFO_POSTFIX "rwdi"
28+
OUTPUT_NAME zlibstatic
29+
)
30+
add_library(ZLIB::ZLIB ALIAS zlibstatic) # trick projects which want to use it via alias
31+
1632
# nlohmann_json
1733
set(JSON_BuildTests OFF)
1834
add_subdirectory(nlohmann_json nlohmann_json EXCLUDE_FROM_ALL)
@@ -81,21 +97,6 @@ endif()
8197
# boost
8298
add_subdirectory(boost boost EXCLUDE_FROM_ALL)
8399

84-
# zlib
85-
set(ZLIB_BUILD_SHARED OFF)
86-
set(ZLIB_BUILD_STATIC ON)
87-
set(ZLIB_INSTALL OFF)
88-
set(ZLIB_BUILD_TESTING OFF)
89-
set(ZLIB_BUILD_MINIZIP OFF)
90-
add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
91-
add_library(ZLIB::ZLIB ALIAS zlibstatic) # trick projects which want to use it
92-
get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR")
93-
set_target_properties(zlibstatic PROPERTIES
94-
ARCHIVE_OUTPUT_DIRECTORY $<1:${ZLIB_BINARY_DIR}>
95-
DEBUG_POSTFIX "d"
96-
OUTPUT_NAME zlibstatic
97-
)
98-
99100
set(SPIRV_HEADERS_SKIP_INSTALL ON CACHE INTERNAL "Skip SPIRV-Headers install")
100101
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE INTERNAL "Skip SPIRV-Headers examples")
101102
add_subdirectory("${DXC_SPIRV_HEADERS_DIR}" SPIRV-Headers EXCLUDE_FROM_ALL)

cmake/FindZLIB.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if(NOT TARGET ZLIB::ZLIB)
2+
message(FATAL_ERROR "define ZLIB::ZLIB target!")
3+
endif()
4+
5+
set(ZLIB_FOUND TRUE)
6+
set(ZLIB_LIBRARY ZLIB::ZLIB)
7+
set(ZLIB_INCLUDE_DIR "${THIRD_PARTY_SOURCE_DIR}/zlib;${THIRD_PARTY_BINARY_DIR}/zlib")

0 commit comments

Comments
 (0)