From aa503c599dbdfeba4e7003f176d5c69062155f06 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 9 Oct 2024 11:23:55 -0500 Subject: [PATCH] Call enable_testing() in top-level project Per CMake documentation, this should be called in the top-level CMakeLists.txt so that testing is enabled for the _project_, and not a subdirectory thereof. This will allow tools like colcon to discover the tests. --- .github/workflows/cmake-multi-platform.yml | 2 +- .github/workflows/cmake-ubuntu.yml | 2 +- CMakeLists.txt | 1 + test/CMakeLists.txt | 2 -- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 135b36e4..1a0f6aa6 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -93,7 +93,7 @@ jobs: - name: Test working-directory: ${{ steps.strings.outputs.build-output-dir }} run: | - ctest --build-config ${{ matrix.build_type }} --no-tests=error --output-on-failure --verbose --test-dir test/ + ctest --build-config ${{ matrix.build_type }} --no-tests=error --output-on-failure --verbose - name: Test Python Module Import working-directory: ${{ steps.strings.outputs.build-output-dir }} diff --git a/.github/workflows/cmake-ubuntu.yml b/.github/workflows/cmake-ubuntu.yml index ea97d0b3..15d8a545 100644 --- a/.github/workflows/cmake-ubuntu.yml +++ b/.github/workflows/cmake-ubuntu.yml @@ -57,6 +57,6 @@ jobs: run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target install - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }}/test + working-directory: ${{ steps.strings.outputs.build-output-dir }} run: | ctest --no-tests=error --output-on-failure --verbose diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a6bc1e7..20e1dcad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,5 +215,6 @@ if (BUILD_EXAMPLES) endif() if(BUILD_TESTING) + enable_testing() add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 433aae39..021911ae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,3 @@ -enable_testing() - add_library(getline OBJECT getline.c) add_executable(test_detection test_detection.c)