-
Notifications
You must be signed in to change notification settings - Fork 7.7k
[libspng] Install pkg-config on Windows #53510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
749aac2
e96c049
566333f
a795d20
bfda642
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
|
|
||
| - 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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" | ||
| ) | ||
| 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kai Pastor (@dg0yt)
libspnghas two build systems. A meson one and a CMake one. The meson one installsspng.pc, which is also the name used in the Debian package and expected bylibjpeg-turbo. This CMake one installslibspng.pcorlibspng_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.