forked from osmcode/pyosmium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
98 lines (80 loc) · 3.08 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
cmake_minimum_required(VERSION 2.8.12)
project(pyosmium)
set(PACKAGE_VERSION 3.0.1)
option(WITH_LZ4 "Build with lz4 support for PBF files" ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Osmium 2.16 REQUIRED COMPONENTS io pbf xml)
if(WITH_LZ4)
find_package(LZ4)
if(LZ4_FOUND)
message(STATUS "lz4 library found, compiling with it")
add_definitions(-DOSMIUM_WITH_LZ4)
include_directories(SYSTEM ${LZ4_INCLUDE_DIRS})
list(APPEND OSMIUM_LIBRARIES ${LZ4_LIBRARIES})
else()
message(WARNING "lz4 library not found, compiling without it")
endif()
else()
message(STATUS "Building without lz4 support: Set WITH_LZ4=ON to change this")
endif()
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS} ${PROTOZERO_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
if(NOT "${CMAKE_CXX_STANDARD}")
if(MSVC)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
endif()
# required for pybind11 < 2.6
if(MSVC)
set(PYBIND11_CPP_STANDARD /std=c++${CMAKE_CXX_STANDARD})
else()
set(PYBIND11_CPP_STANDARD -std=c++${CMAKE_CXX_STANDARD})
endif()
message(STATUS "Building in C++${CMAKE_CXX_STANDARD} mode")
if(PYBIND11_PREFIX)
add_subdirectory(${PYBIND11_PREFIX} contrib/pybind11)
else()
find_package(pybind11 2.2 REQUIRED)
endif()
find_package(Boost 1.41 REQUIRED COMPONENTS)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
function(set_module_output module outdir)
set_target_properties(${module} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${outdir})
# windows needs a build type variant
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config)
set_target_properties(${module} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${outdir})
endforeach()
endfunction()
set(PYOSMIUM_MODULES geom index io)
foreach(PYMOD geom index io)
pybind11_add_module(${PYMOD} lib/${PYMOD}.cc)
set_module_output(${PYMOD} osmium)
target_link_libraries(${PYMOD} PRIVATE ${OSMIUM_LIBRARIES})
if(APPLE)
set_target_properties(${PYMOD} PROPERTIES CXX_VISIBILITY_PRESET "default")
endif()
endforeach()
pybind11_add_module(_osm lib/osm.cc)
set_module_output(_osm osmium/osm)
pybind11_add_module(_osmium
lib/osmium.cc
lib/merge_input_reader.cc
lib/simple_writer.cc
lib/write_handler.cc)
set_module_output(_osmium osmium)
pybind11_add_module(_replication lib/replication.cc)
set_module_output(_replication osmium/replication)
target_link_libraries(_osmium PRIVATE ${OSMIUM_LIBRARIES})
target_link_libraries(_replication PRIVATE ${OSMIUM_LIBRARIES})
# workaround for https://github.com/pybind/pybind11/issues/1272
if(APPLE)
set_target_properties(_osmium PROPERTIES CXX_VISIBILITY_PRESET "default")
set_target_properties(_osm PROPERTIES CXX_VISIBILITY_PRESET "default")
endif()