-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCMakeLists.txt
86 lines (68 loc) · 2.72 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
cmake_minimum_required(VERSION 3.0.2)
project(warehouse_ros_mongo)
# Set compile options
set(PROJECT_COMPILE_OPTIONS
-Wall
-Wextra
-Wpedantic
)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
find_package(catkin REQUIRED COMPONENTS
class_loader
roscpp
rostest
rostime
std_msgs
warehouse_ros
)
find_package(Boost REQUIRED COMPONENTS system filesystem thread)
find_package(OpenSSL REQUIRED)
find_package(MongoDB REQUIRED)
# At least gcc 7.4 has issues compiling against mongoclient with optimization > 1 enabled.
# In this case, Labeler symbols LT, GT, etc. are null, causing weird results.
if (CMAKE_COMPILER_IS_GNUCC)
add_compile_options(-O1)
endif()
include(CheckIncludeFileCXX)
check_include_file_cxx("mongo/version.h" HAVE_MONGO_VERSION_H)
if(HAVE_MONGO_VERSION_H)
add_definitions(-DWAREHOUSE_ROS_MONGO_HAVE_MONGO_VERSION_H)
endif()
set(MONGO_EXPORT)
if("${MongoDB_LIBRARIES}" MATCHES "\\.so$")
set(MONGO_EXPORT MongoDB)
endif()
file(MAKE_DIRECTORY "${CATKIN_DEVEL_PREFIX}/include")
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS roscpp rostime std_msgs
DEPENDS Boost ${MONGO_EXPORT}
)
if (NOT MongoDB_EXPOSE_MACROS)
add_definitions(-DMONGO_EXPOSE_MACROS)
endif()
configure_file("include/${PROJECT_NAME}/config.h.in" "${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}/config.h")
#catkin_lint: ignore_once external_directory (${CATKIN_DEVEL_PREFIX}/include)
include_directories(${CATKIN_DEVEL_PREFIX}/include include ${catkin_INCLUDE_DIRS} ${MongoDB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
set(warehouse_srcs
src/database_connection.cpp
src/message_collection.cpp
src/query_results.cpp)
add_library(${PROJECT_NAME} SHARED ${warehouse_srcs})
target_compile_options(${PROJECT_NAME} PRIVATE ${PROJECT_COMPILE_OPTIONS})
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${MongoDB_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES})
if(CATKIN_ENABLE_TESTING)
add_executable(test_${PROJECT_NAME}_cpp test/test_${PROJECT_NAME}.cpp)
target_link_libraries(test_${PROJECT_NAME}_cpp ${PROJECT_NAME} ${GTEST_LIBRARIES})
add_rostest(test/${PROJECT_NAME}.test)
endif()
catkin_install_python(PROGRAMS scripts/mongo_wrapper_ros.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h")
#catkin_lint: ignore_once external_file
install(FILES "${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}/config.h"
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(FILES mongo_database_connection_plugin_description.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})