hlrc / client / cpp / CMakeLists.txt @ 340bb7ae
History | View | Annotate | Download (6.607 KB)
1 |
PROJECT(hlrc_client_cpp) |
---|---|
2 |
|
3 |
if(NOT "${CMAKE_CXX_STANDARD}") |
4 |
set(CMAKE_CXX_STANDARD 11) |
5 |
endif() |
6 |
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
7 |
set(CMAKE_CXX_EXTENSIONS OFF) |
8 |
|
9 |
#debug? |
10 |
set(CMAKE_BUILD_TYPE Debug) |
11 |
|
12 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) |
13 |
INCLUDE(FindPkgConfig) |
14 |
|
15 |
SET(HLRC_CLIENT_LIBNAME "${PROJECT_NAME}") |
16 |
SET(HLRC_CLIENT_VERSION_MAJOR "0") |
17 |
SET(HLRC_CLIENT_VERSION_MINOR "1") |
18 |
SET(HLRC_CLIENT_VERSION_REVISION "0") |
19 |
SET(HLRC_CLIENT_VERSION "${HLRC_CLIENT_VERSION_MAJOR}.${HLRC_CLIENT_VERSION_MINOR}.${HLRC_CLIENT_VERSION_REVISION}") |
20 |
SET(HLRC_CLIENT_SOVERSION "${HLRC_CLIENT_VERSION_MAJOR}.${HLRC_CLIENT_VERSION_MINOR}") |
21 |
SET(HLRC_CLIENT_PACKAGE "${HLRC_CLIENT_LIBNAME}-${HLRC_CLIENT_VERSION_MAJOR}.${HLRC_CLIENT_VERSION_MINOR}") |
22 |
|
23 |
SET(PREFIX ${CMAKE_INSTALL_PREFIX}) |
24 |
SET(BINDIR "${PREFIX}/bin") |
25 |
SET(INCLUDEDIR "${PREFIX}/include/hlrc_client") |
26 |
SET(MANDIR "${PREFIX}/man") |
27 |
SET(LIBDIR "${PREFIX}/lib") |
28 |
SET(PKGDIR "${PREFIX}/lib/pkgconfig") |
29 |
SET(DATADIR "${PREFIX}/share/hlrc_client") |
30 |
|
31 |
####################################### |
32 |
FIND_PACKAGE(hlrc_server) |
33 |
|
34 |
####################################### |
35 |
#allow forced disable of RSB |
36 |
option(IGNORE_RSB "IGNORE_RSB" OFF) |
37 |
|
38 |
####################################### |
39 |
# check if we have RSB support: |
40 |
IF (IGNORE_RSB) |
41 |
MESSAGE(INFO "RSB disabled per command line flag IGNORE_RSB") |
42 |
ELSE (IGNORE_RSB) |
43 |
FIND_PACKAGE(RSB 0.11 QUIET) |
44 |
IF (RSB_FOUND) |
45 |
#RSB |
46 |
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:\$ORIGIN/") |
47 |
FIND_PACKAGE(RSC 0.11 REQUIRED) |
48 |
FIND_PACKAGE(RSB 0.11 REQUIRED) |
49 |
#RST |
50 |
FIND_PACKAGE(RST REQUIRED COMPONENTS sandbox) |
51 |
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${RST_INCLUDE_DIRS}) |
52 |
ADD_DEFINITIONS(${RST_CFLAGS} ${RSTSANDBOX_CFLAGS}) |
53 |
|
54 |
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${RSB_INCLUDE_DIRS}) |
55 |
LIST(INSERT CMAKE_MODULE_PATH 0 ${RSC_CMAKE_MODULE_PATH}) |
56 |
#RSB |
57 |
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:\$ORIGIN/") |
58 |
FIND_PACKAGE(RSC 0.11 REQUIRED) |
59 |
FIND_PACKAGE(RSB 0.11 REQUIRED) |
60 |
#RST |
61 |
FIND_PACKAGE(RST REQUIRED COMPONENTS sandbox) |
62 |
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${RST_INCLUDE_DIRS}) |
63 |
ADD_DEFINITIONS(${RST_CFLAGS} ${RSTSANDBOX_CFLAGS}) |
64 |
|
65 |
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${RSB_INCLUDE_DIRS}) |
66 |
LIST(INSERT CMAKE_MODULE_PATH 0 ${RSC_CMAKE_MODULE_PATH}) |
67 |
|
68 |
message(STATUS "RSB Support is ON") |
69 |
add_definitions(-DRSB_SUPPORT=1) |
70 |
ELSE(RSB_FOUND) |
71 |
message(STATUS "RSB not found.") |
72 |
ENDIF(RSB_FOUND) |
73 |
ENDIF(IGNORE_RSB) |
74 |
|
75 |
################################################################ |
76 |
# check for ROS support: |
77 |
find_package(catkin QUIET) |
78 |
IF(catkin_FOUND) |
79 |
SET(ROS_FOUND 1) |
80 |
|
81 |
catkin_package( |
82 |
INCLUDE_DIRS include |
83 |
LIBRARIES ${HLRC_CLIENT_LIBNAME} |
84 |
) |
85 |
|
86 |
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs sensor_msgs message_generation genmsg hlrc_server humotion tf2_eigen actionlib) |
87 |
|
88 |
message(STATUS "ROS Support is ON") |
89 |
add_definitions(-DROS_SUPPORT=1) |
90 |
include_directories(${catkin_INCLUDE_DIRS}) |
91 |
ELSE(catkin_FOUND) |
92 |
message(STATUS "ROS not found.") |
93 |
ENDIF(catkin_FOUND) |
94 |
|
95 |
add_definitions ("-Wall") |
96 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fstack-protector-all ") |
97 |
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" ) |
98 |
|
99 |
#search for Boost |
100 |
find_package( Boost 1.46 REQUIRED COMPONENTS program_options filesystem regex) |
101 |
LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS} ) |
102 |
include_directories(${Boost_INCLUDE_DIRS} ) |
103 |
message(STATUS "using ${Boost_LIBRARIES}") |
104 |
|
105 |
INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/include) |
106 |
|
107 |
# SET(PREFIX ${CMAKE_INSTALL_PREFIX}) |
108 |
# SET(BINDIR "${PREFIX}/bin") |
109 |
# SET(INCLUDEDIR "${PREFIX}/include") |
110 |
# SET(MANDIR "${PREFIX}/man") |
111 |
# SET(LIBDIR "${PREFIX}/lib") |
112 |
# SET(DATADIR "${PREFIX}/share/${NAME}") |
113 |
|
114 |
#this dummy list will make all header files appear if you use qtcreator to open the cmake project |
115 |
file(GLOB HEADER_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/*.h ) |
116 |
|
117 |
SET(LIB_CLASSES |
118 |
src/RobotController.cpp |
119 |
src/Middleware.cpp |
120 |
src/MiddlewareROS.cpp |
121 |
src/MiddlewareRSB.cpp |
122 |
) |
123 |
|
124 |
add_library(${HLRC_CLIENT_LIBNAME} SHARED |
125 |
${LIB_CLASSES} |
126 |
${HEADER_LIST} |
127 |
) |
128 |
|
129 |
SET(INSTALL_HEADER_LIST |
130 |
include/RobotController.h |
131 |
include/RobotGaze.h |
132 |
include/RobotTimestamp.h |
133 |
include/RobotMouth.h |
134 |
include/RobotEmotion.h |
135 |
include/RobotHeadAnimation.h |
136 |
) |
137 |
|
138 |
SET_TARGET_PROPERTIES(${HLRC_CLIENT_LIBNAME} PROPERTIES VERSION ${HLRC_CLIENT_VERSION} SOVERSION ${HLRC_CLIENT_SOVERSION}) |
139 |
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) |
140 |
LINK_DIRECTORIES(${LIBDIR}) |
141 |
IF (ROS_FOUND) |
142 |
add_dependencies(${HLRC_CLIENT_LIBNAME} ${catkin_EXPORTED_TARGETS}) |
143 |
ENDIF (ROS_FOUND) |
144 |
|
145 |
target_link_libraries(${HLRC_CLIENT_LIBNAME} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${catkin_LIBRARIES}) |
146 |
|
147 |
#build & install demo |
148 |
#ADD_EXECUTABLE(testMarkerTracker example/testMarkerTracker.cc) |
149 |
#TARGET_LINK_LIBRARIES(testMarkerTracker ${OpenCV_LIBS} ${Boost_LIBRARIES} ${Boost_LIBS} bart) |
150 |
#install(TARGETS testMarkerTracker DESTINATION bin) |
151 |
#build test |
152 |
#ADD_EXECUTABLE(testKalmanMarker src/KalmanMarker.cc) |
153 |
#TARGET_LINK_LIBRARIES(testKalmanMarker ${OpenCV_LIBS} ${Boost_LIBRARIES} ${Boost_LIBS} bart) |
154 |
|
155 |
install (TARGETS ${HLRC_CLIENT_LIBNAME} DESTINATION lib ) |
156 |
INSTALL(FILES ${INSTALL_HEADER_LIST} DESTINATION ${INCLUDEDIR}) |
157 |
|
158 |
set_target_properties(${HLRC_CLIENT_LIBNAME} PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) |
159 |
set_target_properties(${HLRC_CLIENT_LIBNAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) |
160 |
|
161 |
#create package config file |
162 |
SET(PKGCONFIG_FILENAME "hlrc_client.pc") |
163 |
configure_file("${PKGCONFIG_FILENAME}.in" "${PKGCONFIG_FILENAME}" @ONLY) |
164 |
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PKGCONFIG_FILENAME}" DESTINATION "${PKGDIR}") |
165 |
|
166 |
#create cmake config files |
167 |
SET(CMAKECONFIG_FILENAME "hlrc_clientConfig.cmake") |
168 |
configure_file("${CMAKECONFIG_FILENAME}.in" "${CMAKECONFIG_FILENAME}" @ONLY) |
169 |
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKECONFIG_FILENAME}" DESTINATION "${DATADIR}") |
170 |
|
171 |
SET(CMAKECONFIGVERSION_FILENAME "hlrc_clientConfigVersion.cmake") |
172 |
configure_file("${CMAKECONFIGVERSION_FILENAME}.in" "${CMAKECONFIGVERSION_FILENAME}" @ONLY) |
173 |
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKECONFIGVERSION_FILENAME}" DESTINATION "${DATADIR}") |
174 |
|
175 |
#ADD_EXECUTABLE(${PROJECT_NAME} main.cpp ${SRC_FILES}) |
176 |
#TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES} ${Boost_LIBS} ${BART_LIBRARIES} ) |
177 |
|
178 |
#build & install examples |
179 |
ADD_EXECUTABLE(${PROJECT_NAME}_example_random_gaze examples/random_gaze/main.cpp) |
180 |
TARGET_LINK_LIBRARIES(${PROJECT_NAME}_example_random_gaze ${HLRC_CLIENT_LIBNAME}) |
181 |
#install(TARGETS ${PROJECT_NAME}_calibrate_camera DESTINATION bin) |
182 |
ADD_EXECUTABLE(${PROJECT_NAME}_example_speech_test examples/speech_test/main.cpp) |
183 |
TARGET_LINK_LIBRARIES(${PROJECT_NAME}_example_speech_test ${HLRC_CLIENT_LIBNAME}) |