diff --git a/CMakeLists.txt b/CMakeLists.txt index e8f08e9109..c3ca14e5ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,8 @@ include(AddBipedalLocomotionUnitTest) #Function to automatize the process of creating a new library include(AddBipedalLocomotionLibrary) +include(AddBipedalLocomotionYARPDevice) + #Utility to install ini files include(InstallIniFiles) diff --git a/cmake/AddBipedalLocomotionYARPDevice.cmake b/cmake/AddBipedalLocomotionYARPDevice.cmake new file mode 100644 index 0000000000..c5f53b8082 --- /dev/null +++ b/cmake/AddBipedalLocomotionYARPDevice.cmake @@ -0,0 +1,64 @@ +# Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT). All rights reserved. +# This software may be modified and distributed under the terms of the +# GNU Lesser General Public License v2.1 or any later version. + +function(add_bipedal_yarp_device) + set(options ) + set(oneValueArgs NAME) + set(multiValueArgs + SOURCES + PUBLIC_HEADERS + PRIVATE_HEADERS + PUBLIC_LINK_LIBRARIES + PRIVATE_LINK_LIBRARIES + DEFAULT + TYPE + INI) + + set(prefix "bipedal_yarp") + + cmake_parse_arguments(${prefix} + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) + + set(name ${${prefix}_NAME}) + set(type ${${prefix}_TYPE}) + set(default ${${prefix}_DEFAULT}) + set(ini ${${prefix}_INI}) + set(sources ${${prefix}_SOURCES}) + set(public_headers ${${prefix}_PUBLIC_HEADERS}) + set(public_link_libraries ${${prefix}_PUBLIC_LINK_LIBRARIES}) + + yarp_prepare_plugin(${name} CATEGORY device + TYPE ${type} + INCLUDE ${public_headers} + DEFAULT ${default}) + + yarp_add_plugin(${name} ${sources} ${public_headers}) + + target_link_libraries(${name} PUBLIC ${public_link_libraries}) + target_compile_features(${name} PUBLIC cxx_std_17) + + # Specify include directories for both compilation and installation process. + # The $ generator expression is useful to ensure to create + # relocatable configuration files, see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages + target_include_directories(${name} PUBLIC "$" + "/${CMAKE_INSTALL_INCLUDEDIR}>") + + # Specify installation targets, typology and destination folders. + yarp_install(TARGETS ${name} + COMPONENT runtime + LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR}/ + ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR}/) + yarp_install(FILES ${ini} + COMPONENT runtime + DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR}/) + + add_subdirectory(app) + + + message(STATUS "Created device ${name}.") + +endfunction() diff --git a/devices/FloatingBaseEstimatorDevice/CMakeLists.txt b/devices/FloatingBaseEstimatorDevice/CMakeLists.txt index 283f835351..5c205a9fba 100644 --- a/devices/FloatingBaseEstimatorDevice/CMakeLists.txt +++ b/devices/FloatingBaseEstimatorDevice/CMakeLists.txt @@ -3,45 +3,15 @@ # GNU Lesser General Public License v2.1 or any later version. if(FRAMEWORK_COMPILE_YarpImplementation) - cmake_minimum_required(VERSION 3.5) - set(PLUGIN_NAME FloatingBaseEstimatorDevice) - set(${PLUGIN_NAME}_SRC src/FloatingBaseEstimatorDevice.cpp) - set(${PLUGIN_NAME}_HDR include/BipedalLocomotion/FloatingBaseEstimatorDevice.h) - - yarp_prepare_plugin(${PLUGIN_NAME} CATEGORY device - TYPE BipedalLocomotion::FloatingBaseEstimatorDevice - INCLUDE ${${PLUGIN_NAME}_HDR} - DEFAULT ON) - - yarp_add_plugin(${PLUGIN_NAME} ${${PLUGIN_NAME}_SRC} ${${PLUGIN_NAME}_HDR}) - - target_link_libraries(${PLUGIN_NAME} PUBLIC ${YARP_LIBRARIES} - ${iDynTree_LIBRARIES} - BipedalLocomotion::YarpUtilities - BipedalLocomotion::RobotInterfaceYarpImplementation - BipedalLocomotion::ParametersHandlerYarpImplementation - BipedalLocomotion::FloatingBaseEstimators) - target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_17) - - # Specify include directories for both compilation and installation process. - # The $ generator expression is useful to ensure to create - # relocatable configuration files, see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages - target_include_directories(${PLUGIN_NAME} PUBLIC "$" - "/${CMAKE_INSTALL_INCLUDEDIR}>") - - # Specify installation targets, typology and destination folders. - yarp_install(TARGETS ${PLUGIN_NAME} - COMPONENT runtime - LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR}/ - ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR}/) - yarp_install(FILES FloatingBaseEstimatorDevice.ini - COMPONENT runtime - DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR}/) - - add_subdirectory(app) - - message(STATUS "Created device ${PLUGIN_NAME}.") +add_bipedal_yarp_device( + NAME FloatingBaseEstimatorDevice + TYPE BipedalLocomotion::FloatingBaseEstimatorDevice + SOURCES src/FloatingBaseEstimatorDevice.cpp + PUBLIC_HEADERS include/BipedalLocomotion/FloatingBaseEstimatorDevice.h + PUBLIC_LINK_LIBRARIES ${YARP_LIBRARIES} ${iDynTree_LIBRARIES} BipedalLocomotion::YarpUtilities BipedalLocomotion::RobotInterfaceYarpImplementation BipedalLocomotion::ParametersHandlerYarpImplementation BipedalLocomotion::FloatingBaseEstimators + INI FloatingBaseEstimatorDevice.ini + DEFAULT ON) endif()