-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
88 lines (73 loc) · 1.97 KB
/
Copy pathCMakeLists.txt
File metadata and controls
88 lines (73 loc) · 1.97 KB
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
cmake_minimum_required(VERSION 3.10)
project(nav_generator_cpp VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find dependencies
find_package(ZLIB REQUIRED)
find_package(EXPAT REQUIRED)
find_package(BZip2 REQUIRED)
find_package(Threads REQUIRED)
find_package(GDAL REQUIRED)
# Manually find GEOS
find_path(GEOS_INCLUDE_DIR geos_c.h)
find_library(GEOS_C_LIBRARY geos_c)
if(NOT GEOS_INCLUDE_DIR OR NOT GEOS_C_LIBRARY)
message(FATAL_ERROR "GEOS (geos_c) not found. Please install libgeos-dev")
endif()
message(STATUS "Found GEOS include: ${GEOS_INCLUDE_DIR}")
message(STATUS "Found GEOS library: ${GEOS_C_LIBRARY}")
# nlohmann-json
find_package(nlohmann_json QUIET)
# Include directories
include_directories(
${GEOS_INCLUDE_DIR}
${ZLIB_INCLUDE_DIRS}
${EXPAT_INCLUDE_DIRS}
${BZIP2_INCLUDE_DIR}
${GDAL_INCLUDE_DIRS}
src
)
# Main executable
add_executable(nav_generator
src/main.cpp
)
# Link libraries
target_link_libraries(nav_generator
PRIVATE
${GEOS_C_LIBRARY}
${ZLIB_LIBRARIES}
${EXPAT_LIBRARIES}
${BZIP2_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${GDAL_LIBRARIES}
)
if(nlohmann_json_FOUND)
target_link_libraries(nav_generator PRIVATE nlohmann_json::nlohmann_json)
endif()
# Compiler optimization flags
if(MSVC)
target_compile_options(nav_generator PRIVATE /O2 /W3)
else()
target_compile_options(nav_generator PRIVATE -Wall -Wextra -O3 -march=native)
endif()
# Route graph generator
add_executable(route_generator
src/route_main.cpp
)
target_link_libraries(route_generator
PRIVATE
${GEOS_C_LIBRARY}
${ZLIB_LIBRARIES}
${EXPAT_LIBRARIES}
${BZIP2_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${GDAL_LIBRARIES}
)
if(nlohmann_json_FOUND)
target_link_libraries(route_generator PRIVATE nlohmann_json::nlohmann_json)
endif()
if(MSVC)
target_compile_options(route_generator PRIVATE /O2 /W3)
else()
target_compile_options(route_generator PRIVATE -Wall -Wextra -O3 -march=native)
endif()