From 3eeaf564d1714ee533c59e7c79cf5e19a1b4e983 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Fri, 3 Aug 2018 16:14:51 +0900 Subject: [PATCH] [libgeotiff] support linux build (#3843) * [libgeotiff] fix compile on linux Fix cmake libtiff functions detetion failure caused by finding no functions in libm. Signed-off-by: Hiroshi Miura * [libgeotiff] fix utility binary handling in linux Signed-off-by: Hiroshi Miura * [tiff] Fix static transitive dependencies * [libgeotiff] Fix .dll and .exe manipulation * [leptonica] Find dependencies in installed cmake config file * [tiff] Do not add cmake targets to TIFF_LIBRARIES * [tiff] Link consumers against m on unix platforms --- ports/leptonica/CONTROL | 2 +- ports/leptonica/find-dependency.patch | 18 +++++++++ ports/leptonica/portfile.cmake | 5 +-- .../0003-Fix-cmake-TIFF-detection.patch | 36 ----------------- ports/libgeotiff/CONTROL | 2 +- ports/libgeotiff/portfile.cmake | 40 ++++++++++--------- ports/tiff/CONTROL | 2 +- ports/tiff/portfile.cmake | 6 +++ ports/tiff/vcpkg-cmake-wrapper.cmake | 24 +++++++++++ 9 files changed, 73 insertions(+), 62 deletions(-) create mode 100644 ports/leptonica/find-dependency.patch delete mode 100644 ports/libgeotiff/0003-Fix-cmake-TIFF-detection.patch create mode 100644 ports/tiff/vcpkg-cmake-wrapper.cmake diff --git a/ports/leptonica/CONTROL b/ports/leptonica/CONTROL index 2be42f327c..e3543173ff 100644 --- a/ports/leptonica/CONTROL +++ b/ports/leptonica/CONTROL @@ -1,4 +1,4 @@ Source: leptonica -Version: 1.74.4-3 +Version: 1.74.4-5 Description: An open source library containing software that is broadly useful for image processing and image analysis applications Build-Depends: libjpeg-turbo, zlib, libpng, tiff, giflib diff --git a/ports/leptonica/find-dependency.patch b/ports/leptonica/find-dependency.patch new file mode 100644 index 0000000000..46348833e3 --- /dev/null +++ b/ports/leptonica/find-dependency.patch @@ -0,0 +1,18 @@ +diff --git a/cmake/templates/LeptonicaConfig.cmake.in b/cmake/templates/LeptonicaConfig.cmake.in +index d53904a..2aa2fea 100644 +--- a/cmake/templates/LeptonicaConfig.cmake.in ++++ b/cmake/templates/LeptonicaConfig.cmake.in +@@ -20,6 +20,13 @@ + # + # =================================================================================== + ++include(CMakeFindDependencyMacro) ++find_dependency(TIFF) ++find_dependency(ZLIB) ++find_dependency(PNG) ++find_dependency(JPEG) ++find_dependency(GIF) ++ + include(${CMAKE_CURRENT_LIST_DIR}/LeptonicaTargets.cmake) + + # ====================================================== diff --git a/ports/leptonica/portfile.cmake b/ports/leptonica/portfile.cmake index acaf7fe9d0..156ed3dd2a 100644 --- a/ports/leptonica/portfile.cmake +++ b/ports/leptonica/portfile.cmake @@ -6,13 +6,10 @@ vcpkg_from_github( REF 1.74.4 SHA512 3b9d0be937883f733f72cbdf0b624ec245d9256a8b4622997f437d309efd7ad9695ad1cbe2224d543eb3ef8c44833567b3cc9a95e9a774ef9046b7acaf0ae744 HEAD_REF master -) - -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} PATCHES ${CMAKE_CURRENT_LIST_DIR}/fix-cmakelists.patch ${CMAKE_CURRENT_LIST_DIR}/use-tiff-libraries.patch + ${CMAKE_CURRENT_LIST_DIR}/find-dependency.patch ) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" STATIC) diff --git a/ports/libgeotiff/0003-Fix-cmake-TIFF-detection.patch b/ports/libgeotiff/0003-Fix-cmake-TIFF-detection.patch deleted file mode 100644 index 14929e10c2..0000000000 --- a/ports/libgeotiff/0003-Fix-cmake-TIFF-detection.patch +++ /dev/null @@ -1,36 +0,0 @@ -From bc0003ab3d94f271b27f6897259b734709a5d6cf Mon Sep 17 00:00:00 2001 -From: Hiroshi Miura -Date: Wed, 14 Feb 2018 12:32:11 +0900 -Subject: [PATCH 3/5] Fix cmake TIFF detection - -Signed-off-by: Hiroshi Miura ---- - CMakeLists.txt | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 55ececf..1e2fe3d 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -191,7 +191,8 @@ IF(WITH_TIFF) - IF(TIFF_FOUND) - # Confirm required API is available - INCLUDE(CheckFunctionExists) -- SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES}) -+ FIND_PACKAGE(LibLZMA) -+ SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${LIBLZMA_LIBRARIES}) - - CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN) - IF(NOT HAVE_TIFFOPEN) -@@ -204,7 +205,7 @@ IF(WITH_TIFF) - SET(TIFF_FOUND) # ReSET to NOT found for TIFF library - MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFMergeFieldInfo function not found. libtiff 3.6.0 Beta or later required. Please upgrade or use an older version of libgeotiff") - ENDIF() -- -+ SET(CMAKE_REQUIRED_LIBRARIES) - INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) - ADD_DEFINITIONS(-DHAVE_TIFF=1) - ENDIF(TIFF_FOUND) --- -2.16.1 - diff --git a/ports/libgeotiff/CONTROL b/ports/libgeotiff/CONTROL index abd2fbdc5f..8e8dbc3efa 100644 --- a/ports/libgeotiff/CONTROL +++ b/ports/libgeotiff/CONTROL @@ -1,4 +1,4 @@ Source: libgeotiff -Version: 1.4.2-3 +Version: 1.4.2-4 Description: Libgeotiff is an open source library normally hosted on top of ​libtiff for reading, and writing GeoTIFF information tags. Build-Depends: tiff, proj4, zlib, libjpeg-turbo diff --git a/ports/libgeotiff/portfile.cmake b/ports/libgeotiff/portfile.cmake index 65e5fa436b..3f0e1aac0b 100644 --- a/ports/libgeotiff/portfile.cmake +++ b/ports/libgeotiff/portfile.cmake @@ -2,55 +2,57 @@ include(vcpkg_common_functions) set(LIBGEOTIFF_VERSION 1.4.2) set(LIBGEOTIFF_HASH 059c6e05eb0c47f17b102c7217a2e1636e76d622c4d1bdcf0bd89fb3505f3130bffa881e21c73cfd2ca0d6863b81322f85784658ba3539b53b63c3a8f38d1deb) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libgeotiff-${LIBGEOTIFF_VERSION}) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/1/libgeotiff-${LIBGEOTIFF_VERSION}) vcpkg_download_distfile(ARCHIVE URLS "http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-${LIBGEOTIFF_VERSION}.tar.gz" FILENAME "libgeotiff-${LIBGEOTIFF_VERSION}.tar.gz" SHA512 ${LIBGEOTIFF_HASH}) -vcpkg_extract_source_archive(${ARCHIVE}) +vcpkg_extract_source_archive(${ARCHIVE} ${CURRENT_BUILDTREES_DIR}/src/1) vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-Updates-to-CMake-configuration-to-align-with-other-C.patch" "${CMAKE_CURRENT_LIST_DIR}/0002-Fix-directory-output.patch" - "${CMAKE_CURRENT_LIST_DIR}/0003-Fix-cmake-TIFF-detection.patch" "${CMAKE_CURRENT_LIST_DIR}/0004-Fix-libxtiff-installation.patch" "${CMAKE_CURRENT_LIST_DIR}/0005-Control-shared-library-build-with-option.patch" "${CMAKE_CURRENT_LIST_DIR}/0006-Fix-utility-link-error.patch" ) -if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(BUILD_SHARED_LIBS ON) -else() - set(BUILD_SHARED_LIBS OFF) -endif() - vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA - OPTIONS -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} - -DWITH_TIFF=ON - -DWITH_PROJ4=ON - -DWITH_ZLIB=ON - -DWITH_JPEG=ON + OPTIONS + -DWITH_TIFF=ON + -DWITH_PROJ4=ON + -DWITH_ZLIB=ON + -DWITH_JPEG=ON OPTIONS_RELEASE -DWITH_UTILITIES=ON OPTIONS_DEBUG -DWITH_UTILITIES=OFF ) -vcpkg_build_cmake() vcpkg_install_cmake() -vcpkg_copy_pdbs() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/share) file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libgeotiff RENAME copyright) -file(GLOB GEOTIFF_UTILS ${CURRENT_PACKAGES_DIR}/bin/*.exe) +if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + file(GLOB GEOTIFF_UTILS ${CURRENT_PACKAGES_DIR}/bin/*) +else() + file(GLOB GEOTIFF_UTILS ${CURRENT_PACKAGES_DIR}/bin/*.exe) +endif() + file(INSTALL ${GEOTIFF_UTILS} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/libgeotiff/) -file(REMOVE ${GEOTIFF_UTILS}) vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/libgeotiff) -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) +file(GLOB EXES ${CURRENT_PACKAGES_DIR}/bin/*.exe ${CURRENT_PACKAGES_DIR}/debug/bin/*.exe) +if(EXES) + file(REMOVE ${EXES}) +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR (VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin ${CURRENT_PACKAGES_DIR}/bin) endif() + +vcpkg_copy_pdbs() diff --git a/ports/tiff/CONTROL b/ports/tiff/CONTROL index 7a91d1d5bc..710b7a1c23 100644 --- a/ports/tiff/CONTROL +++ b/ports/tiff/CONTROL @@ -1,4 +1,4 @@ Source: tiff -Version: 4.0.9 +Version: 4.0.9-4 Build-Depends: zlib, libjpeg-turbo, liblzma (windows) Description: A library that supports the manipulation of TIFF image files diff --git a/ports/tiff/portfile.cmake b/ports/tiff/portfile.cmake index e14079c310..5ff4baa929 100644 --- a/ports/tiff/portfile.cmake +++ b/ports/tiff/portfile.cmake @@ -42,6 +42,12 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share ${CURRENT_PACKAGES_DIR}/share ) +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/tiff) +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake + ${CURRENT_PACKAGES_DIR}/share/tiff + @ONLY +) file(INSTALL ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/tiff diff --git a/ports/tiff/vcpkg-cmake-wrapper.cmake b/ports/tiff/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000000..fed3875b8b --- /dev/null +++ b/ports/tiff/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,24 @@ +_find_package(${ARGS}) + +if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + set(TIFF_EXTRA_LIBRARIES) + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_package(LibLZMA) + list(APPEND TIFF_EXTRA_LIBRARIES ${LIBLZMA_LIBRARIES}) + 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) + endif() + if(TIFF_LIBRARIES) + list(APPEND TIFF_LIBRARIES ${TIFF_EXTRA_LIBRARIES} ${ZLIB_LIBRARIES}) + if(UNIX) + list(APPEND TIFF_LIBRARIES m) + endif() + endif() +endif()