Fix zlib on master
But png_static project doesn't have a path to configuration zconf.h files
It's weird, because path to it is placed in COMMON_INCLUDE_DIRS though,
and both Irrlicht and IrrlichtServer projects see it, but png_static doesn't
MODIFY
3rdparty/CMakeLists.txt
3rdparty/CMakeLists.txt
@@ -35,6 +35,22 @@ update_git_submodule(./glm)
update_git_submodule(./freetype2)
update_git_submodule(./portable-file-dialogs)
+# zlib (target is zlibstatic)
+set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL})
+set(BUILD_SHARED_LIBS OFF)
+set(SKIP_INSTALL_ALL ON)
+add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
+set(SKIP_INSTALL_ALL ${_OLD_SKIP_INSTALL_ALL})
+set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS})
+get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR")
+get_target_property(ZLIB_NAME zlibstatic "NAME")
+get_target_property(ZLIB_DEBUG_POSTFIX zlibstatic "DEBUG_POSTFIX")
+#message(FATAL_ERROR ${THIRD_PARTY_SOURCE_DIR})
+set(ZLIB_INCLUDE_DIR "${THIRD_PARTY_SOURCE_DIR}/zlib;${THIRD_PARTY_BINARY_DIR}/zlib" CACHE STRING "" FORCE)
+# This probably breaks the non-MSVC build in like 50 different ways
+set(ZLIB_LIBRARY_DEBUG "${ZLIB_BINARY_DIR}/Debug/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${ZLIB_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "" FORCE)
+set(ZLIB_LIBRARY_RELEASE "${ZLIB_BINARY_DIR}/Release/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "" FORCE)
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE BOOL "Skip SPIRV-Headers examples")
@@ -71,29 +87,14 @@ add_subdirectory(libjpeg libjpeg EXCLUDE_FROM_ALL)
#manipulating libpng cmake options from within cmake script
option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
-set(PNG_BUILD_ZLIB ON)
-set(ZLIB_INCLUDE_DIR ${THIRD_PARTY_SOURCE_DIR}/zlib) #for pnglib
-set(ZLIB_LIBRARY "$<TARGET_OBJECTS:zlib>") #for pnglib
+set(PNG_BUILD_ZLIB OFF)
option(PNG_SHARED "Build shared lib" OFF)
option(PNG_TESTS "Build libpng tests" OFF)
add_subdirectory(libpng libpng EXCLUDE_FROM_ALL)
-add_dependencies(png_static zlib) #CMake doesn't get it itself
+add_dependencies(png_static zlibstatic) #CMake doesn't get it itself
irr_adjust_flags()
-add_library(zlib OBJECT
- zlib/adler32.c
- zlib/crc32.c
- zlib/deflate.c
- zlib/infback.c
- zlib/inffast.c
- zlib/inflate.c
- zlib/inftrees.c
- zlib/trees.c
- zlib/uncompr.c
- #zlib/zcompress.c
- zlib/zutil.c
-)
add_library(lzma OBJECT
lzma/C/Alloc.c
lzma/C/LzFind.c

MODIFY
source/Irrlicht/CMakeLists.txt
source/Irrlicht/CMakeLists.txt
@@ -202,6 +202,7 @@ set(IRRLICHT_SRCS_SERVER
set(COMMON_INCLUDE_DIRS
${THIRD_PARTY_SOURCE_DIR}/convertutf
${THIRD_PARTY_SOURCE_DIR}/utfcpp/source
+ $<TARGET_PROPERTY:zlibstatic,BINARY_DIR> #for dynamically generated zconf.h
$<TARGET_PROPERTY:png_static,BINARY_DIR> #for dynamically generated pnglibconf.h
$<TARGET_PROPERTY:jpeg,BINARY_DIR> #for dynamically generated jconfig.h
)
@@ -209,6 +210,13 @@ set(COMMON_INCLUDE_DIRS
irr_adjust_flags() # macro defined in root CMakeLists
irr_adjust_definitions() # macro defined in root CMakeLists
+macro(irr_target_link_zlib _trgt)
+ add_dependencies(${_trgt} zlibstatic)
+ target_link_libraries(${_trgt} INTERFACE
+ zlibstatic
+ )
+ target_include_directories(${_trgt} PUBLIC ${THIRD_PARTY_SOURCE_DIR}/zlib)
+endmacro()
macro(irr_target_link_openssl _trgt)
if(WIN32)
target_link_libraries(${_trgt} INTERFACE
@@ -262,6 +270,7 @@ add_library(Irrlicht STATIC
)
add_dependencies(Irrlicht openssl_build)
+irr_target_link_zlib(Irrlicht)
irr_target_link_openssl(Irrlicht)
irr_target_link_shaderc(Irrlicht)
irr_target_link_libjpeg(Irrlicht)
@@ -334,10 +343,10 @@ add_library(IrrlichtServer STATIC
$<TARGET_OBJECTS:convert_utf>
$<TARGET_OBJECTS:lz4>
$<TARGET_OBJECTS:lzma>
- $<TARGET_OBJECTS:zlib>
)
add_dependencies(IrrlichtServer openssl_build)
+irr_target_link_zlib(IrrlichtServer)
irr_target_link_openssl(IrrlichtServer)
irr_target_link_shaderc(IrrlichtServer)
irr_target_link_libjpeg(IrrlichtServer)

Fix zlib on master

But png_static project doesn't have a path to configuration zconf.h files
It's weird, because path to it is placed in COMMON_INCLUDE_DIRS though,
and both Irrlicht and IrrlichtServer projects see it, but png_static doesn't