Skip to content

Commit

Permalink
Increase CMake minimum version from 3.9 to 3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed Jan 10, 2024
1 parent 5587e57 commit 56acc4f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 194 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/linux_gcc_5_4.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/linux_gcc_5_4/start.sh

This file was deleted.

12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions cmake/Ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions cmake/ProjUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 18 additions & 29 deletions src/lib_proj.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
$<$<CXX_COMPILER_ID:MSVC>:ws2_32>
Expand Down
18 changes: 0 additions & 18 deletions test/googletest/CMakeLists.txt.in

This file was deleted.

63 changes: 13 additions & 50 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56acc4f

Please sign in to comment.