|
1 | 1 | cmake_minimum_required(VERSION 3.15...4.0) |
2 | 2 | project(osmium LANGUAGES CXX) |
3 | 3 |
|
| 4 | +option(WITH_LZ4 "Build with lz4 support for PBF files" ON) |
| 5 | + |
| 6 | +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
| 7 | +message(STATUS "Module path: ${CMAKE_MODULE_PATH}") |
| 8 | + |
4 | 9 | set(PYBIND11_FINDPYTHON ON) |
5 | 10 | find_package(pybind11 CONFIG REQUIRED) |
6 | 11 |
|
@@ -30,4 +35,68 @@ else() |
30 | 35 | ####################################################################### |
31 | 36 | # wheel build |
32 | 37 | # |
| 38 | + |
| 39 | +set(OSMIUM_COMPONENTS io pbf xml) |
| 40 | + |
| 41 | +if(WITH_LZ4) |
| 42 | + find_package(LZ4) |
| 43 | + if (LZ4_FOUND) |
| 44 | + list(APPEND OSMIUM_COMPONENTS lz4) |
| 45 | + message(STATUS "lz4 library found, compiling with it") |
| 46 | + else() |
| 47 | + message(WARNING "lz4 library not found, compiling without it") |
| 48 | + endif() |
| 49 | +else() |
| 50 | + message(STATUS "Building without lz4 support: Set WITH_LZ4=ON to change this") |
| 51 | +endif() |
| 52 | + |
| 53 | +find_package(Osmium 2.16 REQUIRED COMPONENTS ${OSMIUM_COMPONENTS}) |
| 54 | +include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS}) |
| 55 | + |
| 56 | +if(NOT "${CMAKE_CXX_STANDARD}") |
| 57 | + set(CMAKE_CXX_STANDARD 17) |
| 58 | +endif() |
| 59 | + |
| 60 | +message(STATUS "Building in C++${CMAKE_CXX_STANDARD} mode") |
| 61 | + |
| 62 | +find_package(Boost 1.55 REQUIRED COMPONENTS) |
| 63 | +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) |
| 64 | + |
| 65 | +# Modules without any Python code and just one source file. |
| 66 | +foreach(PYMOD geom index io area) |
| 67 | + pybind11_add_module(${PYMOD} lib/${PYMOD}.cc) |
| 68 | + target_link_libraries(${PYMOD} PRIVATE ${OSMIUM_LIBRARIES}) |
| 69 | + install(TARGETS ${PYMOD} DESTINATION osmium) |
| 70 | +endforeach() |
| 71 | + |
| 72 | +# Modules where additional Python code is in src (C++-part will be private). |
| 73 | +foreach(PYMOD osm replication) |
| 74 | + pybind11_add_module(_${PYMOD} lib/${PYMOD}.cc) |
| 75 | + target_link_libraries(_${PYMOD} PRIVATE ${OSMIUM_LIBRARIES}) |
| 76 | + install(TARGETS _${PYMOD} DESTINATION osmium/${PYMOD}) |
| 77 | +endforeach() |
| 78 | + |
| 79 | +# Modules with multiple source files. |
| 80 | +pybind11_add_module(_osmium |
| 81 | + lib/osmium.cc |
| 82 | + lib/merge_input_reader.cc |
| 83 | + lib/node_location_handler.cc |
| 84 | + lib/simple_writer.cc |
| 85 | + lib/file_iterator.cc |
| 86 | + lib/id_tracker.cc) |
| 87 | +install(TARGETS _osmium DESTINATION osmium) |
| 88 | +target_link_libraries(_osmium PRIVATE ${OSMIUM_LIBRARIES}) |
| 89 | + |
| 90 | +pybind11_add_module(filter |
| 91 | + lib/filter.cc |
| 92 | + lib/empty_tag_filter.cc |
| 93 | + lib/key_filter.cc |
| 94 | + lib/tag_filter.cc |
| 95 | + lib/id_filter.cc |
| 96 | + lib/entity_filter.cc |
| 97 | + lib/geo_interface_filter.cc) |
| 98 | +install(TARGETS filter DESTINATION osmium) |
| 99 | +target_link_libraries(filter PRIVATE ${OSMIUM_LIBRARIES}) |
| 100 | + |
| 101 | + |
33 | 102 | endif() |
0 commit comments