Skip to content

Commit 72d54b3

Browse files
committed
Carefully modernize CMake config
* Version 3.5.0 is now required, this is available even in the rather old Ubuntu 16.04 distribution, so this isn't a real restriction. * Also sets the oldest supported PostgreSQL version to 9.5 (which is in Ubuntu 16.04). * Sets minimum libosmium version to 2.17.2 which is included anyway. * Update list of clang-tidy versions we are looking for.
1 parent 7865cd7 commit 72d54b3

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

CMakeLists.txt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
set(PACKAGE osm2pgsql)
2-
set(PACKAGE_NAME osm2pgsql)
3-
set(PACKAGE_VERSION 1.5.1)
41

5-
cmake_minimum_required(VERSION 2.8.12)
2+
cmake_minimum_required(VERSION 3.5.0)
63

7-
project(osm2pgsql)
4+
project(osm2pgsql VERSION 1.5.1 LANGUAGES CXX)
85

96
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
107

@@ -34,7 +31,7 @@ if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
3431
message(FATAL_ERROR "In-source builds are not allowed, please use a separate build directory like `mkdir build && cd build && cmake ..`")
3532
endif()
3633

37-
message(STATUS "Building osm2pgsql ${PACKAGE_VERSION}")
34+
message(STATUS "Building osm2pgsql ${PROJECT_VERSION}")
3835

3936
if (NOT CMAKE_BUILD_TYPE)
4037
set(CMAKE_BUILD_TYPE RelWithDebInfo)
@@ -48,13 +45,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)
4845
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4946

5047
if (MSVC)
51-
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -wd4996)
48+
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX)
49+
add_compile_options(-wd4996)
5250
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099 /STACK:30000000")
5351
else()
54-
add_definitions(-Wall)
55-
if (CMAKE_VERSION VERSION_LESS 3.1)
56-
add_definitions(-std=c++14)
57-
endif()
52+
add_compile_options(-Wall)
5853
endif()
5954

6055
option(EXTERNAL_LIBOSMIUM "Do not use the bundled libosmium" OFF)
@@ -71,10 +66,10 @@ if (NOT WIN32 AND NOT APPLE)
7166
set(PostgreSQL_TYPE_INCLUDE_DIR /usr/include)
7267
endif()
7368

74-
set(MINIMUM_POSTGRESQL_SERVER_VERSION "9.3")
75-
set(MINIMUM_POSTGRESQL_SERVER_VERSION_NUM "90300")
69+
set(MINIMUM_POSTGRESQL_SERVER_VERSION "9.5")
70+
set(MINIMUM_POSTGRESQL_SERVER_VERSION_NUM "90500")
7671

77-
set(PostgreSQL_ADDITIONAL_VERSIONS "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3")
72+
set(PostgreSQL_ADDITIONAL_VERSIONS "14" "13" "12" "11" "10" "9.6" "9.5")
7873

7974
#############################################################
8075
# Version
@@ -132,7 +127,7 @@ if (BUILD_COVERAGE)
132127
message(STATUS " found")
133128
endif()
134129

135-
add_definitions(-g -O0 -fno-inline-functions -fno-inline --coverage)
130+
add_compile_options(-g -O0 -fno-inline-functions -fno-inline --coverage)
136131

137132
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage"
138133
CACHE
@@ -190,7 +185,7 @@ endif()
190185

191186
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR})
192187

193-
find_package(Osmium 2.17.0 REQUIRED COMPONENTS io)
188+
find_package(Osmium 2.17.2 REQUIRED COMPONENTS io)
194189
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS} ${PROTOZERO_INCLUDE_DIR} ${FMT_INCLUDE_DIR} ${RAPIDJSON_INCLUDE_DIR})
195190

196191
if (WITH_LUA)
@@ -297,7 +292,7 @@ target_link_libraries(osm2pgsql osm2pgsql_lib ${LIBS})
297292

298293
message(STATUS "Looking for clang-tidy")
299294
find_program(CLANG_TIDY
300-
NAMES clang-tidy clang-tidy-12 clang-tidy-11 clang-tidy-10 clang-tidy-9 clang-tidy-8 clang-tidy-7)
295+
NAMES clang-tidy clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11)
301296

302297
if (CLANG_TIDY)
303298
message(STATUS "Looking for clang-tidy - found ${CLANG_TIDY}")

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ the report.
148148
## Releasing a new version
149149

150150
* Decide on a new version. (See [semantic versioning](https://semver.org/).)
151-
* Update version in [CMakeLists.txt](CMakeLists.txt), look for `PACKAGE_VERSION`.
151+
* Update version in [CMakeLists.txt](CMakeLists.txt), look for `project` function.
152152
* Build man page (`make man`) and copy it to `docs/osm2pgsql.1`.
153153
* Tag release with release notes in commit message and upload the tag to Github.
154154
* Fill out release notes on Github.

docs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if(PANDOC)
99
-s
1010
-t man
1111
--template ${CMAKE_CURRENT_SOURCE_DIR}/manpage.template
12-
--variable "version=${PACKAGE_VERSION}"
12+
--variable "version=${PROJECT_VERSION}"
1313
--variable "title=OSM2PGSQL"
1414
--variable "section=1"
1515
)

src/CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
set(osm2pgsql_lib_SOURCES
2+
add_library(osm2pgsql_lib STATIC)
3+
4+
target_sources(osm2pgsql_lib PRIVATE
35
db-check.cpp
46
db-copy.cpp
57
dependency-manager.cpp
@@ -39,7 +41,7 @@ if (LUA_FOUND OR LUAJIT_FOUND)
3941
"${CMAKE_CURRENT_SOURCE_DIR}/init.lua")
4042
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/init.lua" LUA_INIT_CODE)
4143
configure_file(lua-init.cpp.in lua-init.cpp @ONLY)
42-
list(APPEND osm2pgsql_lib_SOURCES
44+
target_sources(osm2pgsql_lib PRIVATE
4345
flex-table.cpp
4446
flex-table-column.cpp
4547
geom-transform.cpp
@@ -49,21 +51,20 @@ if (LUA_FOUND OR LUAJIT_FOUND)
4951
${CMAKE_CURRENT_BINARY_DIR}/lua-init.cpp)
5052
endif()
5153

52-
list(APPEND osm2pgsql_lib_SOURCES ${PROJECT_BINARY_DIR}/src/version.cpp)
54+
target_sources(osm2pgsql_lib PRIVATE ${PROJECT_BINARY_DIR}/src/version.cpp)
5355

5456
if (HAVE_PROJ4)
55-
list(APPEND osm2pgsql_lib_SOURCES reprojection-generic-proj4.cpp)
57+
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj4.cpp)
5658
if (NOT MSVC)
5759
set_source_files_properties(reprojection-generic-proj4.cpp
5860
PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
5961
endif()
6062
elseif(HAVE_PROJ6)
61-
list(APPEND osm2pgsql_lib_SOURCES reprojection-generic-proj6.cpp)
63+
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj6.cpp)
6264
else()
63-
list(APPEND osm2pgsql_lib_SOURCES reprojection-generic-none.cpp)
65+
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-none.cpp)
6466
endif()
6567

66-
add_library(osm2pgsql_lib STATIC ${osm2pgsql_lib_SOURCES})
6768
set_target_properties(osm2pgsql_lib PROPERTIES OUTPUT_NAME osm2pgsql)
6869
target_link_libraries(osm2pgsql_lib ${LIBS})
6970

src/version.cpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ char const *get_build_type() noexcept
1414

1515
char const *get_osm2pgsql_version() noexcept
1616
{
17-
return "@PACKAGE_VERSION@@VERSION_FROM_GIT@";
17+
return "@PROJECT_VERSION@@VERSION_FROM_GIT@";
1818
}
1919

2020
char const *get_osm2pgsql_short_version() noexcept
2121
{
22-
return "@PACKAGE_VERSION@";
22+
return "@PROJECT_VERSION@";
2323
}
2424

2525
char const *get_minimum_postgresql_server_version() noexcept

0 commit comments

Comments
 (0)