-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
108 lines (86 loc) · 2.84 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
cmake_minimum_required(VERSION 3.5.1)
project(opendrive-engine VERSION 1.0.2)
set(TARGET_NAME ${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set(CMAKE_BUILD_TYPE Debug) # Debug Release
option(BUILD_SHARED_LIBS "Build opendrive-engine shared library" ON)
option(BUILD_OPENDRIVE_ENGINE_TEST "Build opendrive-engine unittest" OFF)
option(BUILD_OPENDRIVE_ENGINE_VIEWER "Build opendrive-engine tools viewer" OFF)
set(OPENDRIVE_ENGINE_SHARED_TYPE SHARED)
if(NOT BUILD_SHARED_LIBS)
set(OPENDRIVE_ENGINE_SHARED_TYPE STATIC)
endif()
message("---- option shared type:${OPENDRIVE_ENGINE_SHARED_TYPE}")
message("---- option unittest:${BUILD_OPENDRIVE_ENGINE_TEST}")
message("---- option build type:${CMAKE_BUILD_TYPE}")
message("---- option view:${BUILD_OPENDRIVE_ENGINE_VIEWER}")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Tinyxml2 REQUIRED tinyxml2)
pkg_check_modules(NanoFlann REQUIRED nanoflann)
include_directories(
include
${Tinyxml2_INCLUDE_DIRS}
${NanoFlann_INCLUDE_DIRS}
)
link_directories(
${Tinyxml2_LIBRARY_DIRS}
)
file(GLOB_RECURSE OPENDRIVE_ENGINE_SRCS
"src/*.cc"
)
add_library(${TARGET_NAME} ${OPENDRIVE_ENGINE_SHARED_TYPE}
${OPENDRIVE_ENGINE_SRCS}
)
target_link_libraries(${TARGET_NAME}
${Tinyxml2_LIBRARIES}
)
if(BUILD_OPENDRIVE_ENGINE_TEST)
add_subdirectory(tests)
endif()
if(BUILD_OPENDRIVE_ENGINE_VIEWER)
add_subdirectory(viewer/backend)
endif()
# ##############################################################################
# config
# ##############################################################################
configure_file("cmake/${TARGET_NAME}.pc.in"
"${PROJECT_BINARY_DIR}/pkgconfig/${TARGET_NAME}.pc" @ONLY)
configure_package_config_file(
"cmake/${TARGET_NAME}-config.cmake.in"
"${PROJECT_BINARY_DIR}/cmake/${TARGET_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${TARGET_NAME}"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR)
write_basic_package_version_file(
"cmake/${TARGET_NAME}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES
"${PROJECT_BINARY_DIR}/pkgconfig/${TARGET_NAME}.pc"
DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig"
)
install(EXPORT
${TARGET_NAME}-targets
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${TARGET_NAME}"
)
install(FILES
"${PROJECT_BINARY_DIR}/cmake/${TARGET_NAME}-config.cmake"
"${PROJECT_BINARY_DIR}/cmake/${TARGET_NAME}-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${TARGET_NAME}"
)
install(
DIRECTORY include/${TARGET_NAME}/
DESTINATION include/${TARGET_NAME}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
install(
TARGETS ${TARGET_NAME}
EXPORT ${TARGET_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bib
)