Skip to content

Commit

Permalink
[cmake] add AddBipedalYARPDevice cmake macro
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanthr05 committed Nov 13, 2020
1 parent 2b370c9 commit ebe68e4
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 38 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
64 changes: 64 additions & 0 deletions cmake/AddBipedalLocomotionYARPDevice.cmake
Original file line number Diff line number Diff line change
@@ -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 $<INSTALL_PREFIX> 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 "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"<INSTALLINTERFACE:<INSTALL_PREFIX>/${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()
46 changes: 8 additions & 38 deletions devices/FloatingBaseEstimatorDevice/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<INSTALL_PREFIX> 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 "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"<INSTALLINTERFACE:<INSTALL_PREFIX>/${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()

0 comments on commit ebe68e4

Please sign in to comment.