-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
235 lines (176 loc) · 6.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
cmake_minimum_required(VERSION 2.8.3)
project(novatel)
#######################################
## Check for ROS ##
#######################################
option(BUILD_WITH_ROS "Build ROS node and use catkin." ON)
if (NOT catkin_FOUND)
SET(BUILD_WITH_ROS OFF)
endif(NOT catkin_FOUND)
## message( STATUS "catkin_FOUND: ${catkin_FOUND}" )
#include_directories(
# include/locate_node
# )
include_directories(components/serial/include)
add_subdirectory(components/serial)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x -Wfatal-errors")
if (BUILD_WITH_ROS)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
## libraries found here are added to catkin_LIBRARIES and linked automatically
## found:all libs in the COMPONENTS also in package.xml depends by yuhs
find_package(catkin REQUIRED COMPONENTS roscpp rosconsole tf msgs_ht sensor_msgs nav_msgs)
## find_package(catkin REQUIRED COMPONENTS croslib roscpp rosconsole tf msgs_ht sensor_msgs nav_msgs)
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
LIBRARIES novatel
CATKIN_DEPENDS serial roslib roscpp rosconsole tf msgs_ht nav_msgs sensor_msgs
DEPENDS Boost
)
else()
SET(CATKIN_PACKAGE_LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
SET(CATKIN_PACKAGE_BIN_DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
SET(CATKIN_PACKAGE_INCLUDE_DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
# TODO: need to find serial library here
find_package(serial REQUIRED)
set(catkin_INCLUDE_DIRS ${serial_INCLUDE_DIRS})
set(catkin_LIBRARIES ${serial_LIBRARIES})
endif (BUILD_WITH_ROS)
# System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system filesystem thread)
###########
## Build ##
###########
#####add debug for gdb
# SET(CMAKE_BUILD_TYPE "Debug")
# SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
# SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
## Specify additional locations of header files
include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(LIB_NAME novatel)
MESSAGE("Building DEBUG library ${LIB_NAME}")
else ()
set(LIB_NAME novatel)
MESSAGE("Building RELEASE library ${LIB_NAME}")
endif ()
# Declare a cpp library
# create static lib LIB_NAME
add_library(${LIB_NAME}
src/novatel.cpp
)
# Boost_LIBRARIES+catkin_LIBRARIES >> LIB_NAME
target_link_libraries(${LIB_NAME}
${Boost_LIBRARIES}
${catkin_LIBRARIES})
##############
## Examples ##
##############
option(NOVATEL_BUILD_EXAMPLES "Build all of the Novatel examples." ON)
##@
##@ # if find_package found serial,the serial_* macros will be set
##@ if(serial_FOUND)
##@ include_directories(${serial_INCLUDE_DIRS})
##@ list(APPEND NOVATEL_LINK_LIBS ${serial_LIBRARIES} pthread)
##@ if(UNIX AND NOT APPLE)
##@ list(APPEND NOVATEL_LINK_LIBS rt)
##@ endif()
##@ else(serial_FOUND)
##@ message(FATAL_ERROR "Serial library was not found.")
##@ endif(serial_FOUND)
##@
##@ if (NOVATEL_BUILD_EXAMPLES)
##@ # Declare a cpp executable
##@ add_executable(novatel_example examples/novatel_example.cpp)
##@ target_link_libraries(novatel_example
##@ ${LIB_NAME}
##@ ${catkin_LIBRARIES}
##@ ${Boost_LIBRARIES})
##@
##@ add_executable(novatel_read_from_file examples/novatel_read_from_file.cpp)
##@ target_link_libraries(novatel_read_from_file
##@ ${LIB_NAME}
##@ ${catkin_LIBRARIES}
##@ ${Boost_LIBRARIES}
##@ serial)
##@
##@ add_executable(novatel_read_bestutm examples/novatel_read_bestutm.cpp)
##@ target_link_libraries(novatel_read_bestutm
##@ ${LIB_NAME}
##@ ${catkin_LIBRARIES}
##@ ${Boost_LIBRARIES})
##@ endif (NOVATEL_BUILD_EXAMPLES)
##@
# Build ROS node
if (BUILD_WITH_ROS)
# Declare a cpp executable
add_executable(novatel_node src/novatel_node.cpp)
add_dependencies(novatel_node ${catkin_EXPORTED_TARGETS})
target_link_libraries(novatel_node novatel ${catkin_LIBRARIES} ${Boost_LIBRARIES} serial)
endif (BUILD_WITH_ROS)
#############
## Install ##
#############
##@ # Mark executables and/or libraries for installation
##@ if(BUILD_WITH_ROS)
##@ # message( STATUS "CATKIN_PACKAGE_LIB_DESTINATION: ${CATKIN_PACKAGE_LIB_DESTINATION}" )
##@ # message( STATUS "CATKIN_PACKAGE_BIN_DESTINATION: ${CATKIN_PACKAGE_BIN_DESTINATION}" )
##@ # message( STATUS "CATKIN_PACKAGE_INCLUDE_DESTINATION: ${CATKIN_PACKAGE_INCLUDE_DESTINATION}" )
##@ # message( STATUS "catkin_EXPORTED_TARGETS: ${catkin_EXPORTED_TARGETS}" )
##@ # message( STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}" )
##@ install(TARGETS novatel novatel_node
##@ ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
##@ LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
##@ RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
##@ )
##@ # Mark cpp header files for installation
##@ install(DIRECTORY include/${PROJECT_NAME}/
##@ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
##@ FILES_MATCHING PATTERN "*.h"
##@ PATTERN ".svn" EXCLUDE
##@ )
##@ else(BUILD_WITH_ROS) # do a classical install
##@ install(TARGETS ${LIB_NAME}
##@ ARCHIVE DESTINATION /usr/local/lib
##@ LIBRARY DESTINATION /usr/local/lib
##@ RUNTIME DESTINATION /usr/local/bin/${PROJECT_NAME}
##@ )
##@ install(DIRECTORY include/${PROJECT_NAME}/
##@ DESTINATION /usr/local/include/${PROJECT_NAME}
##@ )
##@ set(CMAKE_MODULE_PATH ${CMAKE_ROOT}/Modules)
##@ message(STATUS "module path: " ${CMAKE_MODULE_PATH})
##@ install(FILES Findnovatel.cmake DESTINATION ${CMAKE_MODULE_PATH})
##@ endif (BUILD_WITH_ROS)
##@
##@
##@ ## Mark other files for installation (e.g. launch and bag files, etc.)
##@ # install(FILES
##@ # # myfile1
##@ # # myfile2
##@ # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
##@ # )
#############
## Testing ##
#############
##@ option(NOVATEL_BUILD_TESTS "Build all of the Novatel tests." OFF)
##@
##@
##@ if (NOVATEL_BUILD_TESTS)
##@ # Find Google Test
##@ enable_testing()
##@ find_package(GTest REQUIRED)
##@ include_directories(${GTEST_INCLUDE_DIRS})
##@
##@ # Compile the atrv Test program
##@ add_executable(novatel_tests tests/novatel_tests.cpp)
##@ # Link the Test program to the atrv library
##@ target_link_libraries(novatel_tests ${GTEST_BOTH_LIBRARIES}
##@ novatel)
##@
##@ add_test(AllTestsIntest_novatel novatel_tests)
##@ endif (NOVATEL_BUILD_TESTS)