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 is the top directory CMakeLists.txt
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 "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 for 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 to zmq target_link_libraries(${PROJECT_NAME} ${ZMQ_LIB} ${CMAKE_THREAD_LIBS_INIT})
and tests/CMakeLists.txt is
# Use MZL Source Directories (mzl headers are in top directory) include_directories(${CMAKE_SOURCE_DIR})
Everything worked fine before adding the second mzl-communication-test . After adding it and the lines to tests/CMakeLists.txt after the # Communications test running ctest did nothing - it still ran only the first test.
After deleting the build directory and starting cmake again, I get no errors for starting CMake initially, but running make starts CMake again, resulting in an error with CMake:
CMake Error: Parse error in cache file build/CMakeCache.txt. Offending entry: include
followed by a make error:
Makefile:203: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1
Running make again leads to the creation of everything, including tests; however running ctest results in
Test project build No tests were found!!!
The problem seems to be related to something that I am doing with CMake, but I canβt figure out what to do next, because I donβt see anything that I do other than when it originally worked. Even my last fix on git, which worked when I did it, no longer works.