1
1
################################################################################
2
- # CMake
2
+ # Set minimum required version of cmake, project name and compile options
3
3
################################################################################
4
4
cmake_minimum_required (VERSION 2.8.3)
5
5
project (robotis_controller)
6
6
7
- set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} " )
7
+ ## Compile as C++11, supported in ROS Kinetic and newer
8
+ add_compile_options (-std=c++11)
8
9
9
10
################################################################################
10
- # Packages
11
+ # Find catkin packages and libraries for catkin and system dependencies
11
12
################################################################################
12
13
find_package (catkin REQUIRED COMPONENTS
13
14
roscpp
@@ -21,8 +22,27 @@ find_package(catkin REQUIRED COMPONENTS
21
22
cmake_modules
22
23
)
23
24
25
+ # Resolve system dependency on yaml-cpp, which apparently does not
26
+ # provide a CMake find_package() module.
24
27
find_package (PkgConfig REQUIRED)
25
- pkg_check_modules(yaml_cpp yaml-cpp REQUIRED)
28
+ pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
29
+ find_path (YAML_CPP_INCLUDE_DIR
30
+ NAMES yaml_cpp.h
31
+ PATHS ${YAML_CPP_INCLUDE_DIRS}
32
+ )
33
+ find_library (YAML_CPP_LIBRARY
34
+ NAMES YAML_CPP
35
+ PATHS ${YAML_CPP_LIBRARY_DIRS}
36
+ )
37
+ link_directories (${YAML_CPP_LIBRARY_DIRS} )
38
+
39
+ if (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5" )
40
+ add_definitions (-DHAVE_NEW_YAMLCPP)
41
+ endif (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5" )
42
+
43
+ ################################################################################
44
+ # Setup for python modules and scripts
45
+ ################################################################################
26
46
27
47
################################################################################
28
48
# Declare ROS messages, services and actions
@@ -33,7 +53,7 @@ pkg_check_modules(yaml_cpp yaml-cpp REQUIRED)
33
53
################################################################################
34
54
35
55
################################################################################
36
- # Catkin specific configuration
56
+ # Declare catkin specific configuration to be passed to dependent projects
37
57
################################################################################
38
58
catkin_package(
39
59
INCLUDE_DIRS include
@@ -47,12 +67,12 @@ catkin_package(
47
67
include_directories (
48
68
include
49
69
${catkin_INCLUDE_DIRS}
50
- ${yaml_cpp_INCLUDE_DIRS }
70
+ ${YAML_CPP_INCLUDE_DIRS }
51
71
)
52
72
53
73
add_library (robotis_controller src/robotis_controller/robotis_controller.cpp)
54
74
add_dependencies (robotis_controller ${catkin_EXPORTED_TARGETS} )
55
- target_link_libraries (robotis_controller ${yaml_cpp_LIBRARIES } ${catkin_LIBRARIES } )
75
+ target_link_libraries (robotis_controller ${catkin_LIBRARIES } ${YAML_CPP_LIBRARIES } )
56
76
57
77
################################################################################
58
78
# Install
0 commit comments