(#14694) libspng: add version 0.7.3

This commit is contained in:
toge
2022-12-14 10:05:09 +09:00
committed by GitHub
parent 35ceabffc9
commit 42625c65c0
5 changed files with 99 additions and 1 deletions

View File

@@ -1,8 +1,22 @@
sources:
"0.7.3":
url: "https://github.com/randy408/libspng/archive/refs/tags/v0.7.3.tar.gz"
sha256: "a50cadbe808ffda1a7fab17d145f52a23b163f34b3eb3696c7ecb5a52340fc1d"
"0.7.2":
url: "https://github.com/randy408/libspng/archive/refs/tags/v0.7.2.tar.gz"
sha256: "4acf25571d31f540d0b7ee004f5461d68158e0a13182505376805da99f4ccc4e"
patches:
"0.7.3":
- patch_file: "patches/0.7.3-0001-fix-dll-install.patch"
patch_description: "fix install path"
patch_type: "portability"
- patch_file: "patches/0.7.3-0002-allow-miniz.patch"
patch_description: "add miniz option which is written in docs/BUILD.md"
patch_type: "portability"
"0.7.2":
- patch_file: "patches/0.7.2-0001-fix-dll-install.patch"
patch_description: "fix install path"
patch_type: "portability"
- patch_file: "patches/0.7.2-0002-allow-miniz.patch"
patch_description: "add miniz option which is written in docs/BUILD.md"
patch_type: "portability"

View File

@@ -43,7 +43,7 @@ class LibspngConan(ConanFile):
def requirements(self):
if self.options.with_miniz:
self.requires("miniz/2.2.0")
self.requires("miniz/3.0.1")
else:
self.requires("zlib/1.2.13")

View File

@@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6630a0..fff5d68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,7 +40,12 @@ if(SPNG_SHARED)
add_library(spng SHARED ${spng_SOURCES})
target_include_directories(spng PUBLIC ${PROJECT_SOURCE_DIR}/spng)
target_link_libraries(spng ${spng_LIBS})
- install(TARGETS spng DESTINATION lib)
+ install(
+ TARGETS spng
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
if(BUILD_EXAMPLES)
add_executable(example examples/example.c)

View File

@@ -0,0 +1,64 @@
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()

View File

@@ -1,3 +1,5 @@
versions:
"0.7.3":
folder: all
"0.7.2":
folder: all