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

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

10
find_package(Eigen3 REQUIRED)
Lorenz Meier's avatar
Lorenz Meier committed
11
pkg_check_modules( protobuf REQUIRED protobuf )
12

13
FIND_PACKAGE( Boost 1.40 COMPONENTS system thread REQUIRED )
Lorenz Meier's avatar
Lorenz Meier committed
14
pkg_check_modules(SDF REQUIRED sdformat)
15
16
add_definitions(-std=c++11)

17
18
19
20
21
22
23
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()

24
25
26
include_directories(
  include
  ${GAZEBO_INCLUDE_DIRS}
27
  ${GAZEBO_MSG_INCLUDE_DIRS}
28
  ${SDF_INCLUDE_DIRS}
29
  ${EIGEN3_INCLUDE_DIR}
ChristophTobler's avatar
ChristophTobler committed
30
  ${OpenCV_INCLUDE_DIRS}
31
  ${CMAKE_CURRENT_BINARY_DIR}/msgs
Lorenz Meier's avatar
Lorenz Meier committed
32
  ${Boost_INCLUDE_DIR}
33
  # Workaround for OGRE include dirs on Mac OS
Lorenz Meier's avatar
Lorenz Meier committed
34
  /usr/local/include/OGRE
SimsGautam's avatar
SimsGautam committed
35
  /usr/local/include/OGRE/Paging
36
37
  )

38
39
40
set(enable_mavlink_interface "true")
set(enable_ground_truth "false")
set(enable_logging "false")
41
set(enable_camera "false")
42
set(rotors_description_dir "${CMAKE_SOURCE_DIR}/models/rotors_description")
43
set(scripts_dir "${CMAKE_SOURCE_DIR}/scripts")
44
add_custom_target(sdf
45
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
46
	COMMAND rm -f ${CMAKE_SOURCE_DIR}/models/iris/iris.sdf
47
	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} 
48
49
	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
50
51
	)

52
53
54
55
56
link_directories(${GAZEBO_LIBRARY_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/msgs)
add_subdirectory(msgs)

list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")

57
add_library(hello_world SHARED src/hello_world.cc)
58
target_link_libraries(hello_world ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
59

60
add_library(rotors_gazebo_controller_interface SHARED src/gazebo_controller_interface.cpp)
Lorenz Meier's avatar
Lorenz Meier committed
61
target_link_libraries(rotors_gazebo_controller_interface ${GAZEBO_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE} ${PROTOBUF_LIBRARY} mav_msgs)
62
add_dependencies(rotors_gazebo_controller_interface mav_msgs)
63

64
add_library(rotors_gazebo_motor_model SHARED src/gazebo_motor_model.cpp)
65
target_link_libraries(rotors_gazebo_motor_model mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
66
add_dependencies(rotors_gazebo_motor_model mav_msgs)
67

68
add_library(rotors_gazebo_multirotor_base_plugin SHARED src/gazebo_multirotor_base_plugin.cpp)
69
target_link_libraries(rotors_gazebo_multirotor_base_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
70
71
add_dependencies(rotors_gazebo_multirotor_base_plugin mav_msgs)

72
add_library(rotors_gazebo_imu_plugin SHARED src/gazebo_imu_plugin.cpp)
73
target_link_libraries(rotors_gazebo_imu_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
74
add_dependencies(rotors_gazebo_imu_plugin mav_msgs)
75

ChristophTobler's avatar
ChristophTobler committed
76
77
78
79
80
81
82
83
add_library(gazebo_opticalFlow_plugin SHARED src/gazebo_opticalFlow_plugin.cpp)
target_link_libraries(gazebo_opticalFlow_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE} ${OpenCV_LIBS})
add_dependencies(gazebo_opticalFlow_plugin mav_msgs)

add_library(gazebo_lidar_plugin SHARED src/gazebo_lidar_plugin.cpp)
target_link_libraries(gazebo_lidar_plugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
add_dependencies(gazebo_lidar_plugin mav_msgs)

84
add_library(rotors_gazebo_mavlink_interface SHARED src/gazebo_mavlink_interface.cpp src/geo_mag_declination.cpp)
85
target_link_libraries(rotors_gazebo_mavlink_interface mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
86
add_dependencies(rotors_gazebo_mavlink_interface mav_msgs)
87

88
89
90
add_library(LiftDragPlugin SHARED src/liftdrag_plugin/liftdrag_plugin.cpp)
target_link_libraries(LiftDragPlugin mav_msgs ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${SDF_LIBRARIES} ${Boost_SYSTEM_LIBRARY_RELEASE} ${Boost_THREAD_LIBRARY_RELEASE})
add_dependencies(LiftDragPlugin mav_msgs)