mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 14:23:03 +08:00
[zlib, libpng] Fix pkg-config for mingw (#12753)
* [zlib] Fix pkg-config for mingw * [libpng] Fix pkg-config for mingw
This commit is contained in:
parent
ffd6ae40d5
commit
fca18ba357
@ -1,5 +1,6 @@
|
||||
Source: libpng
|
||||
Version: 1.6.37-10
|
||||
Version: 1.6.37
|
||||
Port-Version: 11
|
||||
Build-Depends: zlib
|
||||
Homepage: https://github.com/glennrp/libpng
|
||||
Description: libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files.
|
||||
|
@ -1,8 +1,8 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 6f85d17ef..8de0eb299 100644
|
||||
--- a/CMakeLists.txt
|
||||
index 6451fcf..4090f42 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -814,20 +814,31 @@ endif()
|
||||
@@ -821,20 +821,31 @@ endif()
|
||||
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
||||
# of a UNIX look-alike.
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
@ -11,22 +11,22 @@ index 6f85d17ef..8de0eb299 100644
|
||||
- set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
- set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
||||
- set(LIBS "-lz -lm")
|
||||
+ set(LIBS "-lz")
|
||||
+ if(NOT APPLE)
|
||||
+ string(APPEND LIBS " -lm")
|
||||
+ endif()
|
||||
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
- ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
- create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc)
|
||||
-
|
||||
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
- ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
|
||||
- create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
|
||||
+ set(LIBS "-lz")
|
||||
+ if(NOT APPLE)
|
||||
+ string(APPEND LIBS " -lm")
|
||||
+ endif()
|
||||
+else()
|
||||
+ if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
+ set(LIBS "-lzlibd")
|
||||
+ set(LIBS "-lzlibd")
|
||||
+ else()
|
||||
+ set(LIBS "-lzlib")
|
||||
+ set(LIBS "-lzlib")
|
||||
+ endif()
|
||||
endif()
|
||||
|
||||
@ -41,6 +41,7 @@ index 6f85d17ef..8de0eb299 100644
|
||||
+
|
||||
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
+ ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
+create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
|
||||
+
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
|
@ -86,7 +86,11 @@ if(EXISTS ${_file})
|
||||
else()
|
||||
string(REGEX REPLACE "-lpng16(d)?" "-lpng16d" _contents "${_contents}")
|
||||
endif()
|
||||
string(REPLACE "-lzlib" "-lzlibd" _contents "${_contents}")
|
||||
if(VCPKG_TARGET_IS_MINGW)
|
||||
string(REPLACE "-lz" "-lzlibd" _contents "${_contents}")
|
||||
else()
|
||||
string(REPLACE "-lzlib" "-lzlibd" _contents "${_contents}")
|
||||
endif()
|
||||
file(WRITE "${_file}" "${_contents}")
|
||||
endif()
|
||||
set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng.pc")
|
||||
@ -97,7 +101,11 @@ if(EXISTS ${_file})
|
||||
else()
|
||||
string(REGEX REPLACE "-lpng16(d)?" "-lpng16d" _contents "${_contents}")
|
||||
endif()
|
||||
string(REPLACE "-lzlib" "-lzlibd" _contents "${_contents}")
|
||||
if(VCPKG_TARGET_IS_MINGW)
|
||||
string(REPLACE "-lz" "-lzlibd" _contents "${_contents}")
|
||||
else()
|
||||
string(REPLACE "-lzlib" "-lzlibd" _contents "${_contents}")
|
||||
endif()
|
||||
file(WRITE "${_file}" "${_contents}")
|
||||
endif()
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
@ -105,16 +113,22 @@ if(VCPKG_TARGET_IS_WINDOWS)
|
||||
if(EXISTS ${_file})
|
||||
file(READ "${_file}" _contents)
|
||||
string(REPLACE "-lpng16" "-llibpng16" _contents "${_contents}")
|
||||
if(VCPKG_TARGET_IS_MINGW)
|
||||
string(REPLACE "-lz" "-lzlib" _contents "${_contents}")
|
||||
endif()
|
||||
file(WRITE "${_file}" "${_contents}")
|
||||
endif()
|
||||
set(_file "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libpng.pc")
|
||||
if(EXISTS ${_file})
|
||||
file(READ "${_file}" _contents)
|
||||
string(REPLACE "-lpng16" "-llibpng16" _contents "${_contents}")
|
||||
if(VCPKG_TARGET_IS_MINGW)
|
||||
string(REPLACE "-lz" "-lzlib" _contents "${_contents}")
|
||||
endif()
|
||||
file(WRITE "${_file}" "${_contents}")
|
||||
endif()
|
||||
endif()
|
||||
vcpkg_fixup_pkgconfig()
|
||||
vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES m)
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: zlib
|
||||
Version: 1.2.11
|
||||
Port-Version: 7
|
||||
Port-Version: 8
|
||||
Homepage: https://www.zlib.net/
|
||||
Description: A compression library
|
||||
|
13
ports/zlib/add_debug_postfix_on_mingw.patch
Normal file
13
ports/zlib/add_debug_postfix_on_mingw.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 0fe939d..e4fc213 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -59,7 +59,7 @@ endif()
|
||||
#
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
-if(MSVC)
|
||||
+if(WIN32)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
@ -12,6 +12,7 @@ vcpkg_extract_source_archive_ex(
|
||||
REF ${VERSION}
|
||||
PATCHES
|
||||
"cmake_dont_build_more_than_needed.patch"
|
||||
"add_debug_postfix_on_mingw.patch"
|
||||
)
|
||||
|
||||
# This is generated during the cmake build
|
||||
|
Loading…
Reference in New Issue
Block a user