From b35f75d646e8e66ac515a0836e9a808bee54c7ba Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 11 Sep 2018 13:11:51 -0700 Subject: [PATCH] [cairo][expat][fontconfig][graphicsmagick][libjpeg-turbo][pixman][tiff] Add unofficial targets and usage information --- ports/cairo/CMakeLists.txt | 79 ++++++++++--------- ports/cairo/CONTROL | 2 +- ports/cairo/portfile.cmake | 27 +++---- ports/expat/portfile.cmake | 2 + ports/expat/usage | 4 + ports/fontconfig/CMakeLists.txt | 25 +++++- ports/fontconfig/CONTROL | 2 +- ports/fontconfig/portfile.cmake | 21 +++-- ports/graphicsmagick/CMakeLists.txt | 52 ++++++++---- ports/graphicsmagick/CONTROL | 2 +- ports/graphicsmagick/portfile.cmake | 4 + ports/io2d/CONTROL | 2 +- ports/io2d/find-package.patch | 47 +++++++++++ ports/io2d/portfile.cmake | 35 ++++---- ports/libjpeg-turbo/portfile.cmake | 23 +++--- ports/libjpeg-turbo/vcpkg-cmake-wrapper.cmake | 28 +++++++ ports/pixman/CMakeLists.txt | 12 ++- ports/pixman/CONTROL | 2 +- ports/pixman/portfile.cmake | 17 ++-- ports/tiff/portfile.cmake | 22 +++--- ports/tiff/usage | 4 + ports/tiff/vcpkg-cmake-wrapper.cmake | 9 ++- 22 files changed, 286 insertions(+), 135 deletions(-) create mode 100644 ports/expat/usage create mode 100644 ports/io2d/find-package.patch create mode 100644 ports/libjpeg-turbo/vcpkg-cmake-wrapper.cmake create mode 100644 ports/tiff/usage diff --git a/ports/cairo/CMakeLists.txt b/ports/cairo/CMakeLists.txt index 5ace57604c..137dba7f3a 100644 --- a/ports/cairo/CMakeLists.txt +++ b/ports/cairo/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.11) project(cairo C) # Add include directories @@ -162,14 +162,10 @@ set(CMAKE_DEBUG_POSTFIX "d") find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) - -# Make the pixman library available -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(PIXMAN_SUFFIX "d") -endif() -find_library(PIXMAN_LIBRARY NAMES pixman-1${PIXMAN_SUFFIX}) - -find_package(Freetype CONFIG REQUIRED) +find_package(Freetype REQUIRED) +find_package(unofficial-glib CONFIG REQUIRED) +find_package(unofficial-fontconfig CONFIG REQUIRED) +find_package(unofficial-pixman CONFIG REQUIRED) # Cairo needs to be told which features of FreeType are availible add_definitions( @@ -179,9 +175,6 @@ add_definitions( -DHAVE_FT_LOAD_SFNT_TABLE=1 -DHAVE_FT_GET_X11_FONT_FORMAT=1) -# Find FontConfig -find_library(FONTCONFIG_LIBRARY fontconfig) - # additional features for macOS if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_definitions( @@ -196,20 +189,7 @@ endif() add_library(cairo ${SOURCES}) -if(MSVC) - # cairo produces a lot of warnings which are disabled here because they otherwise fill up the log files - # NOTE: options only available to MSVC, clang in macOS doesn't understand these flags - target_compile_options(cairo PUBLIC "/wd4244" PUBLIC "/wd4146" PUBLIC "/wd4312" PUBLIC "/wd4267" - PUBLIC "/wd4996" PUBLIC "/wd4311" PUBLIC "/wd4334" PUBLIC "/wd4101") -endif() - -target_link_libraries(cairo gdi32 msimg32 user32 ZLIB::ZLIB PNG::PNG freetype ${PIXMAN_LIBRARY} ${FONTCONFIG_LIBRARY}) - -install(TARGETS cairo - RUNTIME DESTINATION bin - LIBRARY DESTINATION bin - ARCHIVE DESTINATION lib -) +target_link_libraries(cairo PRIVATE gdi32 msimg32 user32 ZLIB::ZLIB PNG::PNG Freetype::Freetype unofficial::pixman::pixman-1 unofficial::fontconfig::fontconfig) # GObject support module @@ -225,16 +205,43 @@ if(BUILD_SHARED_LIBS) PROPERTIES COMPILE_DEFINITIONS "cairo_public=__declspec(dllexport)") endif() -# Make GLib's GObject available -find_path(GLIB_INCLUDE_DIR glib.h) -find_library(GLIB_LIBRARY NAMES glib-2.0) -find_library(GOBJECT_LIBRARY NAMES gobject-2.0) -set(GLIB_LIBRARIES ${GLIB_LIBRARY} ${GOBJECT_LIBRARY}) - add_library(cairo-gobject ${CAIRO_GOBJECT_SOURCES}) -target_link_libraries(cairo-gobject cairo ${GLIB_LIBRARIES}) -target_include_directories(cairo-gobject PRIVATE ${GLIB_INCLUDE_DIR}) -install(TARGETS cairo-gobject +target_link_libraries(cairo-gobject PRIVATE cairo unofficial::glib::gobject unofficial::glib::glib) + +if(MSVC) + # cairo produces a lot of warnings which are disabled here because they otherwise fill up the log files + # NOTE: options only available to MSVC, clang in macOS doesn't understand these flags + target_compile_options(cairo PRIVATE + "/wd4244" "/wd4146" "/wd4312" "/wd4267" "/wd4996" "/wd4311" "/wd4334" "/wd4101" + ) + target_compile_options(cairo-gobject PRIVATE + "/wd4244" "/wd4146" "/wd4312" "/wd4267" "/wd4996" "/wd4311" "/wd4334" "/wd4101" + ) +endif() + +install(TARGETS cairo cairo-gobject + EXPORT cairo-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib +) + +install( + EXPORT cairo-targets + NAMESPACE unofficial::cairo:: + FILE unofficial-cairo-targets.cmake + DESTINATION share/unofficial-cairo +) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unofficial-cairo-config.cmake " +include(CMakeFindDependencyMacro) +find_dependency(ZLIB) +find_dependency(PNG) +find_dependency(Freetype) +find_dependency(unofficial-glib CONFIG) +find_dependency(unofficial-fontconfig CONFIG) +find_dependency(unofficial-pixman CONFIG) + +include(\${CMAKE_CURRENT_LIST_DIR}/unofficial-cairo-targets.cmake) +") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-cairo-config.cmake DESTINATION share/unofficial-cairo) diff --git a/ports/cairo/CONTROL b/ports/cairo/CONTROL index eb1964c8a1..2f182e84b8 100644 --- a/ports/cairo/CONTROL +++ b/ports/cairo/CONTROL @@ -1,4 +1,4 @@ Source: cairo -Version: 1.15.8-2 +Version: 1.15.8-3 Description: Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB. Build-Depends: zlib, libpng, pixman, glib, freetype, fontconfig diff --git a/ports/cairo/portfile.cmake b/ports/cairo/portfile.cmake index bc74654d09..53d944b547 100644 --- a/ports/cairo/portfile.cmake +++ b/ports/cairo/portfile.cmake @@ -1,25 +1,18 @@ -# Common Ambient Variables: -# VCPKG_ROOT_DIR = -# TARGET_TRIPLET is the current triplet (x86-windows, etc) -# PORT is the current port name (zlib, etc) -# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} -# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} -# - include(vcpkg_common_functions) set(CAIRO_VERSION 1.15.8) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/cairo-${CAIRO_VERSION}) + vcpkg_download_distfile(ARCHIVE URLS "http://cairographics.org/snapshots/cairo-${CAIRO_VERSION}.tar.xz" FILENAME "cairo-${CAIRO_VERSION}.tar.xz" SHA512 5af1eebf432201dae0efaa5b6766b151d8273ea00dae48e104d56477005b4d423d64b5d11c512736a4cb076632fb2a572ec35becd922825a68d933bb5ff96ca1 ) -vcpkg_extract_source_archive(${ARCHIVE}) - -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES "${CMAKE_CURRENT_LIST_DIR}/export-only-in-shared-build.patch" - "${CMAKE_CURRENT_LIST_DIR}/0001_fix_osx_defined.patch" +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + REF ${CAIRO_VERSION} + PATCHES + export-only-in-shared-build.patch + 0001_fix_osx_defined.patch ) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}/src) @@ -32,6 +25,8 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-cairo TARGET_PATH share/unofficial-cairo) + # Copy the appropriate header files. foreach(FILE "${SOURCE_PATH}/src/cairo.h" @@ -64,3 +59,5 @@ file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/cairo file(RENAME ${CURRENT_PACKAGES_DIR}/share/cairo/COPYING ${CURRENT_PACKAGES_DIR}/share/cairo/copyright) vcpkg_copy_pdbs() + +vcpkg_test_cmake(PACKAGE_NAME unofficial-cairo) diff --git a/ports/expat/portfile.cmake b/ports/expat/portfile.cmake index b6db7b3747..7e2c322db9 100644 --- a/ports/expat/portfile.cmake +++ b/ports/expat/portfile.cmake @@ -43,3 +43,5 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") string(REPLACE "!defined(XML_STATIC)" "/* vcpkg static build !defined(XML_STATIC) */ 0" EXPAT_EXTERNAL_H "${EXPAT_EXTERNAL_H}") endif() file(WRITE ${CURRENT_PACKAGES_DIR}/include/expat_external.h "${EXPAT_EXTERNAL_H}") + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/expat) diff --git a/ports/expat/usage b/ports/expat/usage new file mode 100644 index 0000000000..a2d35a66e3 --- /dev/null +++ b/ports/expat/usage @@ -0,0 +1,4 @@ +The package expat is compatible with built-in CMake targets: + + find_package(EXPAT REQUIRED) + target_link_libraries(main PRIVATE EXPAT::EXPAT) diff --git a/ports/fontconfig/CMakeLists.txt b/ports/fontconfig/CMakeLists.txt index 5fa5c547a4..1c552468e6 100644 --- a/ports/fontconfig/CMakeLists.txt +++ b/ports/fontconfig/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.11) project(fontconfig C) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -DHAVE_CONFIG_H) @@ -6,8 +6,7 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -DHAVE_CONF # find dependencies find_package(unofficial-iconv CONFIG REQUIRED) find_package(Freetype REQUIRED) -find_path(EXPAT_INCLUDE_DIR expat.h) -find_library(EXPAT_LIBRARY expat) +find_package(EXPAT REQUIRED) add_library(fontconfig src/fcatomic.c @@ -49,9 +48,10 @@ else() target_include_directories(fontconfig PRIVATE ${FC_INCLUDE_DIR}/unix) endif() -target_link_libraries(fontconfig PRIVATE unofficial::iconv::libiconv Freetype::Freetype ${EXPAT_LIBRARY}) +target_link_libraries(fontconfig PRIVATE unofficial::iconv::libiconv Freetype::Freetype EXPAT::EXPAT) install(TARGETS fontconfig + EXPORT fontconfig-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) @@ -73,3 +73,20 @@ if(NOT FC_SKIP_TOOLS) install(FILES fonts.conf DESTINATION tools/fontconfig/fonts) install(DIRECTORY conf.d DESTINATION tools/fontconfig/fonts FILES_MATCHING PATTERN "*.conf") endif() + +install( + EXPORT fontconfig-targets + NAMESPACE unofficial::fontconfig:: + FILE unofficial-fontconfig-targets.cmake + DESTINATION share/unofficial-fontconfig +) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unofficial-fontconfig-config.cmake " +include(CMakeFindDependencyMacro) +find_dependency(unofficial-iconv CONFIG) +find_dependency(Freetype) +find_dependency(EXPAT) + +include(\${CMAKE_CURRENT_LIST_DIR}/unofficial-fontconfig-targets.cmake) +") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-fontconfig-config.cmake DESTINATION share/unofficial-fontconfig) diff --git a/ports/fontconfig/CONTROL b/ports/fontconfig/CONTROL index c0cf971da0..5366616598 100644 --- a/ports/fontconfig/CONTROL +++ b/ports/fontconfig/CONTROL @@ -1,4 +1,4 @@ Source: fontconfig -Version: 2.12.4-3 +Version: 2.12.4-7 Description: Library for configuring and customizing font access. Build-Depends: freetype, expat, libiconv, dirent diff --git a/ports/fontconfig/portfile.cmake b/ports/fontconfig/portfile.cmake index d35bbb64a5..fff6eb477b 100644 --- a/ports/fontconfig/portfile.cmake +++ b/ports/fontconfig/portfile.cmake @@ -1,18 +1,18 @@ include(vcpkg_common_functions) + set(FONTCONFIG_VERSION 2.12.4) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/fontconfig-${FONTCONFIG_VERSION}) vcpkg_download_distfile(ARCHIVE URLS "https://www.freedesktop.org/software/fontconfig/release/fontconfig-${FONTCONFIG_VERSION}.tar.gz" FILENAME "fontconfig-${FONTCONFIG_VERSION}.tar.gz" - SHA512 2be3ee0e8e0e3b62571135a3cae06e456c289dd1ad40ef2a7c780406418ee5efce863a833eca5a8ef55bc737a0ea04ef562bba6fd27e174ae43e42131b52810d) + SHA512 2be3ee0e8e0e3b62571135a3cae06e456c289dd1ad40ef2a7c780406418ee5efce863a833eca5a8ef55bc737a0ea04ef562bba6fd27e174ae43e42131b52810d +) -vcpkg_extract_source_archive(${ARCHIVE}) - -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES - "${CMAKE_CURRENT_LIST_DIR}/fcobjtypehash.patch" +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + REF ${FONTCONFIG_VERSION} + PATCHES fcobjtypehash.patch ) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) @@ -28,6 +28,9 @@ vcpkg_configure_cmake( ) vcpkg_install_cmake() + +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-fontconfig TARGET_PATH share/unofficial-fontconfig) + vcpkg_copy_pdbs() if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) @@ -40,3 +43,5 @@ endif() file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/fontconfig) file(RENAME ${CURRENT_PACKAGES_DIR}/share/fontconfig/COPYING ${CURRENT_PACKAGES_DIR}/share/fontconfig/copyright) + +vcpkg_test_cmake(PACKAGE_NAME unofficial-fontconfig) diff --git a/ports/graphicsmagick/CMakeLists.txt b/ports/graphicsmagick/CMakeLists.txt index 27f9fb1099..c156b69c77 100644 --- a/ports/graphicsmagick/CMakeLists.txt +++ b/ports/graphicsmagick/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.6) project (graphicsmagick) -find_package(Zlib REQUIRED) +find_package(ZLIB REQUIRED) find_package(Bzip2 REQUIRED) find_package(JPEG REQUIRED) find_package(PNG REQUIRED) @@ -29,13 +29,6 @@ include_directories("Magick++") include_directories("Magick++/lib") include_directories("wand") -include_directories(${ZLIB_INCLUDE_DIRS}) -include_directories(${BZIP2_INCLUDE_DIR}) -include_directories(${NATIVE_JPEG_INCLUDE_PATH}) -include_directories(${PNG_INCLUDE_DIRS}) -include_directories(${TIFF_INCLUDE_DIRS}) -include_directories(${FREETYPE_INCLUDE_DIRS}) - file(READ "magick/magick_config.h.in" CONFIG_H) string(REPLACE "#undef HasBZLIB" "#define HasBZLIB" CONFIG_H "${CONFIG_H}") string(REPLACE "#undef HasJPEG" "#define HasJPEG" CONFIG_H "${CONFIG_H}") @@ -108,18 +101,49 @@ add_library(graphicsmagick coders/art.c coders/avs.c Magick++/lib/TypeMetric.cpp wand/drawing_wand.c wand/magick_compat.c wand/magick_wand.c wand/pixel_wand.c) -TARGET_LINK_LIBRARIES(graphicsmagick ${ZLIB_LIBRARIES}) -TARGET_LINK_LIBRARIES(graphicsmagick ${BZIP2_LIBRARIES}) -TARGET_LINK_LIBRARIES(graphicsmagick ${JPEG_LIBRARIES}) -TARGET_LINK_LIBRARIES(graphicsmagick ${PNG_LIBRARIES}) -TARGET_LINK_LIBRARIES(graphicsmagick ${TIFF_LIBRARIES}) -TARGET_LINK_LIBRARIES(graphicsmagick ${FREETYPE_LIBRARIES}) +TARGET_LINK_LIBRARIES(graphicsmagick PRIVATE + ZLIB::ZLIB + BZip2::BZip2 + #${JPEG_LIBRARIES} + JPEG::JPEG + PNG::PNG + TIFF::TIFF + Freetype::Freetype +) +target_include_directories(graphicsmagick INTERFACE $) install(TARGETS graphicsmagick + EXPORT graphicsmagick-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +install( + EXPORT graphicsmagick-targets + FILE unofficial-graphicsmagick-targets.cmake + NAMESPACE unofficial::graphicsmagick:: + DESTINATION share/unofficial-graphicsmagick +) +find_package(ZLIB REQUIRED) +find_package(BZip2 REQUIRED) +find_package(JPEG REQUIRED) +find_package(PNG REQUIRED) +find_package(TIFF REQUIRED) +find_package(Freetype REQUIRED) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unofficial-graphicsmagick-config.cmake " +include(CMakeFindDependencyMacro) +find_dependency(ZLIB) +find_dependency(BZip2) +find_dependency(JPEG) +find_dependency(PNG) +find_dependency(TIFF) +find_dependency(Freetype) + +include(\${CMAKE_CURRENT_LIST_DIR}/unofficial-graphicsmagick-targets.cmake) +") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-graphicsmagick-config.cmake DESTINATION share/unofficial-graphicsmagick) + option(INSTALL_HEADERS "Install development header files" ON) if (INSTALL_HEADERS) diff --git a/ports/graphicsmagick/CONTROL b/ports/graphicsmagick/CONTROL index 1d6f327dfc..f8519040f4 100644 --- a/ports/graphicsmagick/CONTROL +++ b/ports/graphicsmagick/CONTROL @@ -1,5 +1,5 @@ Source: graphicsmagick Maintainer: josuegomes@gmail.com -Version: 1.3.30 +Version: 1.3.30-1 Build-Depends: zlib, bzip2, freetype, libjpeg-turbo, libpng, tiff Description: Image processing library diff --git a/ports/graphicsmagick/portfile.cmake b/ports/graphicsmagick/portfile.cmake index c097c9e978..b04842eb13 100644 --- a/ports/graphicsmagick/portfile.cmake +++ b/ports/graphicsmagick/portfile.cmake @@ -34,6 +34,8 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-graphicsmagick TARGET_PATH share/unofficial-graphicsmagick) + # copy license file(COPY ${SOURCE_PATH}/Copyright.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/graphicsmagick) file(RENAME ${CURRENT_PACKAGES_DIR}/share/graphicsmagick/Copyright.txt ${CURRENT_PACKAGES_DIR}/share/graphicsmagick/copyright) @@ -48,3 +50,5 @@ string(REPLACE "@windows_font_dir@" "$ENV{SYSTEMROOT}/Fonts/" TYPE_MGK "${TYPE_M file(WRITE ${CURRENT_PACKAGES_DIR}/share/graphicsmagick/config/type.mgk "${TYPE_MGK}") vcpkg_copy_pdbs() + +vcpkg_test_cmake(PACKAGE_NAME unofficial-graphicsmagick) diff --git a/ports/io2d/CONTROL b/ports/io2d/CONTROL index 331e585515..7e36cb5d90 100644 --- a/ports/io2d/CONTROL +++ b/ports/io2d/CONTROL @@ -1,4 +1,4 @@ Source: io2d -Version: 0.1 +Version: 0.1-1 Description: a lightweight, cross platform drawing library Build-Depends: cairo, graphicsmagick diff --git a/ports/io2d/find-package.patch b/ports/io2d/find-package.patch new file mode 100644 index 0000000000..10d83f95bd --- /dev/null +++ b/ports/io2d/find-package.patch @@ -0,0 +1,47 @@ +diff --git a/P0267_RefImpl/P0267_RefImpl/cairo/CMakeLists.txt b/P0267_RefImpl/P0267_RefImpl/cairo/CMakeLists.txt +index 3d4791c..1864b7a 100644 +--- a/P0267_RefImpl/P0267_RefImpl/cairo/CMakeLists.txt ++++ b/P0267_RefImpl/P0267_RefImpl/cairo/CMakeLists.txt +@@ -23,7 +23,15 @@ target_compile_features(io2d_cairo PUBLIC cxx_std_17) + + target_link_libraries(io2d_cairo PUBLIC io2d_core) + +-if(MSVC) ++if(DEFINED VCPKG_TARGET_TRIPLET) ++ find_package(unofficial-cairo CONFIG REQUIRED) ++ set(CAIRO_INCLUDE_DIR) ++ set(CAIRO_LIB_DEBUG "CAIRO_LIB_DEBUG-NOTFOUND") ++ set(CAIRO_LIB_RELEASE unofficial::cairo::cairo) ++ find_package(unofficial-graphicsmagick CONFIG REQUIRED) ++ set(GRAPHICSMAGICK_INCLUDE_DIR) ++ set(GRAPHICSMAGICK_LIB unofficial::graphicsmagick::graphicsmagick) ++elseif(MSVC) + find_path(CAIRO_INCLUDE_DIR cairo.h) + find_path(GRAPHICSMAGICK_INCLUDE_DIR magick/api.h) + find_library(CAIRO_LIB_DEBUG cairod) +diff --git a/P0267_RefImpl/P0267_RefImpl/cairo/win32/CMakeLists.txt b/P0267_RefImpl/P0267_RefImpl/cairo/win32/CMakeLists.txt +index abb1501..b7a6e71 100644 +--- a/P0267_RefImpl/P0267_RefImpl/cairo/win32/CMakeLists.txt ++++ b/P0267_RefImpl/P0267_RefImpl/cairo/win32/CMakeLists.txt +@@ -24,20 +24,7 @@ target_compile_features(io2d_cairo_win32 PUBLIC cxx_std_17) + target_link_libraries(io2d_cairo_win32 PUBLIC io2d_cairo) + + if(MSVC) +- target_compile_definitions(io2d_cairo_win32 PUBLIC -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS) +- +- find_library(PIXMAN_LIB pixman-1) +- find_library(FREETYPE_LIB freetype) +- find_library(FONTCONFIG_LIB fontconfig) +- find_library(BZ_LIB bz2) +- find_library(JPEG_LIB jpeg) +- find_library(TIFF_LIB tiff) +- find_library(EXPAT_LIB expat) +- find_library(LZMA_LIB lzma) +- find_library(ICONV_LIB libiconv) +- find_library(CHARSET_LIB libcharset) +- +- target_link_libraries(io2d_cairo_win32 PUBLIC ${PIXMAN_LIB} ${FREETYPE_LIB} ${FONTCONFIG_LIB} ${BZ_LIB} ${JPEG_LIB} ${TIFF_LIB} ${EXPAT_LIB} ${LZMA_LIB} ${ICONV_LIB} ${CHARSET_LIB}) ++ target_compile_definitions(io2d_cairo_win32 PRIVATE -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS) + endif() + + install( diff --git a/ports/io2d/portfile.cmake b/ports/io2d/portfile.cmake index 285cab9699..c1d536d57f 100644 --- a/ports/io2d/portfile.cmake +++ b/ports/io2d/portfile.cmake @@ -12,23 +12,25 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) # Retrieve and validate io2d source code, as-needed if ("${SOURCE_PATH}" STREQUAL "") + # TODO: point at cpp-io2d/(whatever), if and as needed vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH - - # TODO: point at cpp-io2d/(whatever), if and as needed REPO cpp-io2d/P0267_RefImpl REF 21ae92c8be6916034e6e18f08aa57899a975dfb0 SHA512 5b674f98ca7705d6901af339a4189d5ce4f2c3118bfb99430734f355159602f177bc8d1b345c3a2f17947a62547553f7b91747a1f16da063707a4da7f990391d HEAD_REF master + PATCHES find-package.patch ) endif() # Configure the library, using CMake vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA OPTIONS -DIO2D_WITHOUT_SAMPLES=1 -DIO2D_WITHOUT_TESTS=1 + -DCMAKE_INSTALL_INCLUDEDIR:STRING=include ) # Build + install the library, using CMake @@ -38,26 +40,17 @@ vcpkg_install_cmake() # (within /installed/io2d_*/, as installed by vcpkg_install_cmake()): file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -# Don't have duplicate CMake files -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake) +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/io2d) -# Make sure CMake files are installed to the correct location -file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/io2d) -file(RENAME ${CURRENT_PACKAGES_DIR}/lib/cmake ${CURRENT_PACKAGES_DIR}/share/io2d/cmake) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/io2d/io2dConfig.cmake ${CURRENT_PACKAGES_DIR}/share/io2d/io2dTargets.cmake) +file(WRITE ${CURRENT_PACKAGES_DIR}/share/io2d/io2dConfig.cmake " +include(CMakeFindDependencyMacro) +find_dependency(unofficial-cairo CONFIG) +find_dependency(unofficial-graphicsmagick CONFIG) -# Remove separate io2d directory (dludwig@pobox.com: should this always be true? Whither -# a single 'io2d.h' file, with sub-headers within a 'io2d' directory, lest we spam someone's -# 'include' directory?) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include) +include(\${CMAKE_CURRENT_LIST_DIR}/io2dTargets.cmake) +") -# [Re]install io2d headers, using a (currently) flat structure -file( - GLOB IO2D_HEADERS - "${SOURCE_PATH}/P0267_RefImpl/P0267_RefImpl/*.h" - "${SOURCE_PATH}/P0267_RefImpl/P0267_RefImpl/cairo/*.h" - "${SOURCE_PATH}/P0267_RefImpl/P0267_RefImpl/cairo/win32/*.h" -) -file(INSTALL ${IO2D_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include) - -# Install a copyright file, as suggested by vcpkg itself file(INSTALL ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/io2d RENAME copyright) + +vcpkg_test_cmake(PACKAGE_NAME io2d) diff --git a/ports/libjpeg-turbo/portfile.cmake b/ports/libjpeg-turbo/portfile.cmake index 7f6bc49732..c077fd16c4 100644 --- a/ports/libjpeg-turbo/portfile.cmake +++ b/ports/libjpeg-turbo/portfile.cmake @@ -1,11 +1,4 @@ include(vcpkg_common_functions) -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO libjpeg-turbo/libjpeg-turbo - REF 1.5.3 - SHA512 0e7a2cd9943b610f49b562c20a5c350a50326a87bce1d39f14fe45760ed2f89a0d2d3e3f0de9f6a7714f566aabadec6b2422b592591ebb98bbad600ea411fea7 - HEAD_REF master -) vcpkg_download_distfile(GETENV_PATCH URLS "https://github.com/libjpeg-turbo/libjpeg-turbo/commit/bd96b30b74fe166fc94218cfc64a097fafdcc05f.diff" @@ -13,10 +6,15 @@ vcpkg_download_distfile(GETENV_PATCH SHA512 4cd064521b5e4baba4adf972f9f574f6dd43a2cd3e3ad143ca2cdf0f165024406d4fd2ed094124d0c17c5370394140e82fdd892d3cdc49609acdf8f79db1758c ) -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES "${CMAKE_CURRENT_LIST_DIR}/add-options-for-exes-docs-headers.patch" - "${CMAKE_CURRENT_LIST_DIR}/linux-cmake.patch" +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libjpeg-turbo/libjpeg-turbo + REF 1.5.3 + SHA512 0e7a2cd9943b610f49b562c20a5c350a50326a87bce1d39f14fe45760ed2f89a0d2d3e3f0de9f6a7714f566aabadec6b2422b592591ebb98bbad600ea411fea7 + HEAD_REF master + PATCHES + add-options-for-exes-docs-headers.patch + linux-cmake.patch "${GETENV_PATCH}" ) @@ -67,3 +65,6 @@ file(COPY file(RENAME ${CURRENT_PACKAGES_DIR}/share/libjpeg-turbo/LICENSE.md ${CURRENT_PACKAGES_DIR}/share/libjpeg-turbo/copyright) vcpkg_copy_pdbs() file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/jpeg) + +vcpkg_test_cmake(PACKAGE_NAME JPEG MODULE) diff --git a/ports/libjpeg-turbo/vcpkg-cmake-wrapper.cmake b/ports/libjpeg-turbo/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000000..5b0dae6c77 --- /dev/null +++ b/ports/libjpeg-turbo/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,28 @@ +_find_package(${ARGS}) +if(JPEG_FOUND AND NOT TARGET JPEG::JPEG) + # Backfill JPEG::JPEG to versions of cmake before 3.12 + add_library(JPEG::JPEG UNKNOWN IMPORTED) + if(DEFINED JPEG_INCLUDE_DIRS) + set_target_properties(JPEG::JPEG PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}") + endif() + if(EXISTS "${JPEG_LIBRARY}") + set_target_properties(JPEG::JPEG PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${JPEG_LIBRARY}") + endif() + if(EXISTS "${JPEG_LIBRARY_RELEASE}") + set_property(TARGET JPEG::JPEG APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(JPEG::JPEG PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}") + endif() + if(EXISTS "${JPEG_LIBRARY_DEBUG}") + set_property(TARGET JPEG::JPEG APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(JPEG::JPEG PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}") + endif() +endif() diff --git a/ports/pixman/CMakeLists.txt b/ports/pixman/CMakeLists.txt index 8dc9940cb0..d355fe8c61 100644 --- a/ports/pixman/CMakeLists.txt +++ b/ports/pixman/CMakeLists.txt @@ -46,14 +46,14 @@ file(GLOB SOURCES ) add_library(pixman-1 ${SOURCES}) +target_include_directories(pixman-1 PUBLIC $) # pixman requires the three PACKAGE* definitions in order to compile. The USE_SSE2 definition lets it use SSE2 instructions for speed. Every target machine should have SSE2 these days. target_compile_definitions(pixman-1 - PUBLIC + PRIVATE PACKAGE="pixman-1" PACKAGE_VERSION="0.34.0" PACKAGE_BUGREPORT="" - PRIVATE USE_SSE2 ) @@ -63,7 +63,15 @@ if(MSVC) endif() install(TARGETS pixman-1 + EXPORT pixman-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) + +install( + EXPORT pixman-targets + NAMESPACE unofficial::pixman:: + FILE unofficial-pixman-config.cmake + DESTINATION share/unofficial-pixman +) diff --git a/ports/pixman/CONTROL b/ports/pixman/CONTROL index 0deb60d331..d3a5cede7a 100644 --- a/ports/pixman/CONTROL +++ b/ports/pixman/CONTROL @@ -1,3 +1,3 @@ Source: pixman -Version: 0.34.0-3 +Version: 0.34.0-4 Description: Pixman is a low-level software library for pixel manipulation, providing features such as image compositing and trapezoid rasterization. diff --git a/ports/pixman/portfile.cmake b/ports/pixman/portfile.cmake index 4fb37f6d99..83daa9a516 100644 --- a/ports/pixman/portfile.cmake +++ b/ports/pixman/portfile.cmake @@ -1,13 +1,16 @@ include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/pixman-0.34.0) - +set(PIXMAN_VERSION 0.34.0) vcpkg_download_distfile(ARCHIVE - URLS "https://www.cairographics.org/releases/pixman-0.34.0.tar.gz" - FILENAME "pixman-0.34.0.tar.gz" + URLS "https://www.cairographics.org/releases/pixman-${PIXMAN_VERSION}.tar.gz" + FILENAME "pixman-${PIXMAN_VERSION}.tar.gz" SHA512 81caca5b71582b53aaac473bc37145bd66ba9acebb4773fa8cdb51f4ed7fbcb6954790d8633aad85b2826dd276bcce725e26e37997a517760e9edd72e2669a6d ) -vcpkg_extract_source_archive(${ARCHIVE}) +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + REF ${PIXMAN_VERSION} +) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}/pixman) @@ -18,6 +21,8 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-pixman TARGET_PATH share/unofficial-pixman) + # Copy the appropriate header files. file(COPY "${SOURCE_PATH}/pixman/pixman.h" @@ -36,3 +41,5 @@ file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/pixma file(RENAME ${CURRENT_PACKAGES_DIR}/share/pixman/COPYING ${CURRENT_PACKAGES_DIR}/share/pixman/copyright) vcpkg_copy_pdbs() + +vcpkg_test_cmake(PACKAGE_NAME unofficial-pixman) diff --git a/ports/tiff/portfile.cmake b/ports/tiff/portfile.cmake index 5ff4baa929..7062c1ce1e 100644 --- a/ports/tiff/portfile.cmake +++ b/ports/tiff/portfile.cmake @@ -1,21 +1,20 @@ include(vcpkg_common_functions) set(LIBTIFF_VERSION 4.0.9) -set(LIBTIFF_HASH 04f3d5eefccf9c1a0393659fe27f3dddd31108c401ba0dc587bca152a1c1f6bc844ba41622ff5572da8cc278593eff8c402b44e7af0a0090e91d326c2d79f6cd) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/tiff-${LIBTIFF_VERSION}) vcpkg_download_distfile(ARCHIVE URLS "http://download.osgeo.org/libtiff/tiff-${LIBTIFF_VERSION}.tar.gz" FILENAME "tiff-${LIBTIFF_VERSION}.tar.gz" - SHA512 ${LIBTIFF_HASH} + SHA512 04f3d5eefccf9c1a0393659fe27f3dddd31108c401ba0dc587bca152a1c1f6bc844ba41622ff5572da8cc278593eff8c402b44e7af0a0090e91d326c2d79f6cd ) -vcpkg_extract_source_archive(${ARCHIVE}) - -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES ${CMAKE_CURRENT_LIST_DIR}/add-component-options.patch - ${CMAKE_CURRENT_LIST_DIR}/fix-cxx-shared-libs.patch - ${CMAKE_CURRENT_LIST_DIR}/crt-secure-no-deprecate.patch +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + REF ${LIBTIFF_VERSION} + PATCHES + add-component-options.patch + fix-cxx-shared-libs.patch + crt-secure-no-deprecate.patch ) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") @@ -53,5 +52,8 @@ file(INSTALL DESTINATION ${CURRENT_PACKAGES_DIR}/share/tiff RENAME copyright ) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/tiff) vcpkg_copy_pdbs() + +vcpkg_test_cmake(PACKAGE_NAME TIFF MODULE) diff --git a/ports/tiff/usage b/ports/tiff/usage new file mode 100644 index 0000000000..d5312603a5 --- /dev/null +++ b/ports/tiff/usage @@ -0,0 +1,4 @@ +The package tiff is compatible with built-in CMake targets: + + find_package(TIFF REQUIRED) + target_link_libraries(main PRIVATE TIFF::TIFF) diff --git a/ports/tiff/vcpkg-cmake-wrapper.cmake b/ports/tiff/vcpkg-cmake-wrapper.cmake index fed3875b8b..8edcb5e438 100644 --- a/ports/tiff/vcpkg-cmake-wrapper.cmake +++ b/ports/tiff/vcpkg-cmake-wrapper.cmake @@ -8,15 +8,16 @@ if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") endif() find_package(JPEG) - list(APPEND TIFF_EXTRA_LIBRARIES ${JPEG_LIBRARIES}) - find_package(ZLIB) if(TARGET TIFF::TIFF) - set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${TIFF_EXTRA_LIBRARIES} ZLIB::ZLIB) + set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${TIFF_EXTRA_LIBRARIES} JPEG::JPEG ZLIB::ZLIB) + if(UNIX) + set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES m) + endif() endif() if(TIFF_LIBRARIES) - list(APPEND TIFF_LIBRARIES ${TIFF_EXTRA_LIBRARIES} ${ZLIB_LIBRARIES}) + list(APPEND TIFF_LIBRARIES ${TIFF_EXTRA_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES}) if(UNIX) list(APPEND TIFF_LIBRARIES m) endif()