cmake - CTest not detecting tests -


i have project 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 top directory cmakelists.txt file

project(mzl) cmake_minimum_required(version 2.8)  add_subdirectory(tests)  # enable testing project enable_testing()  # find zmq find_library(zmq_lib zmq required) message(status "zmq library: ${zmq_lib}")  # find threading library set(cmake_thread_prefer_pthread on) find_package(threads required) message(status "threading library: ${cmake_thread_libs_init}")    # set include directories headers set     (     mzl_include_dirs     ${cmake_source_dir}     cache string "mzl include directories"     ) include_directories(${mzl_include_dirs})  # set source files set     (     mzl_src_files     mzl.c     )  # add library add_library(${project_name} static ${mzl_src_files})  # link zmq target_link_libraries(${project_name} ${zmq_lib} ${cmake_thread_libs_init}) 

and tests/cmakelists.txt

# use mzl source directories (mzl headers in top directory) include_directories(${cmake_source_dir})  # variable here empty message(status "mzl include directories: ${mzl_include_dirs}")  # files common tests set ( test_common_sources     mzl-test-errors.c     )  # library setup/shutdown testing set(setup_test_name mzl-setup-test) add_executable(${setup_test_name} ${test_common_sources} ${setup_test_name}.c) target_link_libraries(${setup_test_name} ${project_name} ${zmq_lib}) add_test(${setup_test_name} ${setup_test_name})  # communcations test set(communication_test_name mzl-communication-test) add_executable(${communication_test_name} ${test_common_sources}     ${communication_test_name}.c) target_link_libraries(${communication_test_name} ${project_name}         ${cmake_thread_libs_init} ${zmq_lib}) add_test(${communication_test_name}  ${communication_test_name}) 

everything worked fine before added second test mzl-communication-test. after adding , lines in tests/cmakelists.txt after # communications test, running ctest did nothing -- still ran first test.

after deleting build directory , running cmake again, no errors initial cmake run, running make runs cmake again, resulting in error cmake:

cmake error: parse error in cache file build/cmakecache.txt. offending entry: include 

followed make error:

makefile:203: recipe target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] error 1 

running make again results in being built, including tests; however, running ctest results in

test project build no tests found!!! 

the issue seems doing cmake, can't figure out here can't see i'm doing differently when working. last commit git, working when committed it, no longer working.

you need move enable_testing() call before add_subdirectory(tests)

# enable testing project enable_testing()  add_subdirectory(tests) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -