I added tests to my project but ctest says "No tests were found!!!"

project build and produces all files I expect (bin, hex, elf)
but when I run:

\> ctest CMakeLists.txt
Test project D:/projects/mazelbot/libs/lib_utils/test
No tests were found!!!

here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

include_guard(GLOBAL)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(C_STANDARD 18)
set(CXX_STANDARD 17)

if (NOT DEFINED STM32_CHIP)
    set(STM32_CHIP "stm32h7xx")
endif ()

if (NOT DEFINED STM32_CORE)
    set(STM32_CORE "cm7")
endif ()

add_definitions(
    -DHSE_VALUE=8000000
    -DUSE_FULL_LL_DRIVER
)

include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/stm32.cmake)

project("tutils_${STM32_CHIP}_${STM32_CORE}" C CXX ASM)

set(SOURCES
    ./test_is_inside_valid_buffer_memory.cpp
    ./test_ring_buffer.cpp
    ./test_ring_buffer_busy_flag_in_data.cpp
)

if (STM32_CORE MATCHES "cm4")
    set(SOURCES_BOOT
        ${CMAKE_CURRENT_LIST_DIR}/../../lib_stm32/startup/system_stm32h7xx_dualcore_bootcm4_cm7gated.c
    )
else ()
    set(SOURCES_BOOT
        ${CMAKE_CURRENT_LIST_DIR}/../../lib_stm32/startup/system_stm32h7xx_dualcore_bootcm7_cm4gated.c
    )
endif ()

add_executable(${PROJECT_NAME}
    ${CMAKE_CURRENT_LIST_DIR}/../../lib_stm32/startup/startup_stm32h745xx.s
    ${SOURCES}
    ${SOURCES_BOOT}
)

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../lib_stm32 lib_${STM32_CHIP}_${STM32_CORE})
target_link_libraries(${PROJECT_NAME} lib_${STM32_CHIP}_${STM32_CORE})

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../lib_test_cpp lib_test_cpp_${STM32_CHIP}_${STM32_CORE})
target_link_libraries(${PROJECT_NAME} lib_test_cpp_${STM32_CHIP}_${STM32_CORE})

set_target_linker(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../lib_stm32/ld/stm32h745xx_flash_${STM32_CORE_UPPER}.ld)

source_group("src-test" FILES ${SOURCES})

post_build(${PROJECT_NAME})

include(CTest)
enable_testing()
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

ctest doesn’t look at CMakeLists.txt files. DId you mean to use something like cmake /path/to/where/CMakeLists.txt/lives?

1 Like

yeh, I was thinking ctest will run tests based on CMakeLists.txt.

if I run it inside ${CMAKE_INSTALL_PREFIX} directory where output files are located then it works fine

lol.