Skip to content

Commit

Permalink
Add C++ examples to main build
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Feb 15, 2021
1 parent 98f9e37 commit 8dbd67f
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 68 deletions.
18 changes: 1 addition & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,11 @@ install:
before_script:
- mkdir -p "$TRAVIS_BUILD_DIR/build" && cd "$_"
- cmake .. -DCMAKE_INSTALL_PREFIX="$PWD/install" -DENABLE_coverage:BOOL=ON
- cmake .. -DCMAKE_INSTALL_PREFIX="$PWD/install" -DENABLE_coverage:BOOL=ON -DENABLE_examples:BOOL=ON
- make install

- export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
- export YARP_DATA_DIRS=$PWD/install/share/roboticslab-yarp-devices:$YARP_DATA_DIRS
- export CMAKE_PREFIX_PATH="$PWD/install/lib/cmake/ROBOTICSLAB_YARP_DEVICES:$CMAKE_PREFIX_PATH"

- mkdir -p "$TRAVIS_BUILD_DIR/build/exampleJr3" && cd "$_"
- cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleJr3" && make

- mkdir -p "$TRAVIS_BUILD_DIR/build/examplePositionDirect" && cd "$_"
- cmake "$TRAVIS_BUILD_DIR/examples/cpp/examplePositionDirect" && make

- mkdir -p "$TRAVIS_BUILD_DIR/build/exampleRemoteControlboard" && cd "$_"
- cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleRemoteControlboard" && make

- mkdir -p "$TRAVIS_BUILD_DIR/build/exampleRemoteControlboardModule" && cd "$_"
- cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleRemoteControlboardModule" && make

- mkdir -p "$TRAVIS_BUILD_DIR/build/exampleRemoteJr3" && cd "$_"
- cmake "$TRAVIS_BUILD_DIR/examples/cpp/exampleRemoteJr3" && make

script:
- cd "$TRAVIS_BUILD_DIR/build/tests" && ctest -V
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ add_subdirectory(programs)
add_subdirectory(tests)
add_subdirectory(share)
add_subdirectory(doc)
add_subdirectory(examples/cpp)

# Store the package in the user registry.
set(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
Expand Down
9 changes: 9 additions & 0 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
option(ENABLE_examples "Enable/disable C++ examples" OFF)

if(ENABLE_examples)
add_subdirectory(exampleJr3)
add_subdirectory(examplePositionDirect)
add_subdirectory(exampleRemoteControlboard)
add_subdirectory(exampleRemoteControlboardModule)
add_subdirectory(exampleRemoteJr3)
endif()
9 changes: 3 additions & 6 deletions examples/cpp/exampleJr3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(exampleJr3 LANGUAGES CXX)

find_package(YARP 3.2 REQUIRED COMPONENTS os dev sig)
if(NOT YARP_FOUND)
find_package(YARP 3.3 REQUIRED COMPONENTS os dev sig)
endif()

add_executable(exampleJr3 exampleJr3.cpp)

target_link_libraries(exampleJr3 YARP::YARP_os
YARP::YARP_init
YARP::YARP_dev
YARP::YARP_sig)

include(GNUInstallDirs)

install(TARGETS exampleJr3
DESTINATION ${CMAKE_INSTALL_BINDIR})
5 changes: 4 additions & 1 deletion examples/cpp/examplePositionDirect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(examplePositionDirect LANGUAGES CXX)

if(NOT YARP_FOUND)
find_package(YARP 3.3 REQUIRED COMPONENTS os dev)
endif()

find_package(COLOR_DEBUG REQUIRED)
find_package(YARP 3.2 REQUIRED COMPONENTS os dev)

add_executable(examplePositionDirect examplePositionDirect.cpp)

Expand Down
4 changes: 3 additions & 1 deletion examples/cpp/exampleRemoteControlboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(exampleRemoteControlboard LANGUAGES CXX)

find_package(YARP 3.2 REQUIRED COMPONENTS os dev)
if(NOT YARP_FOUND)
find_package(YARP 3.3 REQUIRED COMPONENTS os dev)
endif()

add_executable(exampleRemoteControlboard exampleRemoteControlboard.cpp)

Expand Down
23 changes: 10 additions & 13 deletions examples/cpp/exampleRemoteControlboardModule/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(exampleRemoteControlboard LANGUAGES CXX)
project(exampleRemoteControlboardModule LANGUAGES CXX)

find_package(YARP 3.2 REQUIRED COMPONENTS os dev)
if(NOT YARP_FOUND)
find_package(YARP 3.3 REQUIRED COMPONENTS os dev)
endif()

add_executable(exampleRemoteControlboard main.cpp
ExampleRemoteControlboard.cpp
ExampleRemoteControlboard.hpp)
add_executable(exampleRemoteControlboardModule main.cpp
ExampleRemoteControlboard.cpp
ExampleRemoteControlboard.hpp)

target_link_libraries(exampleRemoteControlboard YARP::YARP_os
YARP::YARP_init
YARP::YARP_dev)

include(GNUInstallDirs)

install(TARGETS exampleRemoteControlboard
DESTINATION ${CMAKE_INSTALL_BINDIR})
target_link_libraries(exampleRemoteControlboardModule YARP::YARP_os
YARP::YARP_init
YARP::YARP_dev)
9 changes: 3 additions & 6 deletions examples/cpp/exampleRemoteJr3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(exampleRemoteJr3 LANGUAGES CXX)

find_package(YARP 3.2 REQUIRED COMPONENTS os dev sig)
if(NOT YARP_FOUND)
find_package(YARP 3.3 REQUIRED COMPONENTS os dev sig)
endif()

add_executable(exampleRemoteJr3 exampleRemoteJr3.cpp)

target_link_libraries(exampleRemoteJr3 YARP::YARP_os
YARP::YARP_init
YARP::YARP_dev
YARP::YARP_sig)

include(GNUInstallDirs)

install(TARGETS exampleRemoteJr3
DESTINATION ${CMAKE_INSTALL_BINDIR})
2 changes: 2 additions & 0 deletions libraries/CanBusSharerLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ if(ENABLE_CanBusSharerLib)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_library(ROBOTICSLAB::CanBusSharerLib ALIAS CanBusSharerLib)

else()

set(ENABLE_CanBusSharerLib OFF CACHE BOOL "Enable/disable CanBusSharerLib library" FORCE)
Expand Down
6 changes: 4 additions & 2 deletions libraries/CanOpenNodeLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ if(ENABLE_CanOpenNodeLib)
"USE_NONSTD_OPTIONAL;optional_CONFIG_NO_EXCEPTIONS=1")
endif()

target_link_libraries(CanOpenNodeLib PUBLIC CanBusSharerLib
StateObserverLib
target_link_libraries(CanOpenNodeLib PUBLIC ROBOTICSLAB::CanBusSharerLib
ROBOTICSLAB::StateObserverLib
PRIVATE ROBOTICSLAB::ColorDebug)

target_include_directories(CanOpenNodeLib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand All @@ -50,6 +50,8 @@ if(ENABLE_CanOpenNodeLib)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_library(ROBOTICSLAB::CanOpenNodeLib ALIAS CanOpenNodeLib)

else()

set(ENABLE_CanOpenNodeLib OFF CACHE BOOL "Enable/disable CanOpenNodeLib library" FORCE)
Expand Down
2 changes: 2 additions & 0 deletions libraries/DextraRawControlboardLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if(ENABLE_DextraRawControlboardLib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

add_library(ROBOTICSLAB::DextraRawControlboardLib ALIAS DextraRawControlboardLib)

else()

set(ENABLE_DextraRawControlboardLib OFF CACHE BOOL "Enable/disable DextraRawControlboardLib library" FORCE)
Expand Down
2 changes: 2 additions & 0 deletions libraries/StateObserverLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ if(ENABLE_StateObserverLib)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_library(ROBOTICSLAB::StateObserverLib ALIAS StateObserverLib)

else()

set(ENABLE_StateObserverLib OFF CACHE BOOL "Enable/disable StateObserverLib library" FORCE)
Expand Down
2 changes: 2 additions & 0 deletions libraries/YarpDeviceMapperLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ if(ENABLE_YarpDeviceMapperLib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

add_library(ROBOTICSLAB::YarpDeviceMapperLib ALIAS YarpDeviceMapperLib)

else()

set(ENABLE_YarpDeviceMapperLib OFF CACHE BOOL "Enable/disable YarpDeviceMapperLib library" FORCE)
Expand Down
2 changes: 2 additions & 0 deletions libraries/YarpPlugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ install(FILES IProximitySensors.h
install(TARGETS YarpDevicesInterfaces
EXPORT ROBOTICSLAB_YARP_DEVICES)

add_library(ROBOTICSLAB::YarpDevicesInterfaces ALIAS YarpDevicesInterfaces)

# YARP devices.
add_subdirectory(AmorControlboard)
add_subdirectory(AravisGigE)
Expand Down
6 changes: 3 additions & 3 deletions libraries/YarpPlugins/CanBusControlboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ if(NOT SKIP_CanBusControlboard)
target_link_libraries(CanBusControlboard YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug
CanBusSharerLib
CanOpenNodeLib
YarpDeviceMapperLib)
ROBOTICSLAB::CanBusSharerLib
ROBOTICSLAB::CanOpenNodeLib
ROBOTICSLAB::YarpDeviceMapperLib)

target_compile_features(CanBusControlboard PRIVATE cxx_std_14)

Expand Down
4 changes: 2 additions & 2 deletions libraries/YarpPlugins/CuiAbsolute/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if(NOT SKIP_CuiAbsolute)
target_link_libraries(CuiAbsolute YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug
CanBusSharerLib
StateObserverLib)
ROBOTICSLAB::CanBusSharerLib
ROBOTICSLAB::StateObserverLib)

target_compile_features(CuiAbsolute PRIVATE cxx_std_11)

Expand Down
4 changes: 2 additions & 2 deletions libraries/YarpPlugins/DextraCanControlboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ if(NOT SKIP_DextraCanControlboard)
ICanBusSharerImpl.cpp
CanSynapse.cpp)

target_link_libraries(DextraCanControlboard DextraRawControlboardLib
target_link_libraries(DextraCanControlboard ROBOTICSLAB::DextraRawControlboardLib
YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug
CanBusSharerLib)
ROBOTICSLAB::CanBusSharerLib)

target_compile_features(DextraCanControlboard PRIVATE cxx_std_11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if(NOT SKIP_DextraSerialControlboard)
DeviceDriverImpl.cpp
SerialSynapse.cpp)

target_link_libraries(DextraSerialControlboard DextraRawControlboardLib
target_link_libraries(DextraSerialControlboard ROBOTICSLAB::DextraRawControlboardLib
YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug)
Expand Down
2 changes: 1 addition & 1 deletion libraries/YarpPlugins/FakeJoint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(NOT SKIP_FakeJoint)
FakeJoint.cpp)

target_link_libraries(FakeJoint YARP::YARP_dev
CanBusSharerLib)
ROBOTICSLAB::CanBusSharerLib)

target_compile_features(FakeJoint PUBLIC cxx_std_11)

Expand Down
2 changes: 1 addition & 1 deletion libraries/YarpPlugins/LacqueyFetch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(NOT SKIP_LacqueyFetch)
target_link_libraries(LacqueyFetch YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug
CanBusSharerLib)
ROBOTICSLAB::CanBusSharerLib)

target_compile_features(LacqueyFetch PUBLIC cxx_std_11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(NOT SKIP_ProximitySensorsClient)
target_link_libraries(ProximitySensorsClient YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug
YarpDevicesInterfaces)
ROBOTICSLAB::YarpDevicesInterfaces)

yarp_install(TARGETS ProximitySensorsClient
LIBRARY DESTINATION ${ROBOTICSLAB-YARP-DEVICES_DYNAMIC_PLUGINS_INSTALL_DIR}
Expand Down
6 changes: 3 additions & 3 deletions libraries/YarpPlugins/TechnosoftIpos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ if(NOT SKIP_TechnosoftIpos)
target_link_libraries(TechnosoftIpos YARP::YARP_os
YARP::YARP_dev
ROBOTICSLAB::ColorDebug
CanBusSharerLib
StateObserverLib
CanOpenNodeLib)
ROBOTICSLAB::CanBusSharerLib
ROBOTICSLAB::StateObserverLib
ROBOTICSLAB::CanOpenNodeLib)

target_compile_features(TechnosoftIpos PUBLIC cxx_std_14)

Expand Down
16 changes: 8 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ if(ENABLE_tests)

# testCanBusSharerLib

if(TARGET CanBusSharerLib)
if(ENABLE_CanBusSharerLib)
add_executable(testCanBusSharerLib testCanBusSharerLib.cpp)
target_link_libraries(testCanBusSharerLib CanBusSharerLib gtest_main)
target_link_libraries(testCanBusSharerLib ROBOTICSLAB::CanBusSharerLib gtest_main)
gtest_discover_tests(testCanBusSharerLib)
endif()

# testStateObserverLib

if(TARGET StateObserverLib)
if(ENABLE_StateObserverLib)
add_executable(testStateObserverLib testStateObserverLib.cpp)
target_link_libraries(testStateObserverLib StateObserverLib FutureObserverLib gtest_main)
target_link_libraries(testStateObserverLib ROBOTICSLAB::StateObserverLib FutureObserverLib gtest_main)
gtest_discover_tests(testStateObserverLib)
endif()

# testCanOpenNodeLib

if(TARGET CanOpenNodeLib)
if(ENABLE_CanOpenNodeLib)
add_executable(testCanOpenNodeLib testCanOpenNodeLib.cpp)
target_link_libraries(testCanOpenNodeLib CanOpenNodeLib FutureObserverLib gtest_main)
target_link_libraries(testCanOpenNodeLib ROBOTICSLAB::CanOpenNodeLib FutureObserverLib gtest_main)
target_compile_features(testCanOpenNodeLib PUBLIC cxx_std_14)
gtest_discover_tests(testCanOpenNodeLib)
endif()

# testYarpDeviceMapperLib

if(TARGET YarpDeviceMapperLib)
if(ENABLE_YarpDeviceMapperLib)
add_executable(testYarpDeviceMapperLib testYarpDeviceMapperLib.cpp)
target_link_libraries(testYarpDeviceMapperLib YarpDeviceMapperLib YARP::YARP_dev gtest_main)
target_link_libraries(testYarpDeviceMapperLib ROBOTICSLAB::YarpDeviceMapperLib YARP::YARP_dev gtest_main)
target_compile_features(testYarpDeviceMapperLib PUBLIC cxx_std_14)
gtest_discover_tests(testYarpDeviceMapperLib)
endif()
Expand Down

0 comments on commit 8dbd67f

Please sign in to comment.