forked from nilsnolde/py-osrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·126 lines (110 loc) · 3.53 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
cmake_minimum_required(VERSION 3.18)
set(PROJECT_NAME "osrm")
set(EXT_NAME "osrm_ext")
project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT SKBUILD)
message(WARNING
"This CMake file is meant to be executed using 'scikit-build-core'.
Running it directly will almost certainly not produce the desired
result. If you are a user trying to install this package, use the
command below, which will install all necessary build dependencies,
compile the package in an isolated environment, and then install it.
=====================================================================
$ pip install .
====================================================================="
)
endif()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
find_package(Python 3.8
REQUIRED COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule
)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR
)
list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}")
find_package(nanobind CONFIG REQUIRED)
set(SRCS
src/osrm_nb.cpp
src/engineconfig_nb.cpp
src/utility/osrm_utility.cpp
src/utility/param_utility.cpp
src/parameters/baseparameter_nb.cpp
src/parameters/routeparameter_nb.cpp
src/parameters/matchparameter_nb.cpp
src/parameters/nearestparameter_nb.cpp
src/parameters/tableparameter_nb.cpp
src/parameters/tileparameter_nb.cpp
src/parameters/tripparameter_nb.cpp
src/types/optional_nb.cpp
src/types/coordinate_nb.cpp
src/types/jsoncontainer_nb.cpp
src/types/approach_nb.cpp
src/types/bearing_nb.cpp
)
nanobind_add_module(
${EXT_NAME}
STABLE_ABI
NB_STATIC
${SRCS}
${UTIL}
${PARAMS}
)
target_include_directories(${EXT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/utility
${CMAKE_CURRENT_SOURCE_DIR}/include/parameters
)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(LibOSRM)
if(LibOSRM_FOUND)
target_link_libraries(${EXT_NAME}
PRIVATE
${LibOSRM_LIBRARIES}
${LibOSRM_DEPENDENT_LIBRARIES}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LibOSRM_CXXFLAGS}")
file(GLOB OSRM_EXECS ${LibOSRM_EXEC_DIR}/osrm-*)
install(FILES ${OSRM_EXECS} TYPE BIN
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
else()
include(FetchContent)
FetchContent_Declare(
libosrm
GIT_REPOSITORY https://github.com/Project-OSRM/osrm-backend
GIT_TAG master
)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-array-bounds -Wno-uninitialized -Wno-free-nonheap-object")
FetchContent_GetProperties(libosrm)
if(NOT libosrm_POPULATED)
FetchContent_Populate(libosrm)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(
${libosrm_SOURCE_DIR}
${libosrm_BINARY_DIR}
)
endif()
target_include_directories(${EXT_NAME}
PUBLIC
${libosrm_SOURCE_DIR}/include
${libosrm_SOURCE_DIR}/third_party/variant/include
${libosrm_SOURCE_DIR}/third_party/flatbuffers/include
)
target_link_libraries(${EXT_NAME}
PRIVATE
osrm
)
endif()
if (MSVC)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
install(TARGETS ${EXT_NAME} LIBRARY DESTINATION ${PROJECT_NAME})