forked from osmcode/osmium-tool
/
CMakeLists.txt
242 lines (190 loc) · 7.15 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#-----------------------------------------------------------------------------
#
# CMake Config
#
# Osmium Tool
#
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#-----------------------------------------------------------------------------
#
# Project version
#
#-----------------------------------------------------------------------------
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel;Dev"
CACHE STRING
"List of available configuration types"
FORCE)
project(osmium)
set(OSMIUM_VERSION_MAJOR 1)
set(OSMIUM_VERSION_MINOR 3)
set(OSMIUM_VERSION_PATCH 0)
set(OSMIUM_VERSION ${OSMIUM_VERSION_MAJOR}.${OSMIUM_VERSION_MINOR}.${OSMIUM_VERSION_PATCH})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_definitions(-DOSMIUM_VERSION="${OSMIUM_VERSION}")
set(AUTHOR "Jochen Topf <jochen@topf.org>")
#-----------------------------------------------------------------------------
#
# Find external dependencies
#
#-----------------------------------------------------------------------------
find_package(Boost REQUIRED COMPONENTS program_options)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
find_package(Osmium REQUIRED COMPONENTS io)
include_directories(${OSMIUM_INCLUDE_DIRS})
#-----------------------------------------------------------------------------
#
# 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=warning,style,performance,portability,information,missingInclude)
# cpp doesn't find system includes for some reason, suppress that report
set(CPPCHECK_OPTIONS ${CPPCHECK_OPTIONS} --suppress=missingIncludeSystem)
add_custom_target(cppcheck ${CPPCHECK} --std=c++11 ${CPPCHECK_OPTIONS} ${CMAKE_SOURCE_DIR}/src/*pp)
else()
message(STATUS "Looking for cppcheck - not found")
message(STATUS " Make target cppcheck not available")
endif(CPPCHECK)
#-----------------------------------------------------------------------------
#
# Optional "man" target to generate man pages
#
#-----------------------------------------------------------------------------
message(STATUS "Looking for pandoc")
find_program(PANDOC pandoc)
function(add_man_page _section _name)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/man/man${_section})
set(_output_file ${CMAKE_BINARY_DIR}/man/man${_section}/${_name}.${_section})
set(_source_file ${CMAKE_SOURCE_DIR}/man/${_name}.md)
set(_install_dir "share/man/man{$_section}")
string(TOUPPER ${_name} _name_upcase)
add_custom_command(OUTPUT ${_output_file}
COMMAND ${PANDOC}
${PANDOC_MAN_OPTIONS}
--variable "title=${_name_upcase}"
--variable "section=${_section}"
-o ${_output_file}
${_source_file}
DEPENDS ${_source_file} man/manpage.template
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Building manpage ${_name}.${_section}"
VERBATIM)
set(ALL_MAN_PAGES "${ALL_MAN_PAGES};${_output_file}" PARENT_SCOPE)
endfunction()
if(PANDOC)
message(STATUS "Looking for pandoc - found")
message(STATUS " Manual pages will be built")
set(PANDOC_MAN_OPTIONS
-s
-t man
--template ${CMAKE_CURRENT_SOURCE_DIR}/man/manpage.template
--variable "description=osmium/${OSMIUM_VERSION}"
--variable "version=${OSMIUM_VERSION}"
--variable "author=${AUTHOR}"
)
set(PANDOC_HTML_OPTIONS -s -t html)
add_man_page(1 osmium)
add_man_page(1 osmium-add-refs)
add_man_page(1 osmium-apply-changes)
add_man_page(1 osmium-cat)
add_man_page(1 osmium-check-refs)
add_man_page(1 osmium-fileinfo)
add_man_page(1 osmium-getid)
add_man_page(1 osmium-merge-changes)
add_man_page(1 osmium-renumber)
add_man_page(1 osmium-sort)
add_man_page(1 osmium-time-filter)
add_man_page(5 osmium-file-formats)
install(DIRECTORY ${CMAKE_BINARY_DIR}/man DESTINATION share)
add_custom_target(man ALL DEPENDS ${ALL_MAN_PAGES})
else()
message(STATUS "Looking for pandoc - not found")
message(STATUS " Manual pages will not be built")
endif(PANDOC)
#-----------------------------------------------------------------------------
#
# Decide which C++ version to use (Minimum/default: C++11).
#
#-----------------------------------------------------------------------------
if(NOT MSVC)
if(NOT USE_CPP_VERSION)
set(USE_CPP_VERSION c++11)
endif()
message(STATUS "Use C++ version: ${USE_CPP_VERSION}")
# following only available from cmake 2.8.12:
# add_compile_options(-std=${USE_CPP_VERSION})
# so using this instead:
add_definitions(-std=${USE_CPP_VERSION})
endif()
#-----------------------------------------------------------------------------
#
# Compiler and Linker flags
#
#-----------------------------------------------------------------------------
if(MSVC)
set(USUAL_COMPILE_OPTIONS "/Ox")
else()
set(USUAL_COMPILE_OPTIONS "-O3 -g")
endif()
if(WIN32)
add_definitions(-DWIN32 -D_WIN32 -DMSWIN32 -DBGDWIN32
-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0600)
endif()
set(CMAKE_CXX_FLAGS_DEV "${USUAL_COMPILE_OPTIONS}"
CACHE STRING "Flags used by the compiler during developer builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEV ""
CACHE STRING "Flags used by the linker during developer builds."
FORCE)
mark_as_advanced(
CMAKE_CXX_FLAGS_DEV
CMAKE_EXE_LINKER_FLAGS_DEV
)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${USUAL_COMPILE_OPTIONS}"
CACHE STRING "Flags used by the compiler during RELWITHDEBINFO builds."
FORCE)
#-----------------------------------------------------------------------------
#
# Build Type
#
#-----------------------------------------------------------------------------
# In 'Dev' mode: compile with very strict warnings and turn them into errors.
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
if(NOT MSVC)
add_definitions(-Werror)
endif()
add_definitions(${OSMIUM_WARNING_OPTIONS})
endif()
# Force RelWithDebInfo build type if none was given
if(CMAKE_BUILD_TYPE)
set(build_type ${CMAKE_BUILD_TYPE})
else()
set(build_type "RelWithDebInfo")
endif()
set(CMAKE_BUILD_TYPE ${build_type}
CACHE STRING
"Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}."
FORCE)
#-----------------------------------------------------------------------------
configure_file(
${PROJECT_SOURCE_DIR}/osmium-wrapper.in
${PROJECT_BINARY_DIR}/osmium
)
#-----------------------------------------------------------------------------
#
# Tests
#
#-----------------------------------------------------------------------------
enable_testing()
add_subdirectory(test)
#-----------------------------------------------------------------------------
include_directories(include)
include_directories(${PROJECT_BINARY_DIR}/src)
add_subdirectory(src)
#-----------------------------------------------------------------------------