Update zlib CMakeLists

This commit is contained in:
Luke Street 2021-06-14 17:18:15 -04:00
parent 2aa5b76732
commit daf8bf0595
1 changed files with 41 additions and 47 deletions

View File

@ -1,15 +1,14 @@
if (APPLE)
# use toolchain zlib
find_package(ZLIB REQUIRED)
add_library(z ALIAS ZLIB::ZLIB) # alias hack to allow use from global context
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
else()
if(NOT WIN32 AND NOT NX) # remove WIN32 when specter/freetype is gone
find_library(ZLIB_LIB NAMES zlib z)
endif()
if(NOT ZLIB_LIB)
message(STATUS "Using Athena's built-in zlib")
add_library(z
# always use toolchain zlib
set(ZLIB_REQUIRED REQUIRED)
endif ()
find_package(ZLIB ${ZLIB_REQUIRED})
if (ZLIB_FOUND)
add_library(z ALIAS ZLIB::ZLIB) # alias hack to allow use from global context
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
else ()
message(STATUS "Using Athena's built-in zlib")
add_library(z
adler32.c
compress.c
crc32.c
@ -32,17 +31,12 @@ add_library(z
zconf.h
zlib.h
zutil.h)
if(WIN32 AND NOT UNIX)
install(FILES zconf.h zlib.h DESTINATION include COMPONENT zlib)
install(TARGETS z DESTINATION lib COMPONENT zlib)
else()
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
endif()
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "zlib include directory" FORCE)
else()
set(ZLIB_LIBRARIES ${ZLIB_LIB} CACHE PATH "zlib libraries" FORCE)
find_path(ZLIB_INCLUDE_DIR zlib.h PATHS "${PNG_LIB}/../../include")
message(STATUS "Using zlib at ${ZLIB_LIB}, include: ${ZLIB_INCLUDE_DIR}")
endif()
endif()
if (WIN32 AND NOT UNIX)
install(FILES zconf.h zlib.h DESTINATION include COMPONENT zlib)
install(TARGETS z DESTINATION lib COMPONENT zlib)
else ()
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
endif ()
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "zlib include directory" FORCE)
endif ()