Skip to content

Commit

Permalink
[libgeotiff] support linux build (#3843)
Browse files Browse the repository at this point in the history
* [libgeotiff] fix compile on linux

Fix cmake libtiff functions detetion failure
caused by finding no functions in libm.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* [libgeotiff] fix utility binary handling in linux

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* [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
  • Loading branch information
miurahr authored and ras0219-msft committed Aug 3, 2018
1 parent 09ccd05 commit 3eeaf56
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 62 deletions.
2 changes: 1 addition & 1 deletion ports/leptonica/CONTROL
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions ports/leptonica/find-dependency.patch
Original file line number Diff line number Diff line change
@@ -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)

# ======================================================
5 changes: 1 addition & 4 deletions ports/leptonica/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 0 additions & 36 deletions ports/libgeotiff/0003-Fix-cmake-TIFF-detection.patch

This file was deleted.

2 changes: 1 addition & 1 deletion ports/libgeotiff/CONTROL
Original file line number Diff line number Diff line change
@@ -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
40 changes: 21 additions & 19 deletions ports/libgeotiff/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion ports/tiff/CONTROL
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions ports/tiff/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions ports/tiff/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 3eeaf56

Please sign in to comment.