Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BUILD_WITHOUT_DEPENDENCIES CMake option and nodeps CMake preset #697

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
]
}
Loading