Files
conan-center-index/recipes/libspng/all/patches/0.7.3-0002-allow-miniz.patch
2022-12-14 02:05:09 +01:00

65 lines
2.0 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fff5d68..5ed4ad0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,7 @@ set(SPNG_VERSION ${SPNG_MAJOR}.${SPNG_MINOR}.${SPNG_REVISION})
option(ENABLE_OPT "Enable architecture-specific optimizations" ON)
option(SPNG_SHARED "Build shared lib" ON)
option(SPNG_STATIC "Build static lib" ON)
+option(SPNG_USE_MINIZ "Use Miniz instead of zlib" OFF)
option(BUILD_EXAMPLES "Build examples" ON)
include(GNUInstallDirs)
@@ -21,15 +22,19 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")
cmake_policy(SET CMP0074 NEW)
endif()
-find_package(ZLIB REQUIRED)
-include_directories(${ZLIB_INCLUDE_DIRS})
+if(SPNG_USE_MINIZ)
+ find_package(miniz REQUIRED)
+ set(spng_LIBS miniz::miniz)
+else()
+ find_package(ZLIB REQUIRED)
+ set(spng_LIBS ZLIB::ZLIB)
+endif()
set(spng_SOURCES spng/spng.c)
-if(NOT CMAKE_HOST_WIN32)
- set(spng_LIBS -lm ${ZLIB_LIBRARIES})
-else()
- set(spng_LIBS ${ZLIB_LIBRARIES})
+find_library(LIBM NAMES m)
+if(LIBM)
+ list(APPEND spng_LIBS ${LIBM})
endif()
if(NOT ENABLE_OPT)
@@ -39,7 +44,10 @@ endif()
if(SPNG_SHARED)
add_library(spng SHARED ${spng_SOURCES})
target_include_directories(spng PUBLIC ${PROJECT_SOURCE_DIR}/spng)
- target_link_libraries(spng ${spng_LIBS})
+ target_link_libraries(spng PRIVATE ${spng_LIBS})
+ if(SPNG_USE_MINIZ)
+ target_compile_definitions(spng PRIVATE SPNG_USE_MINIZ)
+ endif()
install(
TARGETS spng
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -56,7 +64,12 @@ endif()
if(SPNG_STATIC)
add_library(spng_static STATIC ${spng_SOURCES})
- target_include_directories(spng PUBLIC ${PROJECT_SOURCE_DIR}/spng)
+ target_link_libraries(spng_static PRIVATE ${spng_LIBS})
+ if(SPNG_USE_MINIZ)
+ target_compile_definitions(spng_static PRIVATE SPNG_USE_MINIZ)
+ endif()
+
+ target_include_directories(spng_static PUBLIC ${PROJECT_SOURCE_DIR}/spng)
target_compile_definitions(spng_static PUBLIC SPNG_STATIC)
install(TARGETS spng_static DESTINATION lib)
endif()