diff --git a/.github/local-workflow-tech.md b/.github/local-workflow-tech.md index 352a95685e..3f9b5c2b19 100644 --- a/.github/local-workflow-tech.md +++ b/.github/local-workflow-tech.md @@ -42,3 +42,54 @@ Technicalities underlying the fast-pace local workflow ```console git config --local core.hooksPath .githooks/ ``` + +# 🔘 Use an external robots-configuration separately from `robotology-superbuild` + +In some `ergoCubSN???` setups, the `robots-configuration` used by the robot is not the one downloaded by the `robotology-superbuild` (that would be found at `/usr/local/src/robot/robotology-superbuild/src/robots-configuration`), +but rather a separate `robots-configuration` available at `/usr/local/src/robot/robots-configuration`. This is done for two reasons: +- To permit to clone a fresh new `robotology-superbuild`, without the need to manually perform the local repository configuration as described in the previous section, +- To permit to easily share the used `robots-configuration` to other `robotology-superbuild`, that for example are part of a different environment or a different container. + +The steps necessary to switch to use an external robots-configuration given an existing `robotology-superbuild` setup are the following: + +## 🔲 Disable robots-configuration from the superbuild + +First of all, pass the [`-ROBOTOLOGY_SKIP_ROBOTS_CONFIGURATION:BOOL=ON`](https://github.com/robotology/robotology-superbuild/pull/1775) CMake option to all the `robotology-superbuild` that should use the external `robots-configuration`. + +If the `robotology-superbuild` was already built once, remember to first uninstall and then delete the existing robots-configuration repository to avoid confusion. + +In particular uninstall with: + +```console +cd /usr/local/src/robot/robotology-superbuild/build/src/robots-configuration +make uninstall +``` + +and delete any `robots-configuration` folder with: + +```console +cd /usr/local/src/robot/robotology-superbuild +rm -rf /usr/local/src/robot/robotology-superbuild/src/robots-configuration +rm -rf /usr/local/src/robot/robotology-superbuild/build/src/robots-configuration +``` + +## 🔲 Clone, install and ensure that external robots-configuration is visible + +```console +cd /usr/local/src/robot +git clone https://github.com/robots-configuration/robots-configuration.git +cd robots-configuration +``` + +At this point, follow the configuration steps documented in the earlier section. Then, install the repo without dependencies, using the `nodeps` CMake preset: + +```console +cmake --preset nodeps +cmake --install build +``` + +After you did all of this, to ensure that the installed files are found by YARP, add the following line to the `.bashrc_iCub` of the robot: + +```console +export YARP_DATA_DIRS=$YARP_DATA_DIRS:/usr/local/src/robot/robots-configuration/build/install/share/ICUBcontrib +``` diff --git a/.github/workflows/ci-nodeps.yml b/.github/workflows/ci-nodeps.yml new file mode 100644 index 0000000000..d29178fb1d --- /dev/null +++ b/.github/workflows/ci-nodeps.yml @@ -0,0 +1,30 @@ +name: CI Workflow with nodeps CMake preset + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install deps + run: | + sudo apt-get install -y cmake build-essential + + - name: Configure + run: | + cmake --preset nodeps + + - name: Build + run: | + cmake --build --preset nodeps + + - name: Install + run: | + cd build + cmake --install . diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ce93e95d8..4db6e9acff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,20 +4,40 @@ cmake_minimum_required(VERSION 3.12) project(robots-configuration VERSION 2.7.0) -find_package(YCM REQUIRED) -find_package(YARP REQUIRED) -find_package(ICUBcontrib REQUIRED) - -list(APPEND CMAKE_MODULE_PATH ${ICUBCONTRIB_MODULE_PATH}) -include(ICUBcontribOptions) -include(ICUBcontribHelpers) - +option(BUILD_WITHOUT_DEPENDENCIES "If enabled, permit to install robots-configuration without any dependency on YCM, YARP or ICUBcontrib" OFF) option(INSTALL_ALL_ROBOTS "Enable installation of all robots" OFF) set(ROBOT_NAME "$ENV{YARP_ROBOT_NAME}" CACHE PATH "Name of your robot") set(ROBOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${ROBOT_NAME}") option(BUILD_TESTING "If ON compile tests" OFF) -icubcontrib_set_default_prefix() + +if(NOT BUILD_WITHOUT_DEPENDENCIES) + find_package(YCM REQUIRED) + find_package(YARP REQUIRED) + find_package(ICUBcontrib REQUIRED) + + list(APPEND CMAKE_MODULE_PATH ${ICUBCONTRIB_MODULE_PATH}) + include(ICUBcontribOptions) + include(ICUBcontribHelpers) + icubcontrib_set_default_prefix() +else() + if(BUILD_TESTING) + message(FATAL_ERROR "BUILD_TESTING=ON requires BUILD_WITHOUT_DEPENDENCIES=OFF") + endif() + + # If we do not have dependencies, we just need to define yarp_install as a simple redirect + # to CMake's builtin install + function(yarp_install) + install(${ARGN}) + endfunction() + + # The only use of ICUBContrib beside setting the default install prefix is to + # set ICUBCONTRIB_ROBOTS_INSTALL_DIR + include(GNUInstallDirs) + # CMAKE_INSTALL_DATAROOTDIR is just a fancy (and platform independent) way to refer to share, + # see https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + set(ICUBCONTRIB_ROBOTS_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/ICUBcontrib/robots") +endif() if(UNIX) find_program(BASH_PROGRAM bash) @@ -111,4 +131,6 @@ else() endif() endif() -icubcontrib_add_uninstall_target() +if(NOT BUILD_WITHOUT_DEPENDENCIES) + icubcontrib_add_uninstall_target() +endif() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..00238e7b47 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,38 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 22, + "patch": 1 + }, + "configurePresets": [ + { + "name": "default", + "displayName": "Default Configuration", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "nodeps", + "inherits": "default", + "displayName": "Configuration that does not depend on YARP, ICUBContrib or YCM", + "installDir": "${sourceDir}/build/install", + "cacheVariables": { + "INSTALL_ALL_ROBOTS": "ON", + "BUILD_WITHOUT_DEPENDENCIES": "ON" + } + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + }, + { + "name": "nodeps", + "configurePreset": "nodeps" + } + ] +}