From 392b02b64e3b9c840b9429a881db7a418af9fbe1 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 23 Sep 2024 16:41:53 +0200 Subject: [PATCH] Add USE_SYSTEM_tiny-process-library CMake option to use tiny-process-library found in system (#891) --- CHANGELOG.md | 1 + devices/YarpRobotLoggerDevice/CMakeLists.txt | 43 +++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59a287b34a..49d3a8fc8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project are documented in this file. ## [unreleased] ### Added +- Add `USE_SYSTEM_tiny-process-library` CMake option to use `tiny-process-library` found in system (https://github.com/ami-iit/bipedal-locomotion-framework/pull/891) ### Changed diff --git a/devices/YarpRobotLoggerDevice/CMakeLists.txt b/devices/YarpRobotLoggerDevice/CMakeLists.txt index 38844d6a23..6f05fd5074 100644 --- a/devices/YarpRobotLoggerDevice/CMakeLists.txt +++ b/devices/YarpRobotLoggerDevice/CMakeLists.txt @@ -3,35 +3,38 @@ # BSD-3-Clause license. if(FRAMEWORK_COMPILE_YarpRobotLoggerDevice) - # Warning: the option of yarp_configure_plugins_installation should be different from the plugin name - + option(USE_SYSTEM_tiny-process-library "Use system tiny-process-library" OFF) - include(FetchContent) - FetchContent_Declare(tiny_process_library - GIT_REPOSITORY https://gitlab.com/eidheim/tiny-process-library.git - GIT_TAG v2.0.4) + if(USE_SYSTEM_tiny-process-library) + find_package(tiny-process-library REQUIRED) + else() + include(FetchContent) + FetchContent_Declare(tiny_process_library + GIT_REPOSITORY https://gitlab.com/eidheim/tiny-process-library.git + GIT_TAG v2.0.4) - if(NOT tiny_process_library_POPULATED) - FetchContent_Populate(tiny_process_library) + if(NOT tiny_process_library_POPULATED) + FetchContent_Populate(tiny_process_library) - set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) - set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build libraries as shared as opposed to static") + set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build libraries as shared as opposed to static") - set(BUILD_TESTING_OLD ${BUILD_TESTING}) - set(BUILD_TESTING OFF CACHE INTERNAL "Create tests using CMake") + set(BUILD_TESTING_OLD ${BUILD_TESTING}) + set(BUILD_TESTING OFF CACHE INTERNAL "Create tests using CMake") - # Bring the populated content into the build - add_subdirectory(${tiny_process_library_SOURCE_DIR} ${tiny_process_library_BINARY_DIR}) + # Bring the populated content into the build + add_subdirectory(${tiny_process_library_SOURCE_DIR} ${tiny_process_library_BINARY_DIR}) - # Restore the old value of the parameter - set(BUILD_TESTING ${BUILD_TESTING_OLD} CACHE BOOL - "Create tests using CMake" FORCE) + # Restore the old value of the parameter + set(BUILD_TESTING ${BUILD_TESTING_OLD} CACHE BOOL + "Create tests using CMake" FORCE) - set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE BOOL - "Build libraries as shared as opposed to static" FORCE) + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE BOOL + "Build libraries as shared as opposed to static" FORCE) + endif() endif() - + # Warning: the option of yarp_configure_plugins_installation should be different from the plugin name add_bipedal_yarp_device( NAME YarpRobotLoggerDevice TYPE BipedalLocomotion::YarpRobotLoggerDevice