FAQ Database Discussion Community


CMake - How to create executable, but not add to “all” target?

cmake,target,ctest
Using CMake, I have a series of executables that are built, then added as tests, like this: set(TestID 1) add_executable (Test${TestID} Test${TestID}.cpp) # Create test configure_file(${TestID}.endf ${TestID}.endf COPYONLY) add_test( NAME ${TestID} COMMAND Test${TestID} ) This works fine—the executables are created and the tests are correctly added. However, I don't want...

std::cerr doesn't wait for std::cout (when running CTest)

c++,output,io-redirection,ctest
The context I wrote a logger printing messages for the user. Messages with level "debug", "info" or "warning" are printed in std::cout and messages with level "error" or "system_error" are printed in std::cerr. My program is not multi-threaded. I work under Linux openSUSE 12.3 with gcc 4.7.2 and CMake 3.1.0....

Two sets of tests in Cmake

cmake,automated-tests,ctest
I have two sets of tests (functional and unit tests) and I want to be able to specify which set to run through cmake. One set of tests are my unittests that I want to run by doing "make test". Another set of tests are my functional tests that I...

CTest not detecting tests

cmake,make,ctest
I have a project with a structure ├── CMakeLists.txt ├── mzl.c ├── mzl.h └── tests ├── CMakeLists.txt ├── mzl-communication-test.c ├── mzl-setup-test.c ├── mzl-test-errors.c └── mzl-test-errors.h Where the top directory CMakeLists.txt file is project(mzl) cmake_minimum_required(VERSION 2.8) add_subdirectory(tests) # Enable testing for the project enable_testing() # Find zmq find_library(ZMQ_LIB zmq REQUIRED) message(STATUS...

Expected build-failure tests in CMake

c++,cmake,automated-tests,ctest
Sometimes it's good to check that certain things fail to build, e.g.: // Next line should fail to compile: can't convert const iterator to iterator. my_new_container_type::iterator it = my_new_container_type::const_iterator(); Is it possible to incorporate these types of things into CMake/CTest? I'm looking for something like this in CMakeLists.txt: add_build_failure_executable( test_iterator_conversion_build_failure...

CMake and CTest: automatically run test's dependencies

c++,c,testing,cmake,ctest
In my CMakeLists.txt I have something like this: set_property(TEST testX APPEND PROPERTY DEPENDS testY) set_property(TEST testX APPEND PROPERTY DEPENDS testZ) And I want some way to run testX and all its dependencies automatically. Something like: ctest <options> testX and as a result, CTest will run textY, testZ and testX. Is...

Valgrind changes working directory with CTest in KDevelop

c++,cmake,valgrind,ctest
I am starting a test with Helgrind using Ctest: find_program(VALGRIND_EXECUTABLE valgrind) message(STATUS "Valgrind in ${VALGRIND_EXECUTABLE}") configure_file(project.supp project.supp) set(BOOST_TEST_ARGS --catch_system_errors=no) set(VALGRIND_HELGRIND_OPTIONS --tool=helgrind --suppressions=${CMAKE_CURRENT_BINARY_DIR}/project.supp --xml=yes --read-var-info=yes) add_test(NAME TestHelgrind COMMAND ${VALGRIND_EXECUTABLE} ${VALGRIND_HELGRIND_OPTIONS} --xml-file=${CMAKE_CURRENT_BINARY_DIR}/test.xml...