With CMake I try to execute a simple test using CTest. I have this configuration all in one directory (${CMAKE_SOURCE_DIR}):
~$ cat hello.cpp
#include <iostream>
int main() {
std::cout << "hello world\n";
return(0);
}
~$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.18)
project(TEST_CTEST)
enable_testing()
add_executable(test_ctest hello.cpp)
add_test(my_test ./build/test_ctest)
Then I execute:
~$ rm -rf Testing/ build/
~$ cmake -S . -B build
~$ cmake --build build
~$ ./build/test_ctest
hello world
~$ ctest
*********************************
No test configuration file found!
*********************************
Usage
ctest [options]
The only hint I have found in other Q&A is to place enable_testing()
into the root CMakeLists.txt
. I feel like I just missed a little thing, but I can't find what.
How do I run a test with CTest?
ctest
from build directory. Exactly this directory contains configuration file whichctest
wants to read. – Anarchy