mirror of https://github.com/microsoft/vcpkg.git
[libspng] Install pkg-config on Windows (#53510)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
21a093fd90
commit
7ed6d1a07e
|
|
@ -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
|
||||
|
|
@ -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")
|
||||
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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -5746,7 +5746,7 @@
|
|||
},
|
||||
"libspng": {
|
||||
"baseline": "0.7.4",
|
||||
"port-version": 0
|
||||
"port-version": 1
|
||||
},
|
||||
"libsquish": {
|
||||
"baseline": "1.15",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "c18b7942b3efca64c49cf7598a0099db296728d4",
|
||||
"version": "0.7.4",
|
||||
"port-version": 1
|
||||
},
|
||||
{
|
||||
"git-tree": "ed674df56d8b39d76443c7db3ae893c08394bf9c",
|
||||
"version": "0.7.4",
|
||||
|
|
|
|||
Loading…
Reference in New Issue