-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
98 lines (79 loc) · 2.15 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
cmake_minimum_required(VERSION 3.1)
project(range_mi)
set(CMAKE_CXX_STANDARD 11)
if(NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
######################################
# Compile the library >
######################################
# Add includes
include_directories(include)
file(GLOB SRC_FILES src/*.cpp)
add_library(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${LIBS})
set(LIBS ${LIBS} ${PROJECT_NAME})
# Install the library to CMAKE_INSTALL_PREFIX
# which defaults to /usr/local
install(TARGETS ${PROJECT_NAME}
DESTINATION lib)
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include)
######################################
# < End compile the library
######################################
######################################
# Add tests and ROS >
######################################
option(BUILD_TESTS "BUILD_TESTS" OFF)
if (BUILD_TESTS)
include_directories(test)
add_subdirectory(test)
endif()
if(DEFINED CATKIN_DEVEL_PREFIX)
# Find build dependencies
find_package(catkin REQUIRED COMPONENTS
roscpp
nav_msgs
geometry_msgs
message_generation
)
# Add the messages
file(GLOB MSG_FILES msg/*.msg)
foreach(_file ${MSG_FILES})
get_filename_component(_name ${_file} NAME)
add_message_files(
FILES
${_name}
)
endforeach()
# Generate messages
generate_messages(
DEPENDENCIES
std_msgs
)
# Define the package
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS message_runtime
)
# Add nodes
include_directories(node)
add_subdirectory(node)
# Install the library
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
endif()
######################################
# < End add tests and ROS
######################################