Skip to content

Commit 7ebb52a

Browse files
committed
Modernize CMake config
1 parent dc23596 commit 7ebb52a

2 files changed

Lines changed: 23 additions & 25 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,35 @@ jobs:
2222
- "fedora:43"
2323
build_type: [Dev]
2424
cpp_compiler: [g++]
25-
cpp_version: [c++14]
25+
cpp_version: [14]
2626
include:
2727
- image: "ubuntu:22.04"
2828
CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
2929
- image: "ubuntu:24.04"
3030
CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
3131
- image: "debian:bookworm"
32-
cpp_version: c++20
32+
cpp_version: 20
3333
- image: "debian:bookworm"
3434
c_compiler: clang
3535
cpp_compiler: clang++
3636
- image: "debian:bookworm"
3737
c_compiler: clang
3838
cpp_compiler: clang++
39-
cpp_version: c++20
39+
cpp_version: 20
4040
- image: "debian:bookworm"
4141
build_type: RelWithDebInfo
4242
- image: "debian:trixie"
4343
CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
4444
- image: "debian:trixie"
45-
cpp_version: c++20
45+
cpp_version: 20
4646
CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
4747
- image: "debian:trixie"
4848
c_compiler: clang
4949
cpp_compiler: clang++
5050
- image: "debian:trixie"
5151
c_compiler: clang
5252
cpp_compiler: clang++
53-
cpp_version: c++20
53+
cpp_version: 20
5454
- image: "debian:trixie"
5555
build_type: RelWithDebInfo
5656
CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds

CMakeLists.txt

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
#-----------------------------------------------------------------------------
88

9-
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
9+
cmake_minimum_required(VERSION 3.10)
1010

1111
project(osmcoastline VERSION 2.4.1 LANGUAGES CXX C)
1212

@@ -16,9 +16,22 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
1616

1717
set(AUTHOR "Jochen Topf <jochen@topf.org>")
1818

19-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
19+
#-----------------------------------------------------------------------------
20+
#
21+
# Decide which C++ version to use (Minimum/default: C++14)
22+
#
23+
#-----------------------------------------------------------------------------
2024

21-
option(WITH_LZ4 "Build with lz4 support for PBF files" ON)
25+
if(NOT USE_CPP_VERSION)
26+
set(USE_CPP_VERSION 14)
27+
endif()
28+
message(STATUS "Use C++ version: ${USE_CPP_VERSION}")
29+
30+
set(CMAKE_CXX_STANDARD ${USE_CPP_VERSION})
31+
set(CMAKE_CXX_EXTENSIONS OFF)
32+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33+
34+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2235

2336

2437
#-----------------------------------------------------------------------------
@@ -27,6 +40,8 @@ option(WITH_LZ4 "Build with lz4 support for PBF files" ON)
2740
#
2841
#-----------------------------------------------------------------------------
2942

43+
option(WITH_LZ4 "Build with lz4 support for PBF files" ON)
44+
3045
include_directories(include)
3146

3247
find_package(Osmium 2.16.0 COMPONENTS io gdal)
@@ -58,23 +73,6 @@ if(MSVC)
5873
endif()
5974

6075

61-
#-----------------------------------------------------------------------------
62-
#
63-
# Decide which C++ version to use (Minimum/default: C++14).
64-
#
65-
#-----------------------------------------------------------------------------
66-
if(NOT MSVC)
67-
if(NOT USE_CPP_VERSION)
68-
set(USE_CPP_VERSION c++14)
69-
endif()
70-
message(STATUS "Use C++ version: ${USE_CPP_VERSION}")
71-
# following only available from cmake 2.8.12:
72-
# add_compile_options(-std=${USE_CPP_VERSION})
73-
# so using this instead:
74-
add_definitions(-std=${USE_CPP_VERSION})
75-
endif()
76-
77-
7876
#-----------------------------------------------------------------------------
7977
#
8078
# Compiler and Linker flags

0 commit comments

Comments
 (0)