From cee4dcae238b6bf2e3d3be67600ee79e056cbb1f Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 12:27:44 -0500 Subject: [PATCH 01/21] implement CI matrix for linux, windows, and osx --- .github/environment.yml | 12 ++++++ .github/workflows/ci-windows.yml | 10 ++--- .github/workflows/test.yml | 66 ++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 .github/environment.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/environment.yml b/.github/environment.yml new file mode 100644 index 0000000..28e69cf --- /dev/null +++ b/.github/environment.yml @@ -0,0 +1,12 @@ +name: build +channels: + - conda-forge +dependencies: + - conda + - mamba + - compilers + - ninja + - cmake + - proj + - ccache + diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index e52c3db..56cc6ea 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -1,4 +1,4 @@ -name: Windows CI +name: Windows VCPKG on: push: @@ -14,10 +14,10 @@ jobs: ARCH: x64 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 id: cache with: path: | @@ -36,7 +36,7 @@ jobs: Invoke-WebRequest -Uri https://sqlite.org/2018/sqlite-tools-win32-x86-3250100.zip -OutFile sqlite-tools-win32-x86-3250100.zip 7z x sqlite-tools-win32-x86-3250100.zip Copy-Item sqlite-tools-win32-x86-3250100/sqlite3.exe . - + - name: Build PROJ if: steps.cache.outputs.cache-hit != 'true' run: | @@ -51,7 +51,7 @@ jobs: cmake -G "Visual Studio 16 2019" -A ${{ env.ARCH }} .. -DCMAKE_BUILD_TYPE=Release -DPROJ_TESTS=OFF -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_TOOLCHAIN_FILE="$vcpkgPath/scripts/buildsystems/vcpkg.cmake" -DCMAKE_INSTALL_PREFIX="$buildRoot/install-proj" cmake --build . --config Release --target install Pop-Location - + - name: Build run: | $buildRoot = "${{ github.workspace }}".Replace("\", "/") diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..733a5b3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,66 @@ + +name: Test +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build: + name: OS ${{ matrix.os }} with BUILD_SHARED_LIBS=${{matrix.shared}} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + shared: [ON, OFF] + + steps: + - uses: actions/checkout@v4 + - uses: ilammy/msvc-dev-cmd@v1 + if: matrix.os == 'windows-latest' + - name: Support longpaths + run: git config --system core.longpaths true + if: matrix.os == 'windows-latest' + - uses: mamba-org/setup-micromamba@v1 + with: + init-shell: bash + environment-file: ./github/environment.yml + environment-name: "build" + cache-environment: true + cache-downloads: true + + - name: Setup + shell: bash -l {0} + run: | + mkdir build + working-directory: ./libgeotiff + + - name: CMake + shell: bash -l {0} + env: + BUILD_SHARED_LIBS: ${{ matrix.shared }} + + run: | + + if [ "$RUNNER_OS" == "Windows" ]; then + export CC=cl.exe + export CXX=cl.exe + fi + + cmake -G "Ninja" \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \ + -DBUILD_TESTING=ON \ + -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \ + .. + + + working-directory: ./libgeotiff/build + + - name: Compile + shell: bash -l {0} + run: | + ninja + working-directory: ./libgeotiff/build + From 9e9348b38b3607529073fcaffddd85d31aef8755 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 12:31:29 -0500 Subject: [PATCH 02/21] dir typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 733a5b3..f48d36a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: - uses: mamba-org/setup-micromamba@v1 with: init-shell: bash - environment-file: ./github/environment.yml + environment-file: ./.github/environment.yml environment-name: "build" cache-environment: true cache-downloads: true From 1b02fd8bf82a4a34f75ee989302641c6a31996ff Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 12:34:46 -0500 Subject: [PATCH 03/21] remove ancient appveyor config --- .appveyor.yml | 69 --------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 7016576..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,69 +0,0 @@ -environment: - matrix: - -# VS 2015 - - VS_VERSION: Visual Studio 14 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - platform: x86 - -# VS 2017 - - VS_VERSION: Visual Studio 15 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - platform: x64 - -shallow_clone: true - -build_script: - - echo build_script - - set "BUILD_FOLDER=%APPVEYOR_BUILD_FOLDER:\=/%" - - if "%platform%" == "x64" SET VS_FULL=%VS_VERSION% Win64 - - if "%platform%" == "x86" SET VS_FULL=%VS_VERSION% - - echo "%VS_FULL%" -# Build vcpkg - - git clone https://github.com/microsoft/vcpkg - - cd vcpkg - # Remove this after this is fixed: https://github.com/microsoft/vcpkg/issues/33904 - - git checkout 2023.08.09 - - bootstrap-vcpkg.bat - - set PATH=%CD%;%PATH% - - cd .. -# Install libtiff - - vcpkg install tiff:"%platform%"-windows -# Build libtiff -# - git clone --depth=1 https://gitlab.com/libtiff/libtiff -# - cd libtiff -# - mkdir build_cmake -# - cd build_cmake -# - cmake -G "%VS_FULL%" .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%BUILD_FOLDER%/install" -# - cmake --build . --config Release --target install -# - cd .. -# - cd .. -# Install sqlite (PROJ dependency) - - vcpkg install sqlite3:"%platform%"-windows - - ps: | - appveyor DownloadFile https://sqlite.org/2018/sqlite-tools-win32-x86-3250100.zip - 7z x sqlite-tools-win32-x86-3250100.zip - copy sqlite-tools-win32-x86-3250100/sqlite3.exe . -# Build PROJ - - git clone --depth=1 -b 6.3 https://github.com/OSGeo/PROJ proj - - cd proj - - mkdir build - - cd build - - copy ..\..\sqlite3.exe . - - copy c:\projects\libgeotiff\vcpkg\installed\%platform%-windows\bin\sqlite3.dll . - - set PATH=%CD%;%PATH% - - cmake -G "%VS_FULL%" .. -DCMAKE_BUILD_TYPE=Release -DPROJ_TESTS=OFF -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_TOOLCHAIN_FILE=c:/projects/libgeotiff/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX="%BUILD_FOLDER%/install" - - cmake --build . --config Release --target install - - cd .. - - cd .. -# Build libgeotiff - - cd libgeotiff - - mkdir build - - cd build - - cmake -G "%VS_FULL%" .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="/WX" -DCMAKE_CXX_FLAGS="/WX" -DCMAKE_INSTALL_PREFIX="%BUILD_FOLDER%/install" -DPROJ_INCLUDE_DIR="%BUILD_FOLDER%/install/include" -DPROJ_LIBRARY="%BUILD_FOLDER%/install/lib/proj.lib" -DCMAKE_TOOLCHAIN_FILE=c:/projects/libgeotiff/vcpkg/scripts/buildsystems/vcpkg.cmake - - cmake --build . --config Release --target install - -test_script: - -deploy: off - From ca96c0ab112d345fbbe7b40134ddf40697f0dda5 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 12:38:06 -0500 Subject: [PATCH 04/21] we need libtiff too --- .github/environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/environment.yml b/.github/environment.yml index 28e69cf..2268864 100644 --- a/.github/environment.yml +++ b/.github/environment.yml @@ -9,4 +9,5 @@ dependencies: - cmake - proj - ccache + - libtiff From c38b1f74bf81c7c6115e6bb31144c9b17c2b5cc7 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 12:45:07 -0500 Subject: [PATCH 05/21] explicit turn on of tiff/jpeg/zlib --- .github/environment.yml | 2 ++ .github/workflows/test.yml | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.github/environment.yml b/.github/environment.yml index 2268864..1e4e0d1 100644 --- a/.github/environment.yml +++ b/.github/environment.yml @@ -10,4 +10,6 @@ dependencies: - proj - ccache - libtiff + - zlib + - libjpeg-turbo diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f48d36a..30576c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,6 +53,12 @@ jobs: -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \ -DBUILD_TESTING=ON \ -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \ + -DWITH_ZLIB=ON \ + -DWITH_JPEG=ON \ + -DWITH_TIFF=ON \ + -DTIFF_NAMES=tiff \ + -DPROJ_NAMES=proj \ + -DJPEG_NAMES=libjpeg \ .. From c60f8de97a552790735fdc391a2d4ca3f9a1cfff Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 12:57:07 -0500 Subject: [PATCH 06/21] remove travis config --- .travis.yml | 72 ----------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 62507bf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,72 +0,0 @@ -matrix: - fast_finish: true - include: - - - os: linux - compiler: gcc - language: cpp - sudo: required - dist: jammy - env: - - BUILD_NAME=linux - - - os: osx - osx_image: xcode14.2 - compiler: clang - cache: - apt: true - directories: - - $HOME/.ccache - env: - - BUILD_NAME=osx - - CC=clang - - CXX=clang++ - addons: - homebrew: - packages: - - ccache - -cache: - directories: - - $HOME/.ccache - -before_install: - - if test "$TRAVIS_OS_NAME" = "linux"; then sudo apt install g++ libjpeg-dev libz-dev libtiff-dev libsqlite3-dev; fi - - if test "$TRAVIS_OS_NAME" = "osx"; then brew update; brew install ccache; fi - -install: - - git clone --depth=1 https://github.com/OSGeo/PROJ proj - - export CC="ccache $CC" - - export CXX="ccache $CXX" - - $CC --version - - (cd proj && cmake . -DBUILD_APPS=OFF -DPROJ_TESTS=OFF && make -j3 && sudo make install && (if test "$TRAVIS_OS_NAME" = "linux"; then sudo ldconfig; fi)) - - cd libgeotiff - - ./autogen.sh - - ./configure - - make dist - - mkdir libgeotiff - - cat libgeotiff*.tar.gz | tar xz -C libgeotiff --strip-components=1 - - cd libgeotiff - - mkdir build_autoconf - - cd build_autoconf - - CFLAGS="-Wall -Wextra -Werror" ../configure - - make -j3 - - make check - - cd .. - - mkdir build_cmake - - cd build_cmake - - cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_C_FLAGS="-Wall -Wextra -Werror" - - make -j3 - -script: - - echo "done" - -notifications: - #email: - # recipients: - # - gdal-commits@lists.osgeo.org - - irc: - channels: - - "irc.freenode.org#gdal" - use_notice: true From 74c3dcda24dea9d05a3f62baf17f9a4ad782f17e Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 14:32:55 -0500 Subject: [PATCH 07/21] attempt to modernize cmake a bit --- libgeotiff/CMakeLists.txt | 204 ++++++++++++++--------------- libgeotiff/bin/CMakeLists.txt | 3 +- libgeotiff/cmake/FindGeoTIFF.cmake | 119 +++++++++++------ libgeotiff/cmake/FindPROJ.cmake | 135 ++++++++++++------- libgeotiff/makefile.mpw | 49 ------- libgeotiff/makefile.vc | 140 -------------------- 6 files changed, 268 insertions(+), 382 deletions(-) delete mode 100644 libgeotiff/makefile.mpw delete mode 100644 libgeotiff/makefile.vc diff --git a/libgeotiff/CMakeLists.txt b/libgeotiff/CMakeLists.txt index ec02e0c..2d638ed 100644 --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt @@ -5,7 +5,7 @@ # Author: Mateusz Loskot # ############################################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) +CMAKE_MINIMUM_REQUIRED(VERSION 3.13) PROJECT(GeoTIFF) @@ -73,33 +73,7 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) # SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY}) SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -############################################################################### -# Platform and compiler specific settings - -IF(WIN32) - IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_AS_DLL=1) - ENDIF() - IF(MSVC) - ADD_DEFINITIONS(/DW4) - if (NOT (MSVC_VERSION VERSION_LESS 1400)) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING) - ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) - endif() - ENDIF(MSVC) -ENDIF() -IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") - IF(GEOTIFF_BUILD_PEDANTIC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") - ENDIF() -ENDIF() # Check required standard headers INCLUDE(CheckIncludeFiles) @@ -113,82 +87,18 @@ SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if GeoTIFF utilities should be built" ############################################################################### # Search for dependencies -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) # TIFF support - required, default=ON SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") -FIND_PACKAGE(PROJ NO_MODULE QUIET) -if (NOT PROJ_FOUND) - FIND_PACKAGE(PROJ) -endif () - -IF(PROJ_FOUND) - INCLUDE_DIRECTORIES(${PROJ_INCLUDE_DIR}) -ELSE() - MESSAGE(FATAL_ERROR "Failed to detect PROJ >= 6") -ENDIF() +FIND_PACKAGE(PROJ NO_MODULE REQUIRED) # Zlib support - optional, default=OFF SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built") -IF(WITH_ZLIB) - FIND_PACKAGE(ZLIB NO_MODULE QUIET) - if (NOT ZLIB_FOUND) - FIND_PACKAGE(ZLIB) - endif () - - IF(ZLIB_FOUND) - SET(HAVE_ZIP 1) - INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) - ADD_DEFINITIONS(-DHAVE_ZIP=${HAVE_ZIP}) - ENDIF() -ENDIF() - # JPEG support - optional, default=OFF SET(WITH_JPEG FALSE CACHE BOOL "Choose if JPEG support should be built") -IF(WITH_JPEG) - FIND_PACKAGE(JPEG NO_MODULE QUIET) - if (NOT JPEG_FOUND) - FIND_PACKAGE(JPEG) - endif () - - IF(JPEG_FOUND) - SET(HAVE_JPEG 1) - INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) - ADD_DEFINITIONS(-DHAVE_JPEG=${HAVE_JPEG}) - ENDIF() -ENDIF() - -IF(WITH_TIFF) - FIND_PACKAGE(TIFF NO_MODULE QUIET) - if (NOT TIFF_FOUND) - FIND_PACKAGE(TIFF REQUIRED) - endif () - - IF(TIFF_FOUND) - # Confirm required API is available - INCLUDE(CheckFunctionExists) - SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES}) - - CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN) - IF(NOT HAVE_TIFFOPEN) - SET(TIFF_FOUND) # ReSET to NOT found for TIFF library - MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found") - ENDIF() - - CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO) - IF(NOT HAVE_TIFFMERGEFIELDINFO) - 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() - - INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) - ADD_DEFINITIONS(-DHAVE_TIFF=1) - ENDIF(TIFF_FOUND) -ENDIF(WITH_TIFF) # Turn off TOWGS84 support SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support") @@ -255,10 +165,6 @@ INSTALL(FILES ${GEOTIFF_MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) # Install header files for development distribution INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -############################################################################### -# Build libxtiff library - -ADD_SUBDIRECTORY(libxtiff) ############################################################################### # Build libgeotiff library @@ -290,6 +196,66 @@ endif () ADD_LIBRARY(${GEOTIFF_LIBRARY_TARGET} ${GEOTIFF_LIB_SOURCES} ${XTIFF_SOURCES}) +set_property(TARGET ${GEOTIFF_LIBRARY_TARGET} PROPERTY CXX_STANDARD 98) +set_property(TARGET ${GEOTIFF_LIBRARY_TARGET} PROPERTY C_STANDARD 99) +set_property(TARGET ${GEOTIFF_LIBRARY_TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET ${GEOTIFF_LIBRARY_TARGET} PROPERTY OUTPUT_NAME ${GEOTIFF_LIB_NAME}) + +IF(WITH_JPEG) + FIND_PACKAGE(JPEG NO_MODULE QUIET CONFIG) + if (NOT JPEG_FOUND) + FIND_PACKAGE(JPEG CONFIG) + endif () + + IF(JPEG_FOUND) + SET(HAVE_JPEG 1) + TARGET_INCLUDE_DIRECTORIES(${GEOTIFF_LIBRARY_TARGET} PRIVATE ${JPEG_INCLUDE_DIR}) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -DHAVE_JPEG=${HAVE_JPEG}) + ENDIF() +ENDIF() + + +IF(WITH_TIFF) + FIND_PACKAGE(TIFF NO_MODULE QUIET) + if (NOT TIFF_FOUND) + FIND_PACKAGE(TIFF REQUIRED) + endif () + + IF(TIFF_FOUND) + # Confirm required API is available + INCLUDE(CheckFunctionExists) + SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES}) + + CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN) + IF(NOT HAVE_TIFFOPEN) + SET(TIFF_FOUND) # ReSET to NOT found for TIFF library + MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found") + ENDIF() + + CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO) + IF(NOT HAVE_TIFFMERGEFIELDINFO) + 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() + + TARGET_INCLUDE_DIRECTORIES(${GEOTIFF_LIBRARY_TARGET} PRIVATE ${TIFF_INCLUDE_DIR}) + TARGET_COMPILE_DEFINITIONS(${GEOTIFF_LIBRARY_TARGET} PRIVATE -DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) +ENDIF(WITH_TIFF) + +IF(WITH_ZLIB) + FIND_PACKAGE(ZLIB REQUIRED ) + IF(ZLIB_FOUND) + SET(HAVE_ZIP 1) + TARGET_INCLUDE_DIRECTORIES(${GEOTIFF_LIBRARY_TARGET} PRIVATE ${ZLIB_INCLUDE_DIR}) + TARGET_COMPILE_DEFINITIONS(${GEOTIFF_LIBRARY_TARGET} PRIVATE -DHAVE_ZIP=${HAVE_ZIP}) + ENDIF() +ENDIF() + +TARGET_INCLUDE_DIRECTORIES(${GEOTIFF_LIBRARY_TARGET} PUBLIC + $ + $ + $) IF(WIN32 AND MSVC) SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES IMPORT_SUFFIX "_i.lib") ENDIF(WIN32 AND MSVC) @@ -310,8 +276,31 @@ if(UNIX) endif() endif() -SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES - OUTPUT_NAME ${GEOTIFF_LIB_NAME}) +############################################################################### +# Platform and compiler specific settings + +IF(WIN32) + IF(BUILD_SHARED_LIBS) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -DBUILD_AS_DLL=1) + ENDIF() + IF(MSVC) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE /DW4) + if (NOT (MSVC_VERSION VERSION_LESS 1400)) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -D_CRT_SECURE_NO_DEPRECATE) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -D_CRT_SECURE_NO_WARNINGS) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -D_CRT_NONSTDC_NO_WARNING) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -D_SCL_SECURE_NO_WARNINGS) + endif() + ENDIF(MSVC) +ENDIF() + +IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -Wall -Wno-long-long ) + IF(GEOTIFF_BUILD_PEDANTIC) + target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -pedantic) + ENDIF() +ENDIF() + set(CONFIG_PUBLIC_DEPENDENCIES "") set(CONFIG_PRIVATE_DEPENDENCIES "") @@ -324,15 +313,22 @@ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PUBLIC if(TARGET PROJ::proj) set(PROJ_LIBRARIES PROJ::proj) - string(APPEND CONFIG_PRIVATE_DEPENDENCIES " find_dependency(PROJ CONFIG)\n") + string(APPEND CONFIG_PRIVATE_DEPENDENCIES " find_dependency(PROJ)\n") endif() + +if(TARGET ZLIB::zlib) + set(ZLIB_LIBRARIES ZLIB::zlib) + string(APPEND CONFIG_PRIVATE_DEPENDENCIES " find_dependency(ZLIB)\n") +endif() + target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PRIVATE - ${PROJ_LIBRARIES}) + ${PROJ_LIBRARIES} + ${TIFF_LIBRARIES} + ${ZLIB_LIBRARIES}) -target_include_directories( - ${GEOTIFF_LIBRARY_TARGET} - PUBLIC $ - $) +target_include_directories( ${GEOTIFF_LIBRARY_TARGET} PUBLIC + $ + $) INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET} EXPORT depends diff --git a/libgeotiff/bin/CMakeLists.txt b/libgeotiff/bin/CMakeLists.txt index c61585c..87957b1 100644 --- a/libgeotiff/bin/CMakeLists.txt +++ b/libgeotiff/bin/CMakeLists.txt @@ -22,13 +22,12 @@ MESSAGE(STATUS "Adding GeoTIFF utilities to build") FOREACH(utility ${GEOTIFF_UTILITIES}) ADD_EXECUTABLE(${utility} ${utility}.c ${GETOPT_SOURCE}) - TARGET_LINK_LIBRARIES(${utility} PRIVATE xtiff ${GEOTIFF_LIBRARY_TARGET}) + TARGET_LINK_LIBRARIES(${utility} PRIVATE ${GEOTIFF_LIBRARY_TARGET}) ENDFOREACH() ADD_EXECUTABLE(geotifcp geotifcp.c ${GETOPT_SOURCE}) TARGET_LINK_LIBRARIES(geotifcp PRIVATE - xtiff ${GEOTIFF_LIBRARY_TARGET} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES}) diff --git a/libgeotiff/cmake/FindGeoTIFF.cmake b/libgeotiff/cmake/FindGeoTIFF.cmake index 7d7732f..63b384a 100644 --- a/libgeotiff/cmake/FindGeoTIFF.cmake +++ b/libgeotiff/cmake/FindGeoTIFF.cmake @@ -5,12 +5,16 @@ # On success, the macro sets the following variables: # GEOTIFF_FOUND = if the library found # GEOTIFF_LIBRARIES = full path to the library -# GEOTIFF_INCLUDE_DIR = where to find the library headers +# GEOTIFF_INCLUDE_DIR = where to find the library headers # also defined, but not for general use are -# GEOTIFF_LIBRARY, where to find the PROJ.4 library. +# GEOTIFF_LIBRARY # # Copyright (c) 2009 Mateusz Loskot +# Copyright (c) 2016 NextGIS +# Copyright (C) 2017,2018 Hiroshi Miura # +# Origin from +# https://svn.osgeo.org/metacrs/geotiff/trunk/libgeotiff/cmake/FindGeoTIFF.cmake # Module source: http://github.com/mloskot/workshop/tree/master/cmake/ # # Redistribution and use is allowed according to the terms of the BSD license. @@ -18,54 +22,83 @@ # ############################################################################### -SET(GEOTIFF_NAMES geotiff) +find_path(GEOTIFF_INCLUDE_DIR geotiff.h PATH_SUFFIXES geotiff libgeotiff) -IF(WIN32) +set(GEOTIFF_NAMES ${GEOTIFF_NAMES} geotiff geotiff_i) +set(GEOTIFF_NAMES_DEBUG ${GEOTIFF_NAMES_DEBUG} geotiffd geotiff_d geotiff_d_i) - IF(MINGW) - FIND_PATH(GEOTIFF_INCLUDE_DIR - geotiff.h - PATH_PREFIXES geotiff - PATHS - /usr/local/include - /usr/include - c:/msys/local/include) +if(NOT GEOTIFF_LIBRARY) + find_library(GEOTIFF_LIBRARY_RELEASE NAMES ${GEOTIFF_NAMES}) + find_library(GEOTIFF_LIBRARY_DEBUG NAMES ${GEOTIFF_NAMES_DEBUG}) + include(SelectLibraryConfigurations) + select_library_configurations(GEOTIFF) + mark_as_advanced(GEOTIFF_LIBRARY_RELEASE GEOTIFF_LIBRARY_DEBUG) +endif() - FIND_LIBRARY(GEOTIFF_LIBRARY - NAMES ${GEOTIFF_NAMES} - PATHS - /usr/local/lib - /usr/lib - c:/msys/local/lib) - ENDIF(MINGW) +unset(GEOTIFF_NAMES) +unset(GEOTIFF_NAMES_DEBUG) - IF(MSVC) - SET(GEOTIFF_INCLUDE_DIR "$ENV{LIB_DIR}/include" CACHE STRING INTERNAL) - SET(GEOTIFF_NAMES ${GEOTIFF_NAMES} geotiff_i) - FIND_LIBRARY(GEOTIFF_LIBRARY NAMES - NAMES ${GEOTIFF_NAMES} - PATHS - "$ENV{LIB_DIR}/lib" - /usr/lib - c:/msys/local/lib) - ENDIF(MSVC) - -ELSEIF(UNIX) +if(GEOTIFF_INCLUDE_DIR) + set(GEOTIFF_MAJOR_VERSION 0) + set(GEOTIFF_MINOR_VERSION 0) + set(GEOTIFF_PATCH_VERSION 0) + set(GEOTIFF_REVISION_VERSION 0) - FIND_PATH(GEOTIFF_INCLUDE_DIR geotiff.h PATH_PREFIXES geotiff) + if(EXISTS "${GEOTIFF_INCLUDE_DIR}/geotiff.h") + file(READ "${GEOTIFF_INCLUDE_DIR}/geotiff.h" GEOTIFF_H_CONTENTS) + string(REGEX MATCH "LIBGEOTIFF_VERSION[ \t]+([0-9]+)" + LIBGEOTIFF_VERSION ${GEOTIFF_H_CONTENTS}) + string (REGEX MATCH "([0-9]+)" + LIBGEOTIFF_VERSION ${LIBGEOTIFF_VERSION}) - FIND_LIBRARY(GEOTIFF_LIBRARY NAMES ${GEOTIFF_NAMES}) + string(SUBSTRING ${LIBGEOTIFF_VERSION} 0 1 GEOTIFF_MAJOR_VERSION) + string(SUBSTRING ${LIBGEOTIFF_VERSION} 1 1 GEOTIFF_MINOR_VERSION) + string(SUBSTRING ${LIBGEOTIFF_VERSION} 2 1 GEOTIFF_PATCH_VERSION) + string(SUBSTRING ${LIBGEOTIFF_VERSION} 3 1 GEOTIFF_REVISION_VERSION) -ELSE() - MESSAGE("FindGeoTIFF.cmake: unrecognized or unsupported operating system") -ENDIF() + unset(GEOTIFF_H_CONTENTS) + endif() -IF(GEOTIFF_FOUND) - SET(GEOTIFF_LIBRARIES ${GEOTIFF_LIBRARY}) -ENDIF() + set(GEOTIFF_VERSION_STRING "${GEOTIFF_MAJOR_VERSION}.${GEOTIFF_MINOR_VERSION}.${GEOTIFF_PATCH_VERSION}.${GEOTIFF_REVISION_VERSION}") + +endif() +mark_as_advanced(GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GeoTIFF + FOUND_VAR GEOTIFF_FOUND + REQUIRED_VARS GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR + VERSION_VAR GEOTIFF_VERSION_STRING) + +if(GEOTIFF_FOUND) + set(GEOTIFF_LIBRARIES "${GEOTIFF_LIBRARY}") + set(GEOTIFF_INCLUDE_DIRS "${GEOTIFF_INCLUDE_DIR}") + set(GeoTIFF_TARGET GEOTIFF::GEOTIFF) + if(NOT TARGET ${GeoTIFF_TARGET}) + add_library(${GeoTIFF_TARGET} UNKNOWN IMPORTED) + set_target_properties(${GeoTIFF_TARGET} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GEOTIFF_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES C) + if(EXISTS "${GEOTIFF_LIBRARY}") + set_target_properties(${GeoTIFF_TARGET} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${GEOTIFF_LIBRARY}") + endif() + if(EXISTS "${GEOTIFF_LIBRARY_RELEASE}") + set_property(TARGET ${GeoTIFF_TARGET} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${GeoTIFF_TARGET} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${GEOTIFF_LIBRARY_RELEASE}") + endif() + if(EXISTS "${GEOTIFF_LIBRARY_DEBUG}") + set_property(TARGET ${GeoTIFF_TARGET} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${GeoTIFF_TARGET} PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${GEOTIFF_LIBRARY_DEBUG}") + endif() + endif() +endif() -# Handle the QUIETLY and REQUIRED arguments and set SPATIALINDEX_FOUND to TRUE -# if all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GEOTIFF DEFAULT_MSG GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR) diff --git a/libgeotiff/cmake/FindPROJ.cmake b/libgeotiff/cmake/FindPROJ.cmake index f10a0fb..a20ba38 100644 --- a/libgeotiff/cmake/FindPROJ.cmake +++ b/libgeotiff/cmake/FindPROJ.cmake @@ -1,44 +1,91 @@ -############################################################################### -# CMake module to search for PROJ library -# -# On success, the macro sets the following variables: -# PROJ_FOUND = if the library found -# PROJ_LIBRARY = full path to the library -# PROJ_INCLUDE_DIR = where to find the library headers -# also defined, but not for general use are -# PROJ_LIBRARY, where to find the PROJ library. -# -# Copyright (c) 2009 Mateusz Loskot -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# -############################################################################### - -# Try to use OSGeo4W installation -IF(WIN32) - SET(PROJ4_OSGEO4W_HOME "C:/OSGeo4W") - - IF($ENV{OSGEO4W_HOME}) - SET(PROJ4_OSGEO4W_HOME "$ENV{OSGEO4W_HOME}") - ENDIF() -ENDIF(WIN32) - -FIND_PATH(PROJ_INCLUDE_DIR proj.h proj_experimental.h - PATHS ${PROJ_OSGEO4W_HOME}/include - DOC "Path to PROJ library include directory") - -SET(PROJ_NAMES ${PROJ_NAMES} proj proj_i) -FIND_LIBRARY(PROJ_LIBRARY - NAMES ${PROJ_NAMES} - PATHS ${PROJ_OSGEO4W_HOME}/lib - DOC "Path to PROJ library file") - -# Handle the QUIETLY and REQUIRED arguments and set PROJ_FOUND to TRUE -# if all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ DEFAULT_MSG PROJ_LIBRARY PROJ_INCLUDE_DIR) - -IF(PROJ_FOUND) - SET(PROJ_LIBRARIES ${PROJ_LIBRARY}) -ENDIF() +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file COPYING-CMAKE-SCRIPTS or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindPROJ +--------- + +CMake module to search for PROJ(PROJ.4 and PROJ) library + +On success, the macro sets the following variables: +``PROJ_FOUND`` + if the library found + +``PROJ_LIBRARIES`` + full path to the library + +``PROJ_INCLUDE_DIRS`` + where to find the library headers + +``PROJ_VERSION_STRING`` + version string of PROJ + +Copyright (c) 2009 Mateusz Loskot +Copyright (c) 2015 NextGIS +Copyright (c) 2018 Hiroshi Miura + +#]=======================================================================] + +find_path(PROJ_INCLUDE_DIR proj.h + PATHS ${PROJ_ROOT}/include + DOC "Path to PROJ library include directory") + +set(PROJ_NAMES ${PROJ_NAMES} proj proj_i) +set(PROJ_NAMES_DEBUG ${PROJ_NAMES_DEBUG} projd proj_d) + +if(NOT PROJ_LIBRARY) + find_library(PROJ_LIBRARY_RELEASE NAMES ${PROJ_NAMES}) + find_library(PROJ_LIBRARY_DEBUG NAMES ${PROJ_NAMES_DEBUG}) + include(SelectLibraryConfigurations) + select_library_configurations(PROJ) + mark_as_advanced(PROJ_LIBRARY_RELEASE PROJ_LIBRARY_DEBUG) +endif() + +unset(PROJ_NAMES) +unset(PROJ_NAMES_DEBUG) + +if(PROJ_INCLUDE_DIR) + file(READ "${PROJ_INCLUDE_DIR}/proj.h" PROJ_H_CONTENTS) + string(REGEX REPLACE "^.*PROJ_VERSION_MAJOR +([0-9]+).*$" "\\1" PROJ_VERSION_MAJOR "${PROJ_H_CONTENTS}") + string(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${PROJ_H_CONTENTS}") + string(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${PROJ_H_CONTENTS}") + unset(PROJ_H_CONTENTS) + set(PROJ_VERSION_STRING "${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH}") +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PROJ + REQUIRED_VARS PROJ_LIBRARY PROJ_INCLUDE_DIR + VERSION_VAR PROJ_VERSION_STRING) +mark_as_advanced(PROJ_INCLUDE_DIR PROJ_LIBRARY) + +if(PROJ_FOUND) + set(PROJ_LIBRARIES "${PROJ_LIBRARY}") + set(PROJ_INCLUDE_DIRS "${PROJ_INCLUDE_DIR}") + if(NOT TARGET PROJ::proj) + add_library(PROJ::proj UNKNOWN IMPORTED) + set_target_properties(PROJ::proj PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${PROJ_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C") + if(EXISTS "${PROJ_LIBRARY}") + set_target_properties(PROJ::proj PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${PROJ_LIBRARY}") + endif() + if(EXISTS "${PROJ_LIBRARY_RELEASE}") + set_property(TARGET PROJ::proj APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(PROJ::proj PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${PROJ_LIBRARY_RELEASE}") + endif() + if(EXISTS "${PROJ_LIBRARY_DEBUG}") + set_property(TARGET PROJ::proj APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(PROJ::proj PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${PROJ_LIBRARY_DEBUG}") + endif() + endif() +endif() + diff --git a/libgeotiff/makefile.mpw b/libgeotiff/makefile.mpw deleted file mode 100644 index 8a99f82..0000000 --- a/libgeotiff/makefile.mpw +++ /dev/null @@ -1,49 +0,0 @@ -# MPW C Makefile for libgeotiff - -.o Ä .c - C -o {default}.o -I ::libtiff: {default}.c - -XTIFF = :libxtiff:xtiff.o - -CLEANINC= xtiffio.h xtiffiop.h - -OBJECTS = ¶ - {XTIFF} ¶ - geo_free.o ¶ - geo_get.o ¶ - geo_new.o ¶ - geo_names.o ¶ - geo_print.o ¶ - geo_set.o ¶ - geo_tiffp.o ¶ - geo_write.o - -INCLUDES = ¶ - geo_keyp.h ¶ - geo_tiffp.h ¶ - geokeys.h ¶ - geovalues.h ¶ - geonames.h ¶ - geotiff.h - - -ALL = libgeotiff.o - -all Ä {ALL} - -XINCLUDES ÄÄ - cd :libxtiff: - cp -y Å.h :: - cd :: - - -{OBJECTS} ÄÄ {INCLUDES} - -{ALL} Ä XINCLUDES {OBJECTS} - lib -o {ALL} {OBJECTS} - -clean Ä - rm -i {ALL} - rm -i {CLEANINC} - rm -i {OBJECTS} - diff --git a/libgeotiff/makefile.vc b/libgeotiff/makefile.vc deleted file mode 100644 index d80aae0..0000000 --- a/libgeotiff/makefile.vc +++ /dev/null @@ -1,140 +0,0 @@ -# -# Typically the only thing that needs to be changed are the paths to the -# TIFF tree. Note that we expect an existing build tree, in part because we -# need private include files from libtiff, but also we need access to getopt.h. -# in the ports directory. -# -# You may want to add optimization options to the CFLAGS macro as well. -# - -OSGEO4W = c:\OSGeo4W - -TIFF_INC = -I$(OSGEO4W)\include -TIFF_LIB_DLL = $(OSGEO4W)\lib\libtiff_i.lib - -# Installation locations (with install, or devinstall targets) -PREFIX = release -BINDIR = $(PREFIX)\bin -LIBDIR = $(PREFIX)\lib -INCDIR = $(PREFIX)\include - -# -CC = cl -INCL = -I. -Ilibxtiff $(TIFF_INC) - - -# Pick the first LIBS definition for a static libtiff.lib or the second -# to link against the libtiff DLL. - -#LIBS = geotiff.lib $(TIFF_LIB) -LIBS = geotiff_i.lib $(TIFF_LIB_DLL) - -DLLNAME = geotiff.dll - -# Set optimization or debug flags here. -CFLAGS = $(INCL) /MD /Ox /nologo -#CFLAGS = $(INCL) /MD /Zi /nologo - -# -OBJS = \ - xtiff.obj \ - geo_free.obj \ - geo_get.obj \ - geo_names.obj \ - geo_new.obj \ - geo_print.obj \ - geo_set.obj \ - geo_tiffp.obj \ - geo_write.obj \ - geo_extra.obj \ - geo_trans.obj \ - geo_normalize.obj \ - geotiff_proj4.obj \ - geo_simpletags.obj \ - cpl_serv.obj - -all: geo_config.h geotiff.lib $(DLLNAME) listgeo.exe geotifcp.exe - -listgeo.exe: bin\listgeo.c geotiff.lib - $(CC) $(CFLAGS) bin\listgeo.c $(LIBS) - -geotifcp.exe: bin\geotifcp.c geotiff.lib - $(CC) $(CFLAGS) bin\geotifcp.c bin\getopt.c $(LIBS) - -gt_update.exe: bin\gt_update.c geotiff.lib - $(CC) $(CFLAGS) bin\gt_update.c bin\getopt.c geotiff.lib $(LIBS) - -geotiff.lib: $(OBJS) - lib /out:geotiff.lib $(OBJS) - -# -$(DLLNAME): $(OBJS) - link /dll /out:$(DLLNAME) /implib:geotiff_i.lib $(OBJS) $(TIFF_LIB_DLL) - if exist $(DLLNAME).manifest mt -manifest $(DLLNAME).manifest -outputresource:$(DLLNAME);2 - -geo_config.h: geo_config.h.vc - copy geo_config.h.vc geo_config.h - -xtiff.obj: libxtiff\xtiff.c - $(CC) -c $(CFLAGS) libxtiff\xtiff.c - -geo_free.obj: geo_free.c - $(CC) -c $(CFLAGS) geo_free.c - -geo_get.obj: geo_get.c - $(CC) -c $(CFLAGS) geo_get.c - -geo_names.obj: geo_names.c - $(CC) -c $(CFLAGS) geo_names.c - -geo_new.obj: geo_new.c - $(CC) -c $(CFLAGS) geo_new.c - -geo_print.obj: geo_print.c - $(CC) -c $(CFLAGS) geo_print.c - -geo_set.obj: geo_set.c - $(CC) -c $(CFLAGS) geo_set.c - -geo_tiffp.obj: geo_tiffp.c - $(CC) -c $(CFLAGS) geo_tiffp.c - -geo_write.obj: geo_write.c - $(CC) -c $(CFLAGS) geo_write.c - -geo_trans.obj: geo_trans.c - $(CC) -c $(CFLAGS) geo_trans.c - -geo_extra.obj: geo_extra.c - $(CC) -c $(CFLAGS) geo_extra.c - -geo_normalize.obj: geo_normalize.c - $(CC) -c $(CFLAGS) geo_normalize.c - -geotiff_proj4.obj: geotiff_proj4.c - $(CC) -c $(CFLAGS) geotiff_proj4.c - -cpl_serv.obj: cpl_serv.c - $(CC) -c $(CFLAGS) cpl_serv.c - -clean: - -del *.obj - -del *.exe - -del *.lib - -del *.dll - -del *.manifest - -install: all - -mkdir $(PREFIX) - -mkdir $(BINDIR) - copy *.dll $(BINDIR) - copy *.exe $(BINDIR) - -devinstall: install - -mkdir $(INCDIR) - -mkdir $(LIBDIR) - copy *.lib $(LIBDIR) - copy *.h $(INCDIR) - copy libxtiff\*.h $(INCDIR) - copy *.inc $(INCDIR) - From 5f47db828c803c40e74e5ffaba50b31a808dbcef Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 21 May 2024 14:41:27 -0500 Subject: [PATCH 08/21] s/options/definitions --- libgeotiff/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgeotiff/CMakeLists.txt b/libgeotiff/CMakeLists.txt index 2d638ed..44c6b23 100644 --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt @@ -295,9 +295,9 @@ IF(WIN32) ENDIF() IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -Wall -Wno-long-long ) + target_compile_options(${GEOTIFF_LIBRARY_TARGET} PRIVATE -Wall -Wno-long-long ) IF(GEOTIFF_BUILD_PEDANTIC) - target_compile_definitions(${GEOTIFF_LIBRARY_TARGET} PRIVATE -pedantic) + target_compile_options(${GEOTIFF_LIBRARY_TARGET} PRIVATE -pedantic) ENDIF() ENDIF() From 35f2abcff6495b536a9e29b0589da416f060844f Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Wed, 22 May 2024 14:16:17 -0500 Subject: [PATCH 09/21] cpack config --- .github/workflows/test.yml | 11 +++++++ libgeotiff/bin/makefile.mpw | 58 --------------------------------- libgeotiff/cmake/CMakeLists.txt | 45 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 58 deletions(-) delete mode 100644 libgeotiff/bin/makefile.mpw diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30576c8..b581d41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,5 +68,16 @@ jobs: shell: bash -l {0} run: | ninja + cmake --build . --config Release --target package_source working-directory: ./libgeotiff/build + - uses: actions/upload-artifact@v4 + if: matrix.os == 'ubuntu-latest' && matrix.shared == 'ON' + name: Gather source distribution artifact + with: + name: source-package-${{matrix.os}} + if-no-files-found: error + path: | + ./build/libgeotiff-* + + diff --git a/libgeotiff/bin/makefile.mpw b/libgeotiff/bin/makefile.mpw deleted file mode 100644 index 19599f0..0000000 --- a/libgeotiff/bin/makefile.mpw +++ /dev/null @@ -1,58 +0,0 @@ -#*********************************************************************** -# -# MPW build file for example GeoTIFF utilities -# -# written by Niles D. Ritter. -# -CC = c -AR = lib -o -RM = delete -y -LN = duplicate -y - -#debug option -#DEBUG= -sym full -DEBUG= - -# data/code model options -#MODEL= -MODEL= -model far - -TIFFLIB = :::libtiff: -GEOTIFFLIB = :: -PORT = :::port: - -LINK.c = Link {LDFLAGS} -.o Ä .c - {CC} {DEBUG} {CFLAGS} {CPPFLAGS} {Default}.c -o {Default}.o -LDFLAGS = {DEBUG} {MODEL} -c 'MPS ' -t MPST -w -CFLAGS = {MODEL} -CPPFLAGS = -I {TIFFLIB} -I {GEOTIFFLIB} -OBJS = makegeo.o listgeo.o geotifcp.o -CLEANOBJS = makegeo.o -CLEANOTHER = newtif.tif -CLEANINC = -LIBS = {TIFFLIB}libtiff.o ¶ - {GEOTIFFLIB}libgeotiff.o ¶ - "{CLibraries}"StdClib.o ¶ - "{Libraries}"Stubs.o ¶ - "{Libraries}"Runtime.o ¶ - "{Libraries}"Interface.o - -ALL = makegeo listgeo geotifcp - -all Ä {ALL} - -compile Ä {OBJS} - -makegeo Ä makegeo.o {GEOTIFFLIB}libgeotiff.o - {LINK.c} -o makegeo makegeo.o {LIBS} - -listgeo Ä listgeo.o {GEOTIFFLIB}libgeotiff.o - {LINK.c} -o listgeo listgeo.o {LIBS} - -geotifcp Ä geotifcp.o {GEOTIFFLIB}libgeotiff.o {PORT}libport.o - {LINK.c} -o geotifcp geotifcp.o {LIBS} {PORT}libport.o - -clean Ä - {RM} {ALL} {CLEANOBJS} {CLEANOTHER} - diff --git a/libgeotiff/cmake/CMakeLists.txt b/libgeotiff/cmake/CMakeLists.txt index 47a2b00..b7668af 100644 --- a/libgeotiff/cmake/CMakeLists.txt +++ b/libgeotiff/cmake/CMakeLists.txt @@ -30,3 +30,48 @@ install (FILES install (EXPORT depends FILE ${PROJECT_NAME_LOWER}-depends.cmake DESTINATION "${INSTALL_CMAKE_DIR}") + + +# ------------------------------------------------------------------------------ + # CPACK controls + #------------------------------------------------------------------------------ + + + SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) + SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) + SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) + SET(CPACK_PACKAGE_NAME "GeoTIFF") + + SET(CPACK_SOURCE_GENERATOR "TBZ2;TGZ;ZIP") + SET(CPACK_PACKAGE_VENDOR "GeoTIFF Development Team") + SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") + + set(CPACK_SOURCE_PACKAGE_FILE_NAME + "lib${PROJECT_NAME_LOWER}-${GeoTIFF_VERSION}") + + set(CPACK_SOURCE_IGNORE_FILES + "/\\\\.gitattributes" + "/\\\\.DS_Store" + "/\\\\.git/" + "\\\\.swp$" + "~$" + "\\\\.\\\\#" + "/\\\\#" + "CMakeScripts/" + "COPYING-CMAKE-SCRIPTS" + "_CPack_Packages" + "cmake_install.cmake" + ".gitignore" + ".ninja" + ".deps" + "HOWTORELEASE.txt" + "README" + "build/" + "CMakeFiles" + "CTestTestfile.cmake" + ".gz" + ".bz2" + ) + + include(CPack) + add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) From 24e03b34c073be5cc27f88aa0943e64934063672 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Wed, 22 May 2024 14:18:08 -0500 Subject: [PATCH 10/21] path --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b581d41..e3afab5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,6 +78,6 @@ jobs: name: source-package-${{matrix.os}} if-no-files-found: error path: | - ./build/libgeotiff-* + ./libgeotiff/build/libgeotiff-* From 768dfb3f59bdfb3b67d25bc3d77bdc5299a18407 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 07:29:14 -0500 Subject: [PATCH 11/21] attestment and release-from-tag gathering --- .github/workflows/test.yml | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3afab5..df351b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,10 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] shared: [ON, OFF] - + permissions: + contents: write + attestations: write + id-token: write steps: - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 @@ -68,9 +71,18 @@ jobs: shell: bash -l {0} run: | ninja - cmake --build . --config Release --target package_source working-directory: ./libgeotiff/build + - name: Generate source distribution + shell: bash -l {0} + if: matrix.os == 'ubuntu-latest' + run: | + cmake --build . --config Release --target package_source + working-directory: ./libgeotiff/build + - name: Attest + uses: actions/attest-build-provenance@v1 + with: + subject-path: './libgeotiff/build/libgeotiff-*' - uses: actions/upload-artifact@v4 if: matrix.os == 'ubuntu-latest' && matrix.shared == 'ON' name: Gather source distribution artifact @@ -80,4 +92,31 @@ jobs: path: | ./libgeotiff/build/libgeotiff-* + release: + name: Gather and attach release + runs-on: ubuntu-latest + needs: build + permissions: + contents: write + attestations: write + id-token: write + steps: + - uses: actions/download-artifact@v4 + name: Download release artifact + with: + name: source-package-ubuntu-latest + path: release + + - uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + name: Publish release as draft + with: + make_latest: false + fail_on_unmatched_files: true + prerelease: true + generate_release_notes: true + draft: true + files: | + release/libgeotiff-* + From bb145b3cb5e0acb9afef219a1a73411e7309eae9 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 09:48:43 -0500 Subject: [PATCH 12/21] attest only when tagged --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df351b9..016fa3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,6 +81,8 @@ jobs: working-directory: ./libgeotiff/build - name: Attest uses: actions/attest-build-provenance@v1 + if: matrix.os == 'ubuntu-latest' && matrix.shared == 'ON' && startsWith(github.ref, 'refs/tags/') + #&& github.repository_owner == 'OSGeo' with: subject-path: './libgeotiff/build/libgeotiff-*' - uses: actions/upload-artifact@v4 @@ -98,8 +100,8 @@ jobs: needs: build permissions: contents: write - attestations: write id-token: write + attestations: write steps: - uses: actions/download-artifact@v4 name: Download release artifact From 424ea7d56bfe38996ae717370434a24fb607dcc7 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 10:35:49 -0500 Subject: [PATCH 13/21] only attest builds if the github.repository_owner is OSGeo --- .github/workflows/test.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 016fa3f..6886da6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,11 +78,21 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | cmake --build . --config Release --target package_source + extensions=".tar.gz .tar.bz2" + for ext in $extensions + do + for filename in $(ls *$ext) + do + + `md5sum $filename > $filename.md5` + `sha256sum $filename > $filename.sha256sum` + `sha512sum $filename > $filename.sha512sum` + done + done working-directory: ./libgeotiff/build - name: Attest uses: actions/attest-build-provenance@v1 - if: matrix.os == 'ubuntu-latest' && matrix.shared == 'ON' && startsWith(github.ref, 'refs/tags/') - #&& github.repository_owner == 'OSGeo' + if: matrix.os == 'ubuntu-latest' && matrix.shared == 'ON' && startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'OSGeo' with: subject-path: './libgeotiff/build/libgeotiff-*' - uses: actions/upload-artifact@v4 From bcb5bec9be9b175dea95940fae13dd073066e07c Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 11:46:36 -0500 Subject: [PATCH 14/21] remove vcpkg-based windows build. now using the conda-forge one --- .github/workflows/ci-windows.yml | 78 -------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 .github/workflows/ci-windows.yml diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml deleted file mode 100644 index 56cc6ea..0000000 --- a/.github/workflows/ci-windows.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Windows VCPKG - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - workflow_dispatch: - -jobs: - build: - runs-on: windows-2019 - env: - ARCH: x64 - - steps: - - uses: actions/checkout@v4 - - - name: Cache dependencies - uses: actions/cache@v4 - id: cache - with: - path: | - c:\vcpkg\installed - ${{ github.workspace }}\install-proj - key: ${{ runner.os }}-vcpkg-${{ hashFiles('.github/workflows/ci-windows.yml') }} - - - name: Install VCPKG dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: | - vcpkg install tiff:${{ env.ARCH }}-windows - vcpkg install sqlite3:${{ env.ARCH }}-windows - - - name: Install sqlite3.exe - run: | - Invoke-WebRequest -Uri https://sqlite.org/2018/sqlite-tools-win32-x86-3250100.zip -OutFile sqlite-tools-win32-x86-3250100.zip - 7z x sqlite-tools-win32-x86-3250100.zip - Copy-Item sqlite-tools-win32-x86-3250100/sqlite3.exe . - - - name: Build PROJ - if: steps.cache.outputs.cache-hit != 'true' - run: | - $buildRoot = "${{ github.workspace }}".Replace("\", "/") - $vcpkgPath = [System.IO.Path]::GetDirectoryName((Get-Command vcpkg).Source) - git clone --depth=1 -b 6.3 https://github.com/OSGeo/PROJ proj - New-Item -Type Directory proj\build -Force - Push-Location proj\build - Copy-Item ..\..\sqlite3.exe . - Copy-Item $vcpkgPath\installed\${{ env.ARCH }}-windows\bin\sqlite3.dll . - $env:PATH="$($pwd.Path);$($env:PATH)" - cmake -G "Visual Studio 16 2019" -A ${{ env.ARCH }} .. -DCMAKE_BUILD_TYPE=Release -DPROJ_TESTS=OFF -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_TOOLCHAIN_FILE="$vcpkgPath/scripts/buildsystems/vcpkg.cmake" -DCMAKE_INSTALL_PREFIX="$buildRoot/install-proj" - cmake --build . --config Release --target install - Pop-Location - - - name: Build - run: | - $buildRoot = "${{ github.workspace }}".Replace("\", "/") - $vcpkgPath = [System.IO.Path]::GetDirectoryName((Get-Command vcpkg).Source) - New-Item -Type Directory libgeotiff\build -Force - Set-Location libgeotiff\build - cmake -G "Visual Studio 16 2019" -A ${{ env.ARCH }} .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="/WX" -DCMAKE_CXX_FLAGS="/WX" -DCMAKE_INSTALL_PREFIX="$buildRoot/install" -DPROJ_INCLUDE_DIR="$buildRoot/install-proj/include" -DPROJ_LIBRARY="$buildRoot/install-proj/lib/proj.lib" -DCMAKE_TOOLCHAIN_FILE="$vcpkgPath/scripts/buildsystems/vcpkg.cmake" - cmake --build . --config Release --target install - - - name: Add runtime dependencies - run: | - $vcpkgPath = [System.IO.Path]::GetDirectoryName((Get-Command vcpkg).Source) - Copy-Item "${{ github.workspace }}\install-proj\bin\*.dll" "${{ github.workspace }}\install\bin\" - Copy-Item $vcpkgPath\installed\${{ env.ARCH }}-windows\bin\sqlite3.dll "${{ github.workspace }}\install\bin\" - Copy-Item $vcpkgPath\installed\${{ env.ARCH }}-windows\bin\tiff.dll "${{ github.workspace }}\install\bin\" - Copy-Item $vcpkgPath\installed\${{ env.ARCH }}-windows\bin\jpeg62.dll "${{ github.workspace }}\install\bin\" - Copy-Item $vcpkgPath\installed\${{ env.ARCH }}-windows\bin\zlib1.dll "${{ github.workspace }}\install\bin\" - Copy-Item $vcpkgPath\installed\${{ env.ARCH }}-windows\bin\liblzma.dll "${{ github.workspace }}\install\bin\" - - - name: Publish artifacts - uses: actions/upload-artifact@v2 - with: - name: libgeotiff-bin-${{ github.run_number }} - path: install/ From 00d36be0d3362d29c3ffe817fada2d1a51494eab Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 15:01:14 -0500 Subject: [PATCH 15/21] tweak name --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6886da6..b5272f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ -name: Test +name: Build on: [push, pull_request] concurrency: @@ -8,7 +8,7 @@ concurrency: jobs: build: - name: OS ${{ matrix.os }} with BUILD_SHARED_LIBS=${{matrix.shared}} + name: ${{ matrix.os }} with BUILD_SHARED_LIBS=${{matrix.shared}} runs-on: ${{ matrix.os }} strategy: matrix: From 7a264a97c4eec215ee17d5131bb8675535cb68ab Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 15:01:46 -0500 Subject: [PATCH 16/21] put back travis for now --- .travis.yml | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..62507bf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,72 @@ +matrix: + fast_finish: true + include: + + - os: linux + compiler: gcc + language: cpp + sudo: required + dist: jammy + env: + - BUILD_NAME=linux + + - os: osx + osx_image: xcode14.2 + compiler: clang + cache: + apt: true + directories: + - $HOME/.ccache + env: + - BUILD_NAME=osx + - CC=clang + - CXX=clang++ + addons: + homebrew: + packages: + - ccache + +cache: + directories: + - $HOME/.ccache + +before_install: + - if test "$TRAVIS_OS_NAME" = "linux"; then sudo apt install g++ libjpeg-dev libz-dev libtiff-dev libsqlite3-dev; fi + - if test "$TRAVIS_OS_NAME" = "osx"; then brew update; brew install ccache; fi + +install: + - git clone --depth=1 https://github.com/OSGeo/PROJ proj + - export CC="ccache $CC" + - export CXX="ccache $CXX" + - $CC --version + - (cd proj && cmake . -DBUILD_APPS=OFF -DPROJ_TESTS=OFF && make -j3 && sudo make install && (if test "$TRAVIS_OS_NAME" = "linux"; then sudo ldconfig; fi)) + - cd libgeotiff + - ./autogen.sh + - ./configure + - make dist + - mkdir libgeotiff + - cat libgeotiff*.tar.gz | tar xz -C libgeotiff --strip-components=1 + - cd libgeotiff + - mkdir build_autoconf + - cd build_autoconf + - CFLAGS="-Wall -Wextra -Werror" ../configure + - make -j3 + - make check + - cd .. + - mkdir build_cmake + - cd build_cmake + - cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_C_FLAGS="-Wall -Wextra -Werror" + - make -j3 + +script: + - echo "done" + +notifications: + #email: + # recipients: + # - gdal-commits@lists.osgeo.org + + irc: + channels: + - "irc.freenode.org#gdal" + use_notice: true From 5fbdc0f9a3a62ba5749c7a5f9c8f6bacc084e133 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 23 May 2024 15:38:42 -0500 Subject: [PATCH 17/21] no more makefile.vc --- libgeotiff/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/libgeotiff/Makefile.am b/libgeotiff/Makefile.am index 6563e5f..b29d48f 100644 --- a/libgeotiff/Makefile.am +++ b/libgeotiff/Makefile.am @@ -63,7 +63,6 @@ pkgconfig_DATA = libgeotiff.pc pkgconfigdir = $(libdir)/pkgconfig EXTRA_DIST = autogen.sh \ - makefile.vc \ geo_config.h.vc \ README \ README.WIN \ From 9bcdf0ed0e6ff4615b990d8a670d7fa8c10ac10a Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 28 May 2024 07:01:31 -0500 Subject: [PATCH 18/21] adapt non303's patches --- libgeotiff/CMakeLists.txt | 55 ++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/libgeotiff/CMakeLists.txt b/libgeotiff/CMakeLists.txt index 44c6b23..6ac8941 100644 --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt @@ -46,6 +46,8 @@ SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) # General build settings option(BUILD_SHARED_LIBS "Set ON to build shared library" ON) +option(BUILD_MAN "Set ON to build man pages" ON) +option(BUILD_DOC "Set ON to build doc files" ON) IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Debug CACHE STRING @@ -82,26 +84,33 @@ CHECK_INCLUDE_FILES(strings.h GEOTIFF_HAVE_STRINGS_H) ############################################################################### # User-defined build settings -SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if GeoTIFF utilities should be built") +option(WITH_UTILITIES "Choose if GeoTIFF utilities should be built" ON) + +if (MSVC) + SET(INTERFACE_LIB_PREFIX _i CACHE STRING "Windows interface library suffix") +endif (MSVC) ############################################################################### # Search for dependencies # TIFF support - required, default=ON -SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") +option(WITH_TIFF "Choose if TIFF support should be built" ON) -FIND_PACKAGE(PROJ NO_MODULE REQUIRED) +FIND_PACKAGE(PROJ NO_MODULE QUIET) +if (NOT PROJ_FOUND) + FIND_PACKAGE(PROJ REQUIRED) +endif () # Zlib support - optional, default=OFF -SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built") +option(WITH_ZLIB "Choose if zlib support should be built" OFF) # JPEG support - optional, default=OFF -SET(WITH_JPEG FALSE CACHE BOOL "Choose if JPEG support should be built") +option(WITH_JPEG "Choose if JPEG support should be built" OFF) # Turn off TOWGS84 support -SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support") +option(WITH_TOWGS84 "Build with TOWGS84 support" ON) IF (NOT WITH_TOWGS84) SET(GEO_NORMALIZE_DISABLE_TOWGS84 1) endif() @@ -154,13 +163,16 @@ SET(GEOTIFF_MAN_PAGES # ${PROJECT_BINARY_DIR}/geotiff_version.h # Install doc files -INSTALL(FILES +if(BUILD_DOC) + INSTALL(FILES AUTHORS ChangeLog COPYING LICENSE README README_BIN README.WIN DESTINATION ${CMAKE_INSTALL_DOCDIR}) +endif () # Install man pages -INSTALL(FILES ${GEOTIFF_MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) - +if(BUILD_MAN) + INSTALL(FILES ${GEOTIFF_MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +endif () # Install header files for development distribution INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -202,9 +214,9 @@ set_property(TARGET ${GEOTIFF_LIBRARY_TARGET} PROPERTY POSITION_INDEPENDENT_CODE set_property(TARGET ${GEOTIFF_LIBRARY_TARGET} PROPERTY OUTPUT_NAME ${GEOTIFF_LIB_NAME}) IF(WITH_JPEG) - FIND_PACKAGE(JPEG NO_MODULE QUIET CONFIG) + FIND_PACKAGE(JPEG NO_MODULE QUIET) if (NOT JPEG_FOUND) - FIND_PACKAGE(JPEG CONFIG) + FIND_PACKAGE(JPEG) endif () IF(JPEG_FOUND) @@ -257,7 +269,7 @@ TARGET_INCLUDE_DIRECTORIES(${GEOTIFF_LIBRARY_TARGET} PUBLIC $ $) IF(WIN32 AND MSVC) - SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES IMPORT_SUFFIX "_i.lib") + SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES IMPORT_SUFFIX "${INTERFACE_LIB_PREFIX}.lib") ENDIF(WIN32 AND MSVC) # Unix, linux: @@ -332,11 +344,15 @@ target_include_directories( ${GEOTIFF_LIBRARY_TARGET} PUBLIC INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET} EXPORT depends - RUNTIME DESTINATION ${CMAKE_INSTALLL_BINDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) +IF (MSVC) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) +ENDIF (MSVC) + # Install libgeotiff.pc set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\${prefix}") @@ -371,3 +387,16 @@ IF(WITH_UTILITIES) ENDIF() ADD_SUBDIRECTORY(cmake) + +message(STATUS " +################################ +Summary of build options: + Build shared library: ${BUILD_SHARED_LIBS} + Build man pages: ${BUILD_MAN} + Build doc files: ${BUILD_DOC} + Build GeoTIFF utilities: ${WITH_UTILITIES} + Build TIFF support: ${WITH_TIFF} + Build zlib support: ${WITH_ZLIB} + Build JPEG support: ${WITH_JPEG} + Build TOWGS84 support: ${WITH_TOWGS84} +################################") From bfe63b315de30bbd87af91d8295d877afb1f1dad Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 28 May 2024 07:20:16 -0500 Subject: [PATCH 19/21] condition PDB install with BUILD_SHARED_LIBS --- libgeotiff/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgeotiff/CMakeLists.txt b/libgeotiff/CMakeLists.txt index 6ac8941..afdc252 100644 --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt @@ -349,7 +349,7 @@ INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -IF (MSVC) +IF (MSVC and BUILD_SHARED_LIBS) INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) ENDIF (MSVC) From b906481e06ffb84d3c73f36e050fb7312f79e193 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 28 May 2024 07:26:41 -0500 Subject: [PATCH 20/21] syntax --- libgeotiff/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libgeotiff/CMakeLists.txt b/libgeotiff/CMakeLists.txt index afdc252..ea49a44 100644 --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt @@ -349,8 +349,10 @@ INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -IF (MSVC and BUILD_SHARED_LIBS) +IF (MSVC) +IF (BUILD_SHARED_LIBS) INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) +ENDIF (BUILD_SHARED_LIBS) ENDIF (MSVC) # Install libgeotiff.pc From edae2b9c2df7d300b06cb64dace3bb78decf5bb5 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 28 May 2024 07:35:40 -0500 Subject: [PATCH 21/21] remove FindGeoTIFF, which is no longer relevant --- libgeotiff/cmake/FindGeoTIFF.cmake | 104 ----------------------------- 1 file changed, 104 deletions(-) delete mode 100644 libgeotiff/cmake/FindGeoTIFF.cmake diff --git a/libgeotiff/cmake/FindGeoTIFF.cmake b/libgeotiff/cmake/FindGeoTIFF.cmake deleted file mode 100644 index 63b384a..0000000 --- a/libgeotiff/cmake/FindGeoTIFF.cmake +++ /dev/null @@ -1,104 +0,0 @@ -############################################################################### -# -# CMake module to search for GeoTIFF library -# -# On success, the macro sets the following variables: -# GEOTIFF_FOUND = if the library found -# GEOTIFF_LIBRARIES = full path to the library -# GEOTIFF_INCLUDE_DIR = where to find the library headers -# also defined, but not for general use are -# GEOTIFF_LIBRARY -# -# Copyright (c) 2009 Mateusz Loskot -# Copyright (c) 2016 NextGIS -# Copyright (C) 2017,2018 Hiroshi Miura -# -# Origin from -# https://svn.osgeo.org/metacrs/geotiff/trunk/libgeotiff/cmake/FindGeoTIFF.cmake -# Module source: http://github.com/mloskot/workshop/tree/master/cmake/ -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# -############################################################################### - -find_path(GEOTIFF_INCLUDE_DIR geotiff.h PATH_SUFFIXES geotiff libgeotiff) - -set(GEOTIFF_NAMES ${GEOTIFF_NAMES} geotiff geotiff_i) -set(GEOTIFF_NAMES_DEBUG ${GEOTIFF_NAMES_DEBUG} geotiffd geotiff_d geotiff_d_i) - -if(NOT GEOTIFF_LIBRARY) - find_library(GEOTIFF_LIBRARY_RELEASE NAMES ${GEOTIFF_NAMES}) - find_library(GEOTIFF_LIBRARY_DEBUG NAMES ${GEOTIFF_NAMES_DEBUG}) - include(SelectLibraryConfigurations) - select_library_configurations(GEOTIFF) - mark_as_advanced(GEOTIFF_LIBRARY_RELEASE GEOTIFF_LIBRARY_DEBUG) -endif() - -unset(GEOTIFF_NAMES) -unset(GEOTIFF_NAMES_DEBUG) - - -if(GEOTIFF_INCLUDE_DIR) - set(GEOTIFF_MAJOR_VERSION 0) - set(GEOTIFF_MINOR_VERSION 0) - set(GEOTIFF_PATCH_VERSION 0) - set(GEOTIFF_REVISION_VERSION 0) - - if(EXISTS "${GEOTIFF_INCLUDE_DIR}/geotiff.h") - file(READ "${GEOTIFF_INCLUDE_DIR}/geotiff.h" GEOTIFF_H_CONTENTS) - string(REGEX MATCH "LIBGEOTIFF_VERSION[ \t]+([0-9]+)" - LIBGEOTIFF_VERSION ${GEOTIFF_H_CONTENTS}) - string (REGEX MATCH "([0-9]+)" - LIBGEOTIFF_VERSION ${LIBGEOTIFF_VERSION}) - - string(SUBSTRING ${LIBGEOTIFF_VERSION} 0 1 GEOTIFF_MAJOR_VERSION) - string(SUBSTRING ${LIBGEOTIFF_VERSION} 1 1 GEOTIFF_MINOR_VERSION) - string(SUBSTRING ${LIBGEOTIFF_VERSION} 2 1 GEOTIFF_PATCH_VERSION) - string(SUBSTRING ${LIBGEOTIFF_VERSION} 3 1 GEOTIFF_REVISION_VERSION) - - unset(GEOTIFF_H_CONTENTS) - endif() - - set(GEOTIFF_VERSION_STRING "${GEOTIFF_MAJOR_VERSION}.${GEOTIFF_MINOR_VERSION}.${GEOTIFF_PATCH_VERSION}.${GEOTIFF_REVISION_VERSION}") - -endif() -mark_as_advanced(GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GeoTIFF - FOUND_VAR GEOTIFF_FOUND - REQUIRED_VARS GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR - VERSION_VAR GEOTIFF_VERSION_STRING) - -if(GEOTIFF_FOUND) - set(GEOTIFF_LIBRARIES "${GEOTIFF_LIBRARY}") - set(GEOTIFF_INCLUDE_DIRS "${GEOTIFF_INCLUDE_DIR}") - set(GeoTIFF_TARGET GEOTIFF::GEOTIFF) - if(NOT TARGET ${GeoTIFF_TARGET}) - add_library(${GeoTIFF_TARGET} UNKNOWN IMPORTED) - set_target_properties(${GeoTIFF_TARGET} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${GEOTIFF_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES C) - if(EXISTS "${GEOTIFF_LIBRARY}") - set_target_properties(${GeoTIFF_TARGET} PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${GEOTIFF_LIBRARY}") - endif() - if(EXISTS "${GEOTIFF_LIBRARY_RELEASE}") - set_property(TARGET ${GeoTIFF_TARGET} APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(${GeoTIFF_TARGET} PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" - IMPORTED_LOCATION_RELEASE "${GEOTIFF_LIBRARY_RELEASE}") - endif() - if(EXISTS "${GEOTIFF_LIBRARY_DEBUG}") - set_property(TARGET ${GeoTIFF_TARGET} APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(${GeoTIFF_TARGET} PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" - IMPORTED_LOCATION_DEBUG "${GEOTIFF_LIBRARY_DEBUG}") - endif() - endif() -endif() -