From 438ae25a5748f2ee9a2277d364a6bd418c1f9134 Mon Sep 17 00:00:00 2001 From: Eulalie Coevoet Date: Mon, 8 Jan 2024 13:22:51 +0100 Subject: [PATCH] [tests] auto-disables tests if SOFA_BUILD_TESTS is OFF --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a22657e6..3e880a1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \ -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \ - -DSOFTROBOTS_BUILD_TESTS=True " + " if [ -e "$(command -v ccache)" ]; then cmake_options="$cmake_options -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 4847effe..a12327c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,8 +297,11 @@ sofa_create_package_with_targets( install(DIRECTORY docs DESTINATION .) install(FILES "README.md" "LICENSE" "CHANGELOG" DESTINATION .) -option(SOFTROBOTS_BUILD_TESTS "Build unit tests" ON) +# Tests +# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled +cmake_dependent_option(SOFTROBOTS_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF) if(SOFTROBOTS_BUILD_TESTS) + enable_testing() add_subdirectory(tests) endif()