From 56acc4f2b369c136805dd01f514b8d24056912ae Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Wed, 10 Jan 2024 22:15:34 +1300 Subject: [PATCH] Increase CMake minimum version from 3.9 to 3.16 --- .github/workflows/linux_gcc_5_4.yml | 39 --------------- .github/workflows/linux_gcc_5_4/start.sh | 42 ---------------- CMakeLists.txt | 12 +---- cmake/Ccache.cmake | 2 - cmake/ProjUtilities.cmake | 7 +-- src/lib_proj.cmake | 47 +++++++----------- test/googletest/CMakeLists.txt.in | 18 ------- test/unit/CMakeLists.txt | 63 +++++------------------- 8 files changed, 36 insertions(+), 194 deletions(-) delete mode 100644 .github/workflows/linux_gcc_5_4.yml delete mode 100755 .github/workflows/linux_gcc_5_4/start.sh delete mode 100644 test/googletest/CMakeLists.txt.in diff --git a/.github/workflows/linux_gcc_5_4.yml b/.github/workflows/linux_gcc_5_4.yml deleted file mode 100644 index 3d49794bc5..0000000000 --- a/.github/workflows/linux_gcc_5_4.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Linux GCC 5.4 - -on: - push: - paths-ignore: - - 'docs/**' - pull_request: - paths-ignore: - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: true - -jobs: - - linux_gcc_5_4: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache - uses: actions/cache@v3 - id: cache - with: - path: | - ${{ github.workspace }}/ccache.tar.gz - key: ${{ runner.os }}-cache-gcc-5-4-${{ github.run_id }} - restore-keys: ${{ runner.os }}-cache-gcc-5-4- - - - name: Run - run: docker run -e CI -e WORK_DIR="$PWD" -v $PWD:$PWD ubuntu:16.04 $PWD/.github/workflows/linux_gcc_5_4/start.sh - - - name: Coveralls - uses: coverallsapp/github-action@v1.1.2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/linux_gcc_5_4/start.sh b/.github/workflows/linux_gcc_5_4/start.sh deleted file mode 100755 index 98a3c31839..0000000000 --- a/.github/workflows/linux_gcc_5_4/start.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -e - -export TRAVIS_OS_NAME=linux -export BUILD_NAME=linux_gcc -export TRAVIS_BUILD_DIR="$WORK_DIR" - -apt-get update -y - -DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - autoconf automake libtool make cmake ccache pkg-config python3-pip sqlite3 tar zip \ - g++ jq lcov python3-setuptools \ - libsqlite3-dev \ - libtiff-dev \ - libcurl4-openssl-dev libidn11-dev librtmp-dev libssl-dev libkrb5-dev comerr-dev libldap2-dev - -python3 -m pip install --user --upgrade "pip < 21.0" -echo `python3 -m pip --version` -python3 -m pip config --user set global.progress_bar off -python3 -m pip install --user jsonschema -python3 -m pip install --user cmake==3.9.6 - -export PATH=$HOME/.local/bin:$PATH - -cd "$WORK_DIR" - -if test -f "$WORK_DIR/ccache.tar.gz"; then - echo "Restoring ccache..." - (cd $HOME && tar xzf "$WORK_DIR/ccache.tar.gz") -fi - -ccache -M 500M - -CFLAGS="-Werror $CFLAGS" CXXFLAGS="-Werror $CXXFLAGS" ./travis/install.sh - -echo "Saving ccache..." -rm -f "$WORK_DIR/ccache.tar.gz" -(cd $HOME && tar czf "$WORK_DIR/ccache.tar.gz" .ccache) - -mkdir -p coverage -lcov --no-external --capture --directory src --output-file coverage/lcov.info diff --git a/CMakeLists.txt b/CMakeLists.txt index 862570c12e..45bd855bd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ ################################################################################ # General settings ################################################################################ -cmake_minimum_required(VERSION 3.9 FATAL_ERROR) +cmake_minimum_required(VERSION 3.16) project(PROJ DESCRIPTION "PROJ coordinate transformation software library" @@ -219,16 +219,6 @@ if(ENABLE_CURL) if(CURL_FOUND) set(CURL_ENABLED TRUE) - # Target CURL::libcurl only defined since CMake 3.12 - # TODO: remove this when CMake >= 3.12 required - if(NOT TARGET CURL::libcurl) - add_library(CURL::libcurl INTERFACE IMPORTED) - set_target_properties(CURL::libcurl PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}" - ) - endif() - # Curl SSL options are described in # https://curl.se/libcurl/c/CURLOPT_SSL_OPTIONS.html #set(CURLSSLOPT_NO_REVOKE 2) diff --git a/cmake/Ccache.cmake b/cmake/Ccache.cmake index 380513394e..9f56a9ca9c 100644 --- a/cmake/Ccache.cmake +++ b/cmake/Ccache.cmake @@ -7,8 +7,6 @@ # Add "include(Ccache)" to CMakeLists.txt and enable # using the option -D USE_CCACHE=ON -cmake_minimum_required(VERSION 3.9) - option(USE_CCACHE "Use ccache (or clcache for MSVC) to compile C/C++ objects" OFF) diff --git a/cmake/ProjUtilities.cmake b/cmake/ProjUtilities.cmake index 2103d3d3d5..295e3c64e5 100644 --- a/cmake/ProjUtilities.cmake +++ b/cmake/ProjUtilities.cmake @@ -116,9 +116,10 @@ function(configure_proj_pc) if(HAVE_LIBDL) list(APPEND EXTRA_LIBS -ldl) endif() - # Join list with a space; list(JOIN) added CMake 3.12 - string(REPLACE ";" " " EXTRA_LIBS "${EXTRA_LIBS}") - string(REPLACE ";" " " EXTRA_REQUIRES "${EXTRA_REQUIRES}") + + # Join lists with a space + list(JOIN EXTRA_LIBS " " EXTRA_LIBS) + list(JOIN EXTRA_REQUIRES " " EXTRA_REQUIRES) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/proj.pc.in diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake index 79fb73f7d6..e9280ecae3 100644 --- a/src/lib_proj.cmake +++ b/src/lib_proj.cmake @@ -258,19 +258,22 @@ set(SRC_LIBPROJ_CORE ${CMAKE_CURRENT_BINARY_DIR}/proj_config.h ) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) - set_property(SOURCE list.cpp # because if sets DO_NOT_DEFINE_PROJ_HEAD - transformations/defmodel.cpp # Evaluator class conflict - transformations/tinshift.cpp # Evaluator class conflict - wkt1_parser.cpp - wkt2_parser.cpp - wkt1_generated_parser.c - wkt2_generated_parser.c - PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) - if(WIN32) - set_property(SOURCE networkfilemanager.cpp PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) - endif() -endif () +# Skip Unity build for specific files +set(SKIP_UNITY_BUILD_FILES + list.cpp # because if sets DO_NOT_DEFINE_PROJ_HEAD + transformations/defmodel.cpp # Evaluator class conflict + transformations/tinshift.cpp # Evaluator class conflict + wkt1_parser.cpp + wkt2_parser.cpp + wkt1_generated_parser.c + wkt2_generated_parser.c +) +if(WIN32) + list(APPEND SKIP_UNITY_BUILD_FILES + networkfilemanager.cpp + ) +endif() +set_property(SOURCE ${SKIP_UNITY_BUILD_FILES} PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) set(HEADERS_LIBPROJ proj.h @@ -470,26 +473,12 @@ endif() if(TIFF_ENABLED) target_compile_definitions(proj PRIVATE -DTIFF_ENABLED) - if( CMAKE_VERSION VERSION_LESS 3.11 AND CMAKE_CROSSCOMPILING ) - # Hack needed for ubuntu:18.04 mingw64 cross compiling to avoid - # -isystem to be emitted (similar to https://discourse.cmake.org/t/use-of-isystem/1574) - target_include_directories(proj PRIVATE ${TIFF_INCLUDE_DIRS}) - target_link_libraries(proj PRIVATE ${TIFF_LIBRARIES}) - else() - target_link_libraries(proj PRIVATE TIFF::TIFF) - endif() + target_link_libraries(proj PRIVATE TIFF::TIFF) endif() if(CURL_ENABLED) target_compile_definitions(proj PRIVATE -DCURL_ENABLED) - if( CMAKE_VERSION VERSION_LESS 3.11 AND CMAKE_CROSSCOMPILING ) - # Hack needed for ubuntu:18.04 mingw64 cross compiling to avoid - # -isystem to be emitted (similar to https://discourse.cmake.org/t/use-of-isystem/1574) - target_include_directories(proj PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(proj PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(proj PRIVATE CURL::libcurl) - endif() + target_link_libraries(proj PRIVATE CURL::libcurl) target_link_libraries(proj PRIVATE $<$:ws2_32> diff --git a/test/googletest/CMakeLists.txt.in b/test/googletest/CMakeLists.txt.in deleted file mode 100644 index 63413c0aea..0000000000 --- a/test/googletest/CMakeLists.txt.in +++ /dev/null @@ -1,18 +0,0 @@ -# Source /~https://github.com/google/googletest/blob/master/googletest/README.md -cmake_minimum_required(VERSION 2.8.12) - -project(googletest-download NONE) - -include(ExternalProject) -ExternalProject_Add(googletest - URL /~https://github.com/google/googletest/archive/release-1.11.0.zip - URL_HASH SHA1=9ffb7b5923f4a8fcdabf2f42c6540cce299f44c0 - DOWNLOAD_NO_PROGRESS ON - SOURCE_DIR "${PROJ_BINARY_DIR}/googletest-src" - BINARY_DIR "${PROJ_BINARY_DIR}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - TEST_COMMAND "" - # Disable install step - INSTALL_COMMAND "" -) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 1d2b197704..34ea90ea05 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -25,49 +25,21 @@ endif() else() -message(STATUS "Using internal GTest") +message(STATUS "Fetching GTest") +# Add Google Test # -# Build Google Test -# -# Source /~https://github.com/google/googletest/blob/master/googletest/README.md -# Download and unpack googletest at configure time -configure_file( - ${PROJ_SOURCE_DIR}/test/googletest/CMakeLists.txt.in - ${PROJ_BINARY_DIR}/googletest-download/CMakeLists.txt) - -if(CYGWIN) -# needed at least with gcc 11.3.0 Cygwin, otherwise build errors in -# in googletest-src/googletest/include/gtest/internal/gtest-port.h related to -# fileno() and other functions, when building gtest or including it -add_definitions(-D_GNU_SOURCE) -endif() +# Source /~https://github.com/google/googletest/blob/main/googletest/README.md -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${PROJ_BINARY_DIR}/googletest-download) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${PROJ_BINARY_DIR}/googletest-download) -if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") -endif() -# Prevent overriding the parent project's compiler/linker -# settings on Windows +include(FetchContent) +FetchContent_Declare( + googletest + # Specify the commit you depend on and update it regularly. + URL /~https://github.com/google/googletest/archive/5376968f6948923e2411081fd9372e71a59d8e77.zip +) +# For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -# Add googletest directly to our build. This defines -# the gtest and gtest_main targets. -option(INSTALL_GTEST "Enable installation of googletest" OFF) -add_subdirectory( - ${PROJ_BINARY_DIR}/googletest-src - ${PROJ_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL) - -# Provide the same target name as find_package(GTest) -add_library(GTest::gtest ALIAS gtest) +FetchContent_MakeAvailable(googletest) endif() # USE_EXTERNAL_GTEST @@ -148,9 +120,7 @@ set(PROJ_TEST_CPP_API_SOURCES test_c_api.cpp test_grids.cpp) add_executable(proj_test_cpp_api ${PROJ_TEST_CPP_API_SOURCES}) -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) - set_property(SOURCE ${PROJ_TEST_CPP_API_SOURCES} PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) -endif () +set_property(SOURCE ${PROJ_TEST_CPP_API_SOURCES} PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) target_link_libraries(proj_test_cpp_api PRIVATE GTest::gtest @@ -182,14 +152,7 @@ add_executable(test_network test_network.cpp) if(CURL_ENABLED) target_compile_definitions(test_network PRIVATE -DCURL_ENABLED) - if( CMAKE_VERSION VERSION_LESS 3.11 AND CMAKE_CROSSCOMPILING ) - # Hack needed for ubuntu:18.04 mingw64 cross compiling to avoid - # -isystem to be emitted (similar to https://discourse.cmake.org/t/use-of-isystem/1574) - target_include_directories(test_network PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(test_network PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(test_network PRIVATE CURL::libcurl) - endif() + target_link_libraries(test_network PRIVATE CURL::libcurl) endif() target_link_libraries(test_network PRIVATE GTest::gtest