Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions ports/libspng/libspng-pr-286.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da1917e..d385e46 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,10 +17,13 @@ option(BUILD_EXAMPLES "Build examples" ON)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

-if(NOT CMAKE_HOST_WIN32)
+find_library(MATH_LIBRARY_PATH NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
+if(MATH_LIBRARY_PATH)
set(MATH_LIBRARY "m")
+ set(LIBS "-lm")
else()
set(MATH_LIBRARY "")
+ set(LIBS "")
endif()

if(NOT ENABLE_OPT)
@@ -93,16 +96,13 @@ install(
DESTINATION ${config_install_dir}
)

-if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
- set(prefix ${CMAKE_INSTALL_PREFIX})
- set(exec_prefix ${CMAKE_INSTALL_PREFIX})
- set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
- set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
- set(LIBS "-lm")
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(exec_prefix ${CMAKE_INSTALL_PREFIX})
+set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
+set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})

- foreach(libname ${spng_TARGETS})
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libspng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/lib${libname}.pc @ONLY)
+foreach(libname ${spng_TARGETS})
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/spng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/${libname}.pc @ONLY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which names did this install, and which names does it install now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kai Pastor (@dg0yt) libspng has two build systems. A meson one and a CMake one. The meson one installs spng.pc, which is also the name used in the Debian package and expected by libjpeg-turbo. This CMake one installs libspng.pc or libspng_static.pc. This PR resolves the conflict in favor of their meson build system on the grounds that that is what I see downstream customers expecting.


- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/lib${libname}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- endforeach()
-endif()
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${libname}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+endforeach()
diff --git a/cmake/libspng.pc.in b/cmake/spng.pc.in
similarity index 92%
rename from cmake/libspng.pc.in
rename to cmake/spng.pc.in
index 71e0e47..1904c09 100644
--- a/cmake/libspng.pc.in
+++ b/cmake/spng.pc.in
@@ -3,7 +3,7 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/

-Name: lib@libname@
+Name: @libname@
Description: PNG decoding and encoding library
Version: @SPNG_VERSION@
Requires: zlib
29 changes: 26 additions & 3 deletions ports/libspng/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ vcpkg_from_github(
SHA512 cd729653599ed97f80d19f3048c1b3bc2ac16f922b3465804b1913bc45d9fc8b28b56bc2121fda36e9d3dcdd12612cced5383313b722a5342b613f8781879f1a
HEAD_REF master
PATCHES
fix-spngconfig-cmake.patch
fix-spngconfig-cmake.patch # https://github.com/randy408/libspng/pull/262/
libspng-pr-286.diff # https://github.com/randy408/libspng/pull/286/
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SPNG_BUILD_STATIC)
Expand All @@ -26,8 +27,30 @@ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/spng PACKAGE_NAME spng)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_copy_pdbs()

if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future maintenance, it would be nice to jot down what finding / error led to this fix. To my understanding, it is that libspng upstream is inconsistent with the naming of its pkg-config files: in meson it's always spng but in cmake it can be libspng or libspng_static`. And that this inconsistency causes pain for downstream consumers, so you unify them here.

though the PR also captures this, so the info is there. No blockers.

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/spng.h" "#define SPNG_H" "#define SPNG_H\n#define SPNG_STATIC")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng_static.pc" "Name: spng_static" "Name: spng")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng.pc")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng_static.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng.pc")
if (NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng_static.pc" "Name: spng_static" "Name: spng")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng.pc")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng_static.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng.pc")
endif()
else()
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/spng_static.pc")
if (NOT VCPKG_BUILD_TYPE)
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spng_static.pc")
endif()
endif()

vcpkg_fixup_pkgconfig()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
vcpkg_install_copyright(
FILE_LIST
"${SOURCE_PATH}/LICENSE"
"${SOURCE_PATH}/spng/spng.c"
)
7 changes: 6 additions & 1 deletion ports/libspng/usage
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
libspng provides CMake targets:

find_package(SPNG CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:spng::spng>,spng::spng,spng::spng_static>)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:spng::spng>,spng::spng,spng::spng_static>)

libspng provides pkg-config modules:

# PNG decoding and encoding library
spng
3 changes: 2 additions & 1 deletion ports/libspng/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "libspng",
"version": "0.7.4",
"port-version": 1,
"description": "Simple, modern libpng alternative",
"homepage": "https://github.com/randy408/libspng",
"license": "BSD-2-Clause",
"license": "BSD-2-Clause AND libpng-2.0",
"dependencies": [
{
"name": "vcpkg-cmake",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5746,7 +5746,7 @@
},
"libspng": {
"baseline": "0.7.4",
"port-version": 0
"port-version": 1
},
"libsquish": {
"baseline": "1.15",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libspng.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c18b7942b3efca64c49cf7598a0099db296728d4",
"version": "0.7.4",
"port-version": 1
},
{
"git-tree": "ed674df56d8b39d76443c7db3ae893c08394bf9c",
"version": "0.7.4",
Expand Down