-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
179 lines (135 loc) · 5.02 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#-----------------------------------------------------------------------------
#
# CMake Config
#
# osmdbt
#
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#-----------------------------------------------------------------------------
#
# Project version
#
#-----------------------------------------------------------------------------
project(osmdbt VERSION 0.6)
set(AUTHOR "Jochen Topf <[email protected]>")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_PLUGIN "Build PostgreSQL plugin" ON)
#-----------------------------------------------------------------------------
#
# Find external dependencies
#
#-----------------------------------------------------------------------------
find_package(Boost 1.55.0 REQUIRED COMPONENTS filesystem program_options)
find_package(Osmium 2.15.0 REQUIRED COMPONENTS io)
find_package(ZLIB)
find_package(Threads)
find_library(PQXX_LIB pqxx)
if(PQXX_LIB STREQUAL "PQXX_LIB-NOTFOUND")
message(FATAL_ERROR "Missing libpqxx")
endif()
# workaround as per https://github.com/jtv/libpqxx/issues/93
add_definitions(-DPQXX_HIDE_EXP_OPTIONAL)
find_library(YAML_LIB yaml-cpp)
if(YAML_LIB STREQUAL "YAML-NOTFOUND")
message(FATAL_ERROR "Missing yaml-cpp")
endif()
# This can be set to something like "-v11" to force testing with a specific
# PostgreSQL version.
set(PG_VIRTUALENV_VERSION "" CACHE STRING "Version parameter for pg_virtualenv")
#-----------------------------------------------------------------------------
#
# Optional "iwyu" target to check headers
# https://include-what-you-use.org/
#
#-----------------------------------------------------------------------------
find_program(IWYU_TOOL NAMES iwyu_tool iwyu_tool.py)
if(IWYU_TOOL)
message(STATUS "Looking for iwyu_tool.py - found")
add_custom_target(iwyu ${IWYU_TOOL} -p ${CMAKE_BINARY_DIR} --
--no_fwd_decls
--quoted_includes_first
--mapping_file=${CMAKE_SOURCE_DIR}/iwyu.imp)
else()
message(STATUS "Looking for iwyu_tool.py - not found")
message(STATUS " Make target 'iwyu' will not be available")
endif()
#-----------------------------------------------------------------------------
#
# Optional "cppcheck" target that checks C++ code
#
#-----------------------------------------------------------------------------
message(STATUS "Looking for cppcheck")
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
message(STATUS "Looking for cppcheck - found")
set(CPPCHECK_OPTIONS --enable=all)
# cpp doesn't find system includes for some reason, suppress that report
set(CPPCHECK_OPTIONS ${CPPCHECK_OPTIONS} --suppress=missingIncludeSystem)
file(GLOB ALL_CODE src/*.cpp)
set(CPPCHECK_FILES ${ALL_CODE})
add_custom_target(cppcheck
${CPPCHECK}
--std=c++17 ${CPPCHECK_OPTIONS}
${CPPCHECK_FILES}
)
else()
message(STATUS "Looking for cppcheck - not found")
message(STATUS " Build target 'cppcheck' will not be available.")
endif(CPPCHECK)
#-----------------------------------------------------------------------------
#
# Optional "clang-tidy" target
#
#-----------------------------------------------------------------------------
message(STATUS "Looking for clang-tidy")
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11)
if(CLANG_TIDY)
message(STATUS "Looking for clang-tidy - found ${CLANG_TIDY}")
file(GLOB CT_CHECK_FILES src/*.cpp)
add_custom_target(clang-tidy
${CLANG_TIDY}
-p ${CMAKE_BINARY_DIR}
${CT_CHECK_FILES}
)
else()
message(STATUS "Looking for clang-tidy - not found")
message(STATUS " Build target 'clang-tidy' will not be available.")
endif()
#-----------------------------------------------------------------------------
#
# Version
#
#-----------------------------------------------------------------------------
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --dirty=-changed
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE VERSION_FROM_GIT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(VERSION_FROM_GIT)
set(VERSION_FROM_GIT " (${VERSION_FROM_GIT})")
endif()
endif()
configure_file(
${PROJECT_SOURCE_DIR}/src/version.cpp.in
${PROJECT_BINARY_DIR}/src/version.cpp
)
#-----------------------------------------------------------------------------
#
# Tests
#
#-----------------------------------------------------------------------------
enable_testing()
add_subdirectory(test)
#-----------------------------------------------------------------------------
add_subdirectory(man)
add_subdirectory(src)
if(BUILD_PLUGIN)
add_subdirectory(postgresql-plugin)
endif()
#-----------------------------------------------------------------------------