|
1 | | -cmake_minimum_required(VERSION 3.15.0) |
2 | | -project(pyosmium VERSION 4.0.2) |
| 1 | +cmake_minimum_required(VERSION 3.15...4.0) |
| 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 | | - |
8 | | -find_package(Osmium 2.16 REQUIRED COMPONENTS io pbf xml) |
9 | | - |
10 | | -if(WITH_LZ4) |
11 | | -find_package(LZ4) |
12 | | - |
13 | | - if(LZ4_FOUND) |
14 | | - message(STATUS "lz4 library found, compiling with it") |
15 | | - add_definitions(-DOSMIUM_WITH_LZ4) |
16 | | - include_directories(SYSTEM ${LZ4_INCLUDE_DIRS}) |
17 | | - list(APPEND OSMIUM_LIBRARIES ${LZ4_LIBRARIES}) |
18 | | - else() |
19 | | - message(WARNING "lz4 library not found, compiling without it") |
20 | | - endif() |
21 | | -else() |
22 | | - message(STATUS "Building without lz4 support: Set WITH_LZ4=ON to change this") |
23 | | -endif() |
24 | | - |
25 | | -include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS} ${PROTOZERO_INCLUDE_DIR}) |
26 | | -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib) |
27 | | - |
28 | | -if(NOT "${CMAKE_CXX_STANDARD}") |
29 | | - set(CMAKE_CXX_STANDARD 17) |
30 | | -endif() |
31 | | - |
32 | | -set(PYBIND11_CPP_STANDARD -std=c++${CMAKE_CXX_STANDARD}) |
33 | | - |
34 | | -message(STATUS "Building in C++${CMAKE_CXX_STANDARD} mode") |
35 | | - |
36 | | -find_package(Python COMPONENTS Interpreter Development) |
37 | | - |
38 | | -# Check for abiflags, so we can check for free-threaded later. |
39 | | -execute_process(COMMAND ${Python_EXECUTABLE} -c "import sys; print(sys.abiflags, end='')" |
40 | | - OUTPUT_VARIABLE PYTHON_ABIFLAGS) |
41 | | - |
42 | | -if(PYBIND11_PREFIX) |
43 | | - add_subdirectory(${PYBIND11_PREFIX} contrib/pybind11) |
44 | | -elseif(PYTHON_ABIFLAGS STREQUAL "t") |
45 | | - message(STATUS "Free-threading Python found. Enabling support (needs pybind11 2.13+).") |
46 | | - find_package(pybind11 2.13 REQUIRED) |
47 | | -else() |
48 | | - find_package(pybind11 2.9 REQUIRED) |
49 | | -endif() |
50 | | - |
51 | | -find_package(Boost 1.70 REQUIRED COMPONENTS) |
52 | | -include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) |
53 | | - |
54 | | -function(set_module_output module outdir) |
55 | | - set_target_properties(${module} PROPERTIES |
56 | | - LIBRARY_OUTPUT_DIRECTORY |
57 | | - ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${outdir}) |
58 | | - # windows needs a build type variant |
59 | | - foreach(config ${CMAKE_CONFIGURATION_TYPES}) |
60 | | - string(TOUPPER ${config} config) |
61 | | - set_target_properties(${module} PROPERTIES |
62 | | - LIBRARY_OUTPUT_DIRECTORY_${config} |
63 | | - ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${outdir}) |
64 | | - endforeach() |
65 | | -endfunction() |
66 | | - |
67 | | -# Modules without any Python code and just one source file. |
68 | | -foreach(PYMOD geom index io area) |
69 | | - pybind11_add_module(${PYMOD} lib/${PYMOD}.cc) |
70 | | - set_module_output(${PYMOD} osmium) |
71 | | - target_link_libraries(${PYMOD} PRIVATE ${OSMIUM_LIBRARIES}) |
72 | | - if(APPLE) |
73 | | - set_target_properties(${PYMOD} PROPERTIES CXX_VISIBILITY_PRESET "default") |
74 | | - endif() |
75 | | -endforeach() |
76 | | - |
77 | | -# Modules where additional Python code is in src (C++-part will be private). |
78 | | -foreach(PYMOD osm replication) |
79 | | - pybind11_add_module(_${PYMOD} lib/${PYMOD}.cc) |
80 | | - set_module_output(_${PYMOD} osmium/${PYMOD}) |
81 | | - target_link_libraries(_${PYMOD} PRIVATE ${OSMIUM_LIBRARIES}) |
82 | | - if(APPLE) |
83 | | - set_target_properties(_${PYMOD} PROPERTIES CXX_VISIBILITY_PRESET "default") |
84 | | - endif() |
85 | | -endforeach() |
86 | | - |
87 | | -# Modules with multiple source files. |
88 | | -pybind11_add_module(_osmium |
89 | | - lib/osmium.cc |
90 | | - lib/merge_input_reader.cc |
91 | | - lib/node_location_handler.cc |
92 | | - lib/simple_writer.cc |
93 | | - lib/file_iterator.cc |
94 | | - lib/id_tracker.cc) |
95 | | -set_module_output(_osmium osmium) |
96 | | -target_link_libraries(_osmium PRIVATE ${OSMIUM_LIBRARIES}) |
97 | | - |
98 | | -pybind11_add_module(filter |
99 | | - lib/filter.cc |
100 | | - lib/empty_tag_filter.cc |
101 | | - lib/key_filter.cc |
102 | | - lib/tag_filter.cc |
103 | | - lib/id_filter.cc |
104 | | - lib/entity_filter.cc |
105 | | - lib/geo_interface_filter.cc) |
106 | | -set_module_output(filter osmium) |
107 | | -target_link_libraries(filter PRIVATE ${OSMIUM_LIBRARIES}) |
108 | | - |
109 | | -# workaround for https://github.com/pybind/pybind11/issues/1272 |
110 | | -if(APPLE) |
111 | | - set_target_properties(_osmium PROPERTIES CXX_VISIBILITY_PRESET "default") |
112 | | - set_target_properties(filter PROPERTIES CXX_VISIBILITY_PRESET "default") |
113 | | -endif() |
| 4 | +set(PYBIND11_FINDPYTHON ON) |
| 5 | +find_package(pybind11 CONFIG REQUIRED) |
114 | 6 |
|
0 commit comments