-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
143 lines (120 loc) · 4.23 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
cmake_minimum_required(VERSION 2.8.3)
# Cmake policy
if(COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# Project name and the type of project
PROJECT(gocator_3100)
message(STATUS "Executig CMakeLists of project ${PROJECT_NAME}.")
# DEBUG/RELEASE
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RELEASE")
ENDIF (NOT CMAKE_BUILD_TYPE)
message(STATUS "Configured to compile in ${CMAKE_BUILD_TYPE} mode.")
#Set Flags
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -D_REENTRANT")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT")
#Set compiler according C++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++11 support.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++0x support.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
## Find catkin macros and libraries
find_package(
catkin REQUIRED
COMPONENTS
roscpp
rospy
dynamic_reconfigure
# message_generation
std_msgs
sensor_msgs
pcl_ros
pcl_conversions
)
# Find point cloud Library
FIND_PACKAGE(PCL 1.3 REQUIRED COMPONENTS)
INCLUDE_DIRECTORIES(${PCL_INCLUDE_DIRS})
LINK_DIRECTORIES(${PCL_LIBRARY_DIRS})
ADD_DEFINITIONS(${PCL_DEFINITIONS})
# Set GO_SDK include paths (That could be part of a FindGocator.cmake)
SET(GO_SDK_4 /home/zyx/ZYX_platform/GO_SDK) # TODO: Should be an env variable!!
FIND_PATH(
GOCATOR_INCLUDES
NAMES GoSdk/GoSdk.h
PATHS ${GO_SDK_4}/Gocator/GoSdk)
FIND_PATH(
KAPI_INCLUDES
NAMES kApi/kApi.h
PATHS ${GO_SDK_4}/Platform/kApi)
INCLUDE_DIRECTORIES(${GOCATOR_INCLUDES} ${KAPI_INCLUDES})
# Set GO_SDK libs (That could be part of a FindGocator.cmake)
FIND_LIBRARY(
GOCATOR_LIBRARIES
NAMES GoSdk
PATHS ${GO_SDK_4}/lib/gnud/)
FIND_LIBRARY(
KAPI_LIBRARIES
NAMES kApi
PATHS ${GO_SDK_4}/lib/gnud/)
message(STATUS "Gocator Headers found at ${GOCATOR_INCLUDES}.")
message(STATUS "Gocator Libraries found at ${GOCATOR_LIBRARIES}.")
# add other necessary include directories
include_directories(src/ src/lib/src/ ${catkin_INCLUDE_DIRS})
# Set source files for the library
SET(SRCS_LIB
src/lib/src/gocator3100.cpp)
# Set header files for the library
SET(HDRS_LIB
src/lib/src/gocator3100.h)
# Set source files for the ROS node
SET(SRCS_NODE
src/gocator_3100_node.cpp
src/gocator_3100_node_main.cpp
)
# add_service_files(
# FILES
# PointCloudAsService.srv
# )
## Generate added messages and services
# generate_messages(
# DEPENDENCIES
# std_msgs
# sensor_msgs
# )
#dynamic reconfigure cfg file
generate_dynamic_reconfigure_options(cfg/gocator_3100_params.cfg)
## The catkin_package macro generates cmake config files for your package
catkin_package(
CATKIN_DEPENDS
roscpp
rospy
dynamic_reconfigure
# message_runtime
std_msgs
sensor_msgs
pcl_ros
pcl_conversions
)
#Build library (TODO: Should call a CMakeLists.txt at src/lib/)
ADD_LIBRARY(${PROJECT_NAME}_LIB SHARED ${SRCS_LIB})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}_LIB ${GOCATOR_LIBRARIES} ${KAPI_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
#Build executable
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS_NODE} ${SRCS_LIB})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${GOCATOR_LIBRARIES} ${KAPI_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_gencpp ${PROJECT_NAME}_gencfg)
#Build examples TODO: Should be called from a CMakeLists at at src/lib/
ADD_SUBDIRECTORY(src/lib/src/examples)
## Declare a cpp executable
# add_executable(btr_point_tracker_node ${SRCS} src/btr_point_tracker_main.cpp)
# add_dependencies(btr_point_tracker_node ${PROJECT_NAME}_EXPORTED_TARGETS)
# target_link_libraries(btr_point_tracker_node ${OpenCV_LIBS} ${catkin_LIBRARIES})