I'm building my project with CMake, and I'm trying to create a bunch of test suites for each module. Apparently if I modify the variable CMAKE_RUNTIME_OUTPUT_DIRECTORY
then ctest cannot find the test to run and fails.
I've made a minimal example to showcase what I am talking about, and I'm running it with CMake 2.8.11.2 on Lubuntu 13.10. I'd appreciate if somebody could tell me whether this is a bug and/or how to work around it. Thanks.
file CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (Test)
# Put all tests in the test directory, where the sources also are
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/test)
enable_testing()
add_subdirectory (${PROJECT_SOURCE_DIR}/test)
file test/CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
add_executable(ttest main.cpp)
add_test(ttest ttest)
file test/main.cpp:
int main() {
return 0;
}
After building in a new folder build
, the executable is correctly created in the folder test
. Running make test
from build results in the following output:
Running tests...
Test project /home/svalorzen/Tests/cmake/build
Start 1: ttest
Could not find executable ttest
Looked in the following places:
ttest
ttest
Release/ttest
Release/ttest
Debug/ttest
Debug/ttest
MinSizeRel/ttest
MinSizeRel/ttest
RelWithDebInfo/ttest
RelWithDebInfo/ttest
Deployment/ttest
Deployment/ttest
Development/ttest
Development/ttest
Unable to find executable: ttest
1/1 Test #1: ttest ............................***Not Run 0.00 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.00 sec
The following tests FAILED:
1 - ttest (Not Run)
Errors while running CTest
make: *** [test] Error 8