CMakeLists.txt 4.93 KB
Newer Older
1
2
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)

Lorenz Meier's avatar
Lorenz Meier committed
3
4
5
# Add search directory for CMake on OS X
list(APPEND CMAKE_MODULE_PATH /usr/local/share/cmake/Modules)

6
find_package( PkgConfig REQUIRED)
ChristophTobler's avatar
ChristophTobler committed
7
8
find_package(OpenCV REQUIRED)
find_package(gazebo REQUIRED)
9
10
11
12
if(${GAZEBO_VERSION} VERSION_LESS "6.0")
  message(FATAL_ERROR "You need at least Gazebo 6.0. Your version: ${GAZEBO_VERSION}")
endif()

13
14
15
find_package(Eigen3 QUIET)
if(NOT EIGEN3_FOUND)
  # Fallback to cmake_modules
Lorenz Meier's avatar
Lorenz Meier committed
16
17
18
19
20
21
22
  find_package(Eigen QUIET)
  if(NOT EIGEN_FOUND)
    pkg_check_modules( EIGEN3 REQUIRED eigen3)
  else()
    set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
    set(EIGEN3_LIBRARIES ${EIGEN_LIBRARIES})
  endif()
23
24
25
26
else()
  set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
endif()

Lorenz Meier's avatar
Lorenz Meier committed
27
pkg_check_modules( protobuf REQUIRED protobuf )
28

29
FIND_PACKAGE( Boost 1.40 COMPONENTS system thread REQUIRED )
30
31
add_definitions(-std=c++11)

32
33
34
35
36
37
38
set(GAZEBO_MSG_INCLUDE_DIRS)
foreach(ITR ${GAZEBO_INCLUDE_DIRS})
  if(ITR MATCHES ".*gazebo-[0-9.]+$")
    set(GAZEBO_MSG_INCLUDE_DIRS "${ITR}/gazebo/msgs")
  endif()
endforeach()

39
40
41
include_directories(
  include
  ${GAZEBO_INCLUDE_DIRS}
42
  ${GAZEBO_MSG_INCLUDE_DIRS}
43
  ${EIGEN3_INCLUDE_DIRS}
ChristophTobler's avatar
ChristophTobler committed
44
  ${OpenCV_INCLUDE_DIRS}
45
  ${CMAKE_CURRENT_BINARY_DIR}/msgs
Lorenz Meier's avatar
Lorenz Meier committed
46
  ${Boost_INCLUDE_DIR}
Lorenz Meier's avatar
Lorenz Meier committed
47
48
  # Workaround for Eigen3
  ${Boost_INCLUDE_DIR}/eigen3
Lorenz Meier's avatar
Lorenz Meier committed
49
  ${EIGEN3_INCLUDE_DIRS}/eigen3
50
  # Workaround for OGRE include dirs on Mac OS
Lorenz Meier's avatar
Lorenz Meier committed
51
  /usr/local/include/OGRE
SimsGautam's avatar
SimsGautam committed
52
  /usr/local/include/OGRE/Paging
53
54
  )

55
56
57
set(enable_mavlink_interface "true")
set(enable_ground_truth "false")
set(enable_logging "false")
58
set(enable_camera "false")
59
set(rotors_description_dir "${CMAKE_SOURCE_DIR}/models/rotors_description")
60
set(scripts_dir "${CMAKE_SOURCE_DIR}/scripts")
61
add_custom_target(sdf
62
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
63
	COMMAND rm -f ${CMAKE_SOURCE_DIR}/models/iris/iris.sdf
64
	COMMAND python ${scripts_dir}/xacro.py -o  ${rotors_description_dir}/urdf/iris_base.urdf  ${rotors_description_dir}/urdf/iris_base.xacro enable_mavlink_interface:=${enable_mavlink_interface} enable_ground_truth:=${enable_ground_truth} enable_logging:=${enable_logging} rotors_description_dir:=${rotors_description_dir} 
65
66
	COMMAND gz sdf -p  ${rotors_description_dir}/urdf/iris_base.urdf >> ${CMAKE_SOURCE_DIR}/models/iris/iris.sdf
	COMMAND rm -f ${rotors_description_dir}/urdf/iris_base.urdf
67
68
	)

69
70
71
72
73
link_directories(${GAZEBO_LIBRARY_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/msgs)
add_subdirectory(msgs)

list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")

74
add_library(hello_world SHARED src/hello_world.cc)
75
target_link_libraries(hello_world ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
76

77
add_library(rotors_gazebo_controller_interface SHARED src/gazebo_controller_interface.cpp)
Lorenz Meier's avatar
Lorenz Meier committed
78
target_link_libraries(rotors_gazebo_controller_interface ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE} ${PROTOBUF_LIBRARY} mav_msgs)
79
add_dependencies(rotors_gazebo_controller_interface mav_msgs)
80

81
add_library(rotors_gazebo_motor_model SHARED src/gazebo_motor_model.cpp)
82
target_link_libraries(rotors_gazebo_motor_model mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
83
add_dependencies(rotors_gazebo_motor_model mav_msgs)
84

85
add_library(rotors_gazebo_multirotor_base_plugin SHARED src/gazebo_multirotor_base_plugin.cpp)
86
target_link_libraries(rotors_gazebo_multirotor_base_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
87
88
add_dependencies(rotors_gazebo_multirotor_base_plugin mav_msgs)

89
add_library(rotors_gazebo_imu_plugin SHARED src/gazebo_imu_plugin.cpp)
90
target_link_libraries(rotors_gazebo_imu_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
91
add_dependencies(rotors_gazebo_imu_plugin mav_msgs)
92

ChristophTobler's avatar
ChristophTobler committed
93
add_library(gazebo_opticalFlow_plugin SHARED src/gazebo_opticalFlow_plugin.cpp)
94
target_link_libraries(gazebo_opticalFlow_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE} ${OpenCV_LIBS})
ChristophTobler's avatar
ChristophTobler committed
95
96
97
add_dependencies(gazebo_opticalFlow_plugin mav_msgs)

add_library(gazebo_lidar_plugin SHARED src/gazebo_lidar_plugin.cpp)
98
target_link_libraries(gazebo_lidar_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
ChristophTobler's avatar
ChristophTobler committed
99
100
add_dependencies(gazebo_lidar_plugin mav_msgs)

101
add_library(rotors_gazebo_mavlink_interface SHARED src/gazebo_mavlink_interface.cpp src/geo_mag_declination.cpp)
102
target_link_libraries(rotors_gazebo_mavlink_interface mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
103
add_dependencies(rotors_gazebo_mavlink_interface mav_msgs)
104

105
add_library(LiftDragPlugin SHARED src/liftdrag_plugin/liftdrag_plugin.cpp)
106
target_link_libraries(LiftDragPlugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
107
add_dependencies(LiftDragPlugin mav_msgs)