cmake_minimum_required(VERSION 3.0) project(plugins) find_package(gazebo REQUIRED) # Work around broken CMake exports pulled in transitively via Gazebo -> DART. # DART was packaged with empty include prefixes, so several of its imported # targets (Boost::system/filesystem/regex, ...) carry a bogus "/include" path # in INTERFACE_INCLUDE_DIRECTORIES. CMake validates these while walking the # link closure and aborts the generate step with: # Imported target "dart" includes non-existent path "/include". # Recurse through the whole GAZEBO_LIBRARIES link closure and drop any include # directory that does not exist on disk. function(_strip_bad_includes _target) if(NOT TARGET ${_target}) return() endif() get_property(_seen GLOBAL PROPERTY "_sbi_seen_${_target}") if(_seen) return() endif() set_property(GLOBAL PROPERTY "_sbi_seen_${_target}" 1) get_target_property(_inc ${_target} INTERFACE_INCLUDE_DIRECTORIES) if(_inc) set(_ok "") foreach(_p IN LISTS _inc) if(EXISTS "${_p}") list(APPEND _ok "${_p}") endif() endforeach() set_target_properties(${_target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_ok}") endif() get_target_property(_deps ${_target} INTERFACE_LINK_LIBRARIES) if(_deps) foreach(_d IN LISTS _deps) if(TARGET ${_d}) _strip_bad_includes(${_d}) endif() endforeach() endif() endfunction() foreach(_root IN LISTS GAZEBO_LIBRARIES) if(TARGET ${_root}) _strip_bad_includes(${_root}) endif() endforeach() # The same empty-prefix bug leaves a stray "/include" in GAZEBO_INCLUDE_DIRS; # drop non-existent entries so the compiler isn't handed bogus -I flags. set(_gz_inc_ok "") foreach(_p IN LISTS GAZEBO_INCLUDE_DIRS) if(EXISTS "${_p}") list(APPEND _gz_inc_ok "${_p}") endif() endforeach() set(GAZEBO_INCLUDE_DIRS "${_gz_inc_ok}") # Gazebo headers require C++14, and bring in their own compile flags. set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}") include_directories(${GAZEBO_INCLUDE_DIRS}) link_directories(${GAZEBO_LIBRARY_DIRS}) add_library(SimpleDronePlugin SHARED SimpleDronePlugin.cc) # GAZEBO_LIBRARIES already pulls in the sensors + rendering + transport libs # needed for reading camera frames. target_link_libraries(SimpleDronePlugin ${GAZEBO_LIBRARIES})