[libgd] Fixes, feature "tools" (#27551)

* Revise portfile and patches

Fix dependencies and pkg-config export.
Add tools feature.

* Update versions

* Fixup libgd name for windows [skip actions]

* Print usage

* Update versions
This commit is contained in:
Kai Pastor 2022-11-02 04:23:20 +01:00 committed by GitHub
parent 630bc4ef88
commit cafd398be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 185 additions and 137 deletions

View File

@ -1,84 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b3e5b3..cf80322 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -298,8 +298,10 @@ else (USE_EXT_GD)
add_subdirectory(src)
endif (USE_EXT_GD)
-add_subdirectory(tests)
-add_subdirectory(examples)
+if(BUILD_TEST)
+ add_subdirectory(tests)
+ add_subdirectory(examples)
+endif()
add_subdirectory(docs)
add_custom_target(distclean ${GD_SOURCE_DIR}/cmake/distclean.sh)
@@ -317,7 +319,7 @@ else(WIN32)
set(CPACK_GENERATOR TGZ)
endif(WIN32)
-
+if(0)
INSTALL(FILES docs/INSTALL DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
INSTALL(FILES docs/README.JPN DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
INSTALL(FILES docs/README.CMAKE DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
@@ -339,7 +341,7 @@ INSTALL(FILES examples/test_crop_threshold.png DESTINATION share/doc/gd-${GDLIB_
INSTALL(FILES examples/tgaread.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
INSTALL(FILES examples/tiffread.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
INSTALL(FILES examples/windows.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
-
+endif()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3839bc7..f7dabf7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -76,7 +76,7 @@ if (BUILD_STATIC_LIBS)
if (UNIX)
set_target_properties(${GD_LIB_STATIC} PROPERTIES OUTPUT_NAME ${GD_LIB})
endif()
-endif()
+
if (NOT "${GD_PROGRAMS_LIB_SRC_FILES}" STREQUAL "")
add_library(gd_programs_lib STATIC ${GD_PROGRAMS_LIB_SRC_FILES})
@@ -90,6 +90,7 @@ if (WIN32 AND NOT MINGW AND NOT MSYS)
endif()
ENDIF(WIN32 AND NOT MINGW AND NOT MSYS)
+endif()
if (MINGW OR MSYS)
ADD_DEFINITIONS("-mms-bitfields")
@@ -127,7 +128,7 @@ SET(LIBS_PRIVATES
${LIQ_LIBRARIES}
${WEBP_LIBRARIES}
)
-
+if(BUILD_PROGRAMS)
set(GD_PROGRAMS gdcmpgif)
if (PNG_FOUND)
@@ -168,6 +169,9 @@ foreach(program ${GD_PROGRAMS})
endif()
endforeach(program)
+install(PROGRAMS bdftogd DESTINATION bin)
+endif()
+
set(GD_INSTALL_TARGETS ${GD_PROGRAMS})
if (BUILD_SHARED_LIBS)
set(GD_INSTALL_TARGETS ${GD_INSTALL_TARGETS} ${GD_LIB})
@@ -180,7 +184,7 @@ install(TARGETS ${GD_INSTALL_TARGETS}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
-install(PROGRAMS bdftogd DESTINATION bin)
+
install(FILES
gd.h
gd_color_map.h

View File

@ -0,0 +1,59 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b3e5b3..bab784a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -182,6 +182,21 @@ else (USE_EXT_GD)
SET(ENABLE_GD_FORMATS ${ENABLE_GD_FORMATS})
+ # The remaining code uses <Pkg>_FOUND, but this could be set as side effect.
+ # Restore explicit control. <Pkg>_FOUND is implied by <Pkg>_REQUIRED.
+ set(FONTCONFIG_FOUND ${ENABLE_FONTCONFIG})
+ set(FREETYPE_FOUND ${ENABLE_FREETYPE})
+ set(HEIF_FOUND ${ENABLE_HEIF})
+ set(ICONV_FOUND ${ENABLE_ICONV})
+ set(JPEG_FOUND ${ENABLE_JPEG})
+ set(LIQ_FOUND ${ENABLE_LIQ})
+ set(PNG_FOUND ${ENABLE_PNG})
+ set(RAQM_FOUND ${ENABLE_RAQM})
+ set(TIFF_FOUND ${ENABLE_TIFF})
+ set(WEBP_FOUND ${ENABLE_WEBP})
+ set(XPM_FOUND ${ENABLE_XPM})
+ set(ZLIB_FOUND ${ENABLE_GD_FORMATS})
+
if (FREETYPE_FOUND)
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
SET(HAVE_FT2BUILD_H 1)
@@ -299,8 +299,6 @@ else (USE_EXT_GD)
endif (USE_EXT_GD)
add_subdirectory(tests)
-add_subdirectory(examples)
-add_subdirectory(docs)
add_custom_target(distclean ${GD_SOURCE_DIR}/cmake/distclean.sh)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3839bc7..4cb56eb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -150,6 +150,9 @@ if (ZLIB_FOUND)
set(GD_PROGRAMS ${GD_PROGRAMS} gd2copypal gd2togif giftogd2)
endif()
+if(NOT ENABLE_TOOLS)
+ set(GD_PROGRAMS "")
+endif()
foreach(program ${GD_PROGRAMS})
add_executable(${program} ${program}.c)
if (WIN32)
@@ -180,7 +183,9 @@ install(TARGETS ${GD_INSTALL_TARGETS}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+if(ENABLE_TOOLS)
install(PROGRAMS bdftogd DESTINATION bin)
+endif()
install(FILES
gd.h
gd_color_map.h

View File

@ -0,0 +1,39 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bab784a..76c20e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,7 +134,10 @@ else (USE_EXT_GD)
endif (ENABLE_ICONV)
IF (ENABLE_WEBP)
- FIND_PACKAGE(WEBP REQUIRED)
+ find_package(WEBP NAMES WebP CONFIG REQUIRED)
+ set(WEBP_INCLUDE_DIR "")
+ set(WEBP_LIBRARIES WebP::webp)
+ list(APPEND PKG_REQUIRES_PRIVATES libwebp)
ENDIF (ENABLE_WEBP)
IF (ENABLE_HEIF)
@@ -173,7 +176,9 @@ else (USE_EXT_GD)
endif (ENABLE_XPM)
if (ENABLE_FONTCONFIG)
- FIND_PACKAGE(FontConfig REQUIRED)
+ FIND_PACKAGE(Fontconfig REQUIRED)
+ set(FONTCONFIG_INCLUDE_DIR "")
+ set(FONTCONFIG_LIBRARY Fontconfig::Fontconfig)
endif (ENABLE_FONTCONFIG)
if (ENABLE_RAQM)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4cb56eb..74fa26b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -125,7 +125,6 @@ endif()
SET(LIBS_PRIVATES
${ICONV_LIBRARIES}
${LIQ_LIBRARIES}
- ${WEBP_LIBRARIES}
)
set(GD_PROGRAMS gdcmpgif)

View File

@ -1,27 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b3e5b3..966ddb3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,7 +134,7 @@ else (USE_EXT_GD)
endif (ENABLE_ICONV)
diff --git a/src/gd_webp.c b/src/gd_webp.c
index e9ad802..7631f27 100644
--- a/src/gd_webp.c
+++ b/src/gd_webp.c
@@ -16,6 +16,7 @@
#include "gd.h"
#include "gd_errors.h"
#include "gdhelpers.h"
+#include "gd_intern.h" # for ssize_t
IF (ENABLE_WEBP)
- FIND_PACKAGE(WEBP REQUIRED)
+ FIND_PACKAGE(WebP CONFIG REQUIRED)
ENDIF (ENABLE_WEBP)
IF (ENABLE_HEIF)
diff --git a/src/config.h.cmake b/src/config.h.cmake
index 0542942..e9cfde1 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -142,3 +142,8 @@
/* Version number of package */
#cmakedefine VERSION
+
+#ifdef _MSC_VER
+ #define ssize_t SSIZE_T
+ #define SSIZE_MAX MAXSSIZE_T
+#endif
\ No newline at end of file
#ifdef HAVE_LIBWEBP
#include "webp/decode.h"

View File

@ -5,46 +5,79 @@ vcpkg_from_github(
SHA512 b4c6ca1d9575048de35a38b0db69e7380e160293133c1f72ae570f83ce614d4f2fd2615d217f7a0023e2265652c1089561b906beabca56c15e6ec0250e4394b2
HEAD_REF master
PATCHES
0001-fix-cmake.patch
control-build.patch
fix-dependencies.cmake
fix_msvc_build.patch
)
#delete CMake builtins modules
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/modules/CMakeParseArguments.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/modules/FindFreetype.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/modules/FindJPEG.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/modules/FindPackageHandleStandardArgs.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/modules/FindPNG.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/modules/FindWEBP.cmake")
# Delete vendored Find modules
file(REMOVE
"${SOURCE_PATH}/cmake/modules/CMakeParseArguments.cmake"
"${SOURCE_PATH}/cmake/modules/FindFontConfig.cmake"
"${SOURCE_PATH}/cmake/modules/FindFreetype.cmake"
"${SOURCE_PATH}/cmake/modules/FindJPEG.cmake"
"${SOURCE_PATH}/cmake/modules/FindPackageHandleStandardArgs.cmake"
"${SOURCE_PATH}/cmake/modules/FindPNG.cmake"
"${SOURCE_PATH}/cmake/modules/FindWEBP.cmake"
)
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
png ENABLE_PNG
fontconfig ENABLE_FONTCONFIG
freetype ENABLE_FREETYPE
jpeg ENABLE_JPEG
tiff ENABLE_TIFF
freetype ENABLE_FREETYPE
png ENABLE_PNG
tools ENABLE_TOOLS
webp ENABLE_WEBP
fontconfig ENABLE_FONTCONFIG
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DLIBGD_SHARED_LIBS=${BUILD_SHARED}
-DBUILD_STATIC_LIBS=${BUILD_STATIC}
-DBUILD_TEST=OFF
OPTIONS_DEBUG
-DENABLE_TOOLS=OFF
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
string(REPLACE "_dynamic" "" suffix "_${VCPKG_LIBRARY_LINKAGE}")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/gdlib.pc" " -lgd" " -llibgd${suffix}")
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/gdlib.pc" " -lgd" " -llibgd${suffix}")
endif()
endif()
vcpkg_fixup_pkgconfig()
if(ENABLE_TOOLS)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/bdftogd" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bdftogd")
vcpkg_list(SET tool_names gdcmpgif)
if(ENABLE_PNG)
vcpkg_list(APPEND tool_names gdtopng pngtogd)
endif()
if(NOT VCPKG_TARGET_IS_WINDOWS)
if(ENABLE_FREETYPE AND ENABLE_JPEG)
vcpkg_list(APPEND tool_names annotate)
endif()
if(ENABLE_PNG)
vcpkg_list(APPEND tool_names webpng)
endif()
endif()
vcpkg_copy_tools(TOOL_NAMES ${tool_names} AUTO_CLEAN)
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share/doc"
)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

6
ports/libgd/usage Normal file
View File

@ -0,0 +1,6 @@
libgd can be imported via CMake FindPkgConfig module:
find_package(PkgConfig)
pkg_check_modules(LIBGD REQUIRED IMPORTED_TARGET gdlib)
target_link_libraries(main PRIVATE PkgConfig::LIBGD)

View File

@ -1,6 +1,7 @@
{
"name": "libgd",
"version-semver": "2.3.3",
"port-version": 1,
"description": "Open source code library for the dynamic creation of images by programmers.",
"homepage": "https://github.com/libgd/libgd",
"license": "GD",
@ -20,37 +21,41 @@
],
"features": {
"fontconfig": {
"description": "Support for fontconfig",
"description": "Support for Fontconfig",
"dependencies": [
"fontconfig"
]
},
"freetype": {
"description": "Support for freetype",
"description": "Support for FreeType",
"dependencies": [
"freetype"
]
},
"jpeg": {
"description": "Support for jpeg",
"description": "Support for JPEG",
"dependencies": [
"libjpeg-turbo"
]
},
"png": {
"description": "Support for png",
"description": "Support for PNG",
"dependencies": [
"libpng"
"libpng",
"zlib"
]
},
"tiff": {
"description": "Support for tiff",
"description": "Support for TIFF",
"dependencies": [
"tiff"
]
},
"tools": {
"description": "Build tools"
},
"webp": {
"description": "Support for webp",
"description": "Support for WebP",
"dependencies": [
"libwebp"
]

View File

@ -3750,7 +3750,7 @@
},
"libgd": {
"baseline": "2.3.3",
"port-version": 0
"port-version": 1
},
"libgeotiff": {
"baseline": "1.7.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3198a57128bcffbbd79213ff2aa000c859483b68",
"version-semver": "2.3.3",
"port-version": 1
},
{
"git-tree": "2de4ed776a149cb13e64876f1f8d7e241e3291db",
"version-semver": "2.3.3",