Skip to content

Commit

Permalink
Add BUILD_WITHOUT_DEPENDENCIES CMake option and nodeps CMake preset (#…
Browse files Browse the repository at this point in the history
…697)

Co-authored-by: Stefano Dafarra <[email protected]>
  • Loading branch information
traversaro and S-Dafarra authored Dec 17, 2024
1 parent 6b22848 commit 8f3974f
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 10 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci-nodeps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI Workflow with nodeps CMake preset

on:
push:
pull_request:
workflow_dispatch:
schedule:

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 ./build
42 changes: 32 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -111,4 +131,6 @@ else()
endif()
endif()

icubcontrib_add_uninstall_target()
if(NOT BUILD_WITHOUT_DEPENDENCIES)
icubcontrib_add_uninstall_target()
endif()
38 changes: 38 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 8f3974f

Please sign in to comment.