cmake,make,ctest , CTest not detecting tests


CTest not detecting tests

Question:

Tag: 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 "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})

# Variable from here is empty
message(STATUS "MZL Include Directories: ${MZL_INCLUDE_DIRS}")

# Files common to all 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 I added the second test mzl-communication-test. After adding it and the lines in the tests/CMakeLists.txt after # Communications test, running ctest did nothing extra -- it still only ran the first test.

After deleting the build directory and running cmake again, I get no errors for the initial CMake run, but running make runs 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 results in everything being built, including the tests; however, running ctest results in

Test project build
No tests were found!!!

The issue seems to be with something that I am doing with CMake, but can't figure out what to do from here as I can't see anything that I'm doing differently than when it was originally working. Even my last commit to git, which was working when I committed it, is no longer working.


Answer:

You need to move the enable_tests() call to be before you do add_subdirectory(tests)

# Enable testing for the project
enable_testing()

add_subdirectory(tests)

Related:


How to correctly make install of binaries and data after compile in linux?


linux,make,install
After make of sources I have compiled executable file and data directory with images for it. What should I do at "make install" phase to correctly install these files to the linux system? And how then application can find installed data (in case when binary and data are placed in...

make: *** No rule to make target 'rm', needed by 'clean.Stop


c++,makefile,make
I am working with cygwin on windows 8.1. I have used the following make file .SUFFIXES : .o .C CFLAGS = -g2 CC =g++ ${CFLAGS} LIBRARIES = -lm .C.o : ${CC} -c $< SOURCE-FILES = sparsegraph.C myvarious.C pairlist.C graphlist.C peo.graph.C choldc.C copy.C metropolis_fns.C likelihood.C metropolis.C OBJECT-FILES = sparsegraph.o myvarious.o pairlist.o...

Add LLVM to project using cmake


c++,cmake,llvm,llvm-c++-api,llvm-3.0
I'm trying to add LLVM to a cmake project, using cygwin as a compiler. I downloaded LLVM from cygwin's installer (just installed all of the llvm related packages). The files are there, however I cannot include LLVM in my project. I tried using the official guide for 3.5.2 (the version...

A make rule for verbosity


makefile,make
Typically we have this in a Makefile %.o:%.c $(cc) $(flags) -o [email protected] -c $< When the amount of flags is huge, I feel better to write this instead %.o:%.c $(info $(cc): $< --> [email protected]) @$(cc) $(flags) -o [email protected] -c $< However it can be useful to sometime see everything. So...

Why does CMake FILE(READ) ignore commas in my file?


cmake
I have a css file (which I want to parse and adapt for Qt, but that's not the problem). Let's say this one: QLineEdit:hover:not(focus), QWidget QPlainTextEdit:not(hover):not(focus) { border-color: #5575b0; } I made a CMake script to replace not(...) by !... : that part of the script works correctly. The problem...

Cmake and Qt5 linking error


c++,qt,cmake,qt5
I'm trying to build a Qt5 project with Cmake in order to add some new librairies. The cmake goes well but I have a linking issue when building : Linking CXX executable bin/qGo CMakeFiles/qGo.dir/src/main.cpp.o: dans la fonction « main »: main.cpp:(.text+0x102b): undefined reference to « qInitResources_application() » collect2: error: ld...

Building vtk with QT5 windows 8


windows,cmake,qt5,vtk
I'm facing a rather weird error. I can see on the wiki that we can build vtk with support for qt5. However, when trying to do so and first configuring with cmake I get the following output: CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindQt4.cmake:1326 (message): Found unsuitable Qt version "5.4.2" from...

Autodependency generation in makefiles


makefile,make,gnu-make,makefile-project,multiple-makefiles
I am trying to understand how autodependency is generated in makefiles in the given link, i cannot understand the following piece of code: DEPDIR = .deps df = $(DEPDIR)/$(*F) SRCS = foo.c bar.c ... %.o : %.c @$(MAKEDEPEND); \ cp $(df).d $(df).P; \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e...

Cmake errors: The CXX Compiler identification is unknown, The C compiler identification is unknown


c++,opencv,cmake,arm,cmake-gui
I'm trying to install OpenCV on Fedora 21 with a cross compiler for ARM processor. However, when i try to configure using Cmake 3.03, it gives the error: *The CXX compiler identification is unknown The C compiler identification is unknown Check for working CXX compiler: /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++ Check for working CXX...

Nested For loop in makefile


shell,makefile,make
I am trying to loop through the .c files in a specific directory through the makefile. i used the following code, but it seems not working: DIR= Sources \ Sources_2 @for entry in ${DIR} ; \ do \ @for i in $${entry}/*.c ; \ do \ echo "Processing $${i}"; \...

Makefile overriding default implicit rule


c++,c,makefile,make
Why this rule cannot override the default implicit rule ? When make is invoked like: make myapp (suppose myapp.c is there). The make runs the default command to build and link the program instead the commands defined in this implicit rule: #... omitted code LCUS=$(LIBS)/libcus.a #... omitted code % :...

Eclipse Makefile: Make Variables are skipped


eclipse,makefile,make
I have a project with a Makefile in it, on Unix console it works fine, compiles, builds and I can run the binary at the end. I imported the project into Eclipse workspace and somehow Makefile module of Eclipse cannot build the project now. It gives the following error: g++:...

Haskell make recipe fails for Paradox theorem prover using GHC


linux,haskell,make,ghc,theorem-proving
I am trying to install the paradox theorem prover sourced from here. When I run the makefile this is the command that runs: ghc -optl -static -lstdc++ -I../instantiate -I../minisat/current-base ../minisat/current-base/Solver.or ../minisat/current-base/Prop.or ../instantiate/MiniSatWrapper.or ../instantiate/MiniSatInstantiateClause.or -fglasgow-exts -O2 -static -threaded -main-is Paradox.Main.main --make Paradox.Main -o paradox And it results in several errors like...

Linker error while building from source code


c++,cmake,linuxmint
I am trying to build an application from source. I am able to configure it using 'cmake .'. However, when I run 'make' it gives me this: Linking CXX executable ../../bin/lux64/Release/od_batch_launcher ../../bin/lux64/Release/libBasic.so: undefined reference to `dlopen' ../../bin/lux64/Release/libBasic.so: undefined reference to `dlclose' ../../bin/lux64/Release/libBasic.so: undefined reference to `dlerror' ../../bin/lux64/Release/libBasic.so: undefined reference to...

Dot in front of variables in make files


makefile,make,gnu-make
I am not able to figure out what does a dot . in front of a variable in makefile does. For e.g.: SOURCEDIRS = . $(PROJECTDIRS) $(TARGET_DIRS_CONCAT) vpath %.c $(SOURCEDIRS) It would be great if someone could tell me. Thanks!...

Avr-g++ compilation failed with Make Error 1


eclipse,arduino,make,avr,avr-gcc
I'm trying to compile arduino code in Eclipse. Below is build log. make all Building file: ../test.cpp Starting C++ compile "/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=163 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I"/opt/arduino-1.6.3/hardware/arduino/avr/cores/arduino" -I"/opt/arduino-1.6.3/hardware/arduino/avr/variants/standard" -I/usr/lib/avr/include -MMD -MP -MF"test.cpp.d" -MT"test.cpp.d" -D__IN_ECLIPSE__=1 -x c++ "../test.cpp" -o...

What's the difference between [email protected] and $1 when there is only one parameter?


makefile,make
There are some C code: apple.c #include<stdio.h> int main(void) { printf("apple\n"); return 0; } Makefile apple: gcc -c [email protected] gcc [email protected] -o [email protected] $ make apple and it works perfectly. But if I modify Makefile as: apple: gcc -c $1.c gcc $1.o -o $1 $ make apple It does not...

What does the following makefile command do? /no-symbols-control-file


makefile,make,gnu-make,binaryfiles,contiki
I cam across the following command in a makefile: %-nosyms.$(TARGET).elf: %.co $(PROJECT_OBJECTFILES) $(INTERRUPT_OBJECTFILES) contiki-$(TARGET).a $(CC) $(CFLAGS) -o [email protected] $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) $(LDFLAGS) Source: Contiki/cpu/arm/stm32f103/Makefile.stm32f103 . Does this command generate no-symbols-control-file? What is the use of a no symbol image file?...

basic makefile ifeq how to


makefile,make,gnu-make
I am just learning about Makefiles and am having trouble with ifeq. Version = GNU Make 3.82 Here is my simple Makefile: CHECK := 0 CHECK2 := 0 check : @echo "Check=${CHECK}" @echo "Check2=${CHECK2}" ifeq (${CHECK2},${CHECK}) @echo "EQUAL" else @echo "NOT EQUAL" endif Here is the output: Check=0 Check2=0 NOT...

How to install shared library and include files manually in linux?


linux,opencv,cmake,raspberry-pi
I am trying to build and install TBB library from source so that it can be used for OpenCV to take advantages of multiple cores on my raspberry pi. I was able to build TBB from source without any problems using this steps. (Source : How do I build OpenCV...

Error : Cmake can't generate openCV


opencv,cmake,codeblocks
I am trying to instal opencv C++ with codeBlocks in Windows 8 by following this http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/ but I am blocked in step 4.when I try to generate Cmake I have this Error : CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not...

How to change the name of the output binary to not be a.out with CMake?


cmake
Where would I go within CMakeLists.txt in order to change the name of the generated file?

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...

Why does gcc search header files from non-exist folders?


c,linux,gcc,compiler-errors,make
I am trying to build an open source project shark on CentOS 7, and get very weird build errors: make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h', needed by `core/luv/luv.o'. make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h', needed by `core/luv/luv.o'. make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed/limits.h', needed...

CMake to find path to a file which its name contains a certain string


cmake
So I am writing a CMake module to find some libraries which is being used a lot in our company. These libraries all have different versions and are such a mess here. In a certain library, even the name of header files and binary files don't match. So I am...

what does -wl, --start-group mean in make file?


make
I have this in my Make file.. # Create list of object files # LIB_OBJS = -Wl,--start-group \ $(T_OBJ_DIR)/Source1.o \ $(T_OBJ_DIR)/Source2.o \ $(T_OBJ_DIR)/Source3.o \ $(T_OBJ_DIR)/Source4.o \ $(T_OBJ_DIR)/Source5.o \ -Wl,--end-group \ Could anyone please explain What "-Wl,--start-group" and "-Wl,--end-group" mean?...

Can Make be made to understand that a/../z and b/../z are the same location?


makefile,make,gnu-make
I have a somewhat large and complex Makefile setup that postprocesses some data files. Overall it work quite well, but I have run into an annoying issue where Make builds the same target many times over under different directory names. As a simple example, consider the Makefile foo : 1/foo...

Reuse jquery plugin without conflict


javascript,jquery,plugins,make,conflict
I have a little plugin working as a progressbar. the problem is: I can't update progressbar's value because every change I made, affect just the last object created =( also.. if I call it as: $(node-selector).progBar().setValue() it works calling the correct node but it loss the config object follow the...

xcode 6.3.2 external build


c++,xcode,makefile,make
I'm trying to compile an existing c++ project, originally developed on linux with gcc. The only external library is GSL (GNU Scientific Library). I have created an external build tool project to use xcode's debugger, but I currently have two issues. 1) When I try to build in xcode it...

c++: Undefined reference to ERROR


c++,cmake,ros,cpd
I want to add new c++ library of cpd (https://github.com/gadomski/cpd) to one project in ROS. I have already successfully installed the cpd library in my Ubuntu OS. Now I want to use it under ROS environment. In the CMakeList.txt file, I already added the line of find_package(CPD REQUIRED) include_directories(include ${catkin_INCLUDE_DIRS}...

How can I configure CMake generated Eclipse project's Build Command and Project Paths?


cmake,eclipse-cdt
Our project uses CMake to configure our code. We use Ninja along with a distributed build system. A number of people on our team use Eclipse CDT. We run CMake with the "Eclipse CDT4 - Ninja" generator and the result is generally pretty good. The issues is that any time...

CMake link shared library


cmake
I am trying to link shared library using cmake. The library is located at known location /home/username/lib. I have added find_library to CMakeLists.txt to find the library. By running ccmake I verified that the library was correctly localized. But when I generate makefile and call make I get error: /user/bin/ld:...

Having issues with using libraries and CMake


c++,cmake
C:\Program Files (x86)\JetBrains\CLion 1.0.1\bin\cmake\bin\cmake.exe" --build C:\Users\Anthony\.clion10\system\cmake\generated\d04e461a\d04e461a\Debug --target all -- -j 8 -- Configuring incomplete, errors occurred! CMake Error at CMakeLists.txt:19 (add_library): See also "C:/Users/Anthony/.clion10/system/cmake/generated/d04e461a/d04e461a/Debug/CMakeFiles/CMakeOutput.log". add_library cannot create target "Majick" because another target with the same name already exists. The existing target is an executable created in source directory...

Cannot link Boost to CMake-based project on VS2015 RC


c++,visual-studio,visual-c++,boost,cmake
It gives the error: LINK : fatal error LNK1104: cannot open file 'boost_unit_test_framework-vc140-mt-gd-1_58.lib' [C:\projects\boost-http\build\algorithm.vcxproj] You can see the full error at AppVeyor. The build script (CMakeLists.txt and how cmake is invoked) can be found on the project repository. I've tried a lot, but nothing seems to help. Documentation doesn't help...

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...

Unable to build GLFW with CMake errors


c,cmake,glfw
I downloaded the latest GLFW source (3.1.1) from its site, uncompressed it to the desktop, and tried to build it with cmake. Some dependency errors popped up, but was quickly fixed. Until I got stuck on this one: [email protected]:~/Desktop/glfw-3.1.1$ cmake . -- The C compiler identification is Clang 3.6.0 --...

What does $(@:.h=.h.d) mean in GNU make?


make
I'm maintaining a (horrendously complicated) Makefile, and in some recipes I saw the following: $(@:.h=.h.d) I have absolutely no clue as to how to interpret this, or whether there's any documentation on those characters. Obviously, Google won't work because it thinks I'm typing gibberish. I saw a related question about...

Two different CMake difinitions


cmake
With CMake when some definitions are defined they are defined in this way: add_definitions(-DMY_DEFINITION) Sometimes I see people make the definitions in a different way: add_definitions(-DMY_DEFINITION=1) Then my question is what's the difference between them in the generated C++ project. Thanks. ...

Link target to libraries


makefile,cmake,mingw,cmake-gui
I have a "CMakified" version of CryptoPP and I am using CMake-GUI to create a MakeFile which ming-make could process as shown in the image below. The "MakeFile" creation was successful but when I executed mingw32-make.exe I got below errors at the very end. Linking CXX executable cryptest.exe CMakeFiles\cryptest.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x8e82): undefined...

makefile read reused variable inside recipe


makefile,make
In trying to implement nonrecursive make, I have a Rules.mk which looks like: ############ # Enter Stack ############ sp := $(sp).x dirstack_$(sp) := $(d) d := $(dir) .. setup things like OBJECTS_$(d), DEPS_$(d), TARGET_$(d), etc ... ############ # Exit Stack ############ -include $(DEPS_$(d)) d := $(dirstack_$(sp)) sp := $(basename $(sp))...

how to make sure that cmake codes will run after subdirs


c++,cmake
Just give a small example to illustrate my problem: project(Test) set(TestLibName mytest) subdirs(src) # will generate mytest.dll dynamic library set_property(TARGET ${TestLibName} PROPERTY FOLDER "test") In this small script, I want to generate the dynamic library with the CMakeLists.txt file in src foler, and after that I will set the library's...

How to deal with libraries like Boost when cross compiling for arm?


ubuntu,cmake,g++,cross-compiling,beagleboneblack
I'd like to cross compile from my AMD64 desktop to ARM7 for Beagleboard Black. So I started with this to get the cross compilers installed: sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf I also created a cmake toolchain file: set (CMAKE_SYSTEM_NAME Linux) set (CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set (CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) When I run cmake,...

How do I list the defined make targets from the command line?


cmake
I feel almost silly for asking this but I couldn't find anything on this... Suppose I have a cmake project containing a number of targets: libraries, executables, external targets, ... . How do I list them using the cmake command line interface. I want a list of things that are...

How to build a './configure && make && make install' software against a custom library which I also build?


linux,make,gnu,ld,configure
I am building tmux-2.0 from sources on a pretty regular Linux host. First attempt failed as it turned out that the version of libevent installed is older than required, so I proceeded to download and build libevent-2.0.22 from sources (current at the time of writing) first. Building of libevent succeeded...

make error during building webkitgtk


linux,makefile,cmake,make
I use UBuntu 14.04 LTS. I need to build webkitgtk 2.8.3 Here is an example instruction which I have used: linuxfromscratch When I run sudo make -j8 I get following log: Scanning dependencies of target JavaScriptCore-4-gir Scanning dependencies of target fake-generated-webkitdom-headers [ 0%] Scanning dependencies of target WebKit2-fake-api-headers Scanning dependencies...

Cannot link to sublibrary/internal library/embedded library with CMake's Visual Studio generator


c++,visual-studio,visual-c++,cmake
The full error is available at AppVeyor. I create a library using CMake's add_library command, but when I try to compile another target to this library, I get silly errors like LINK : fatal error LNK1104: cannot open file '..\Debug\boost_http.lib' [C:\projects\boost-http\build\test\algorithm.vcxproj]. Other CMake generators do fine. How to properly handle...

How does MAKE remember the file timestamps


c,make
I've found this question which is basically asking the same, but got no real answer. Where is the make's config file / database file where it remembers the file timestamps, so it can tell what changed? I checked and there's no .make or similar in my project, nor in the...

CMake simple MVC structure


c++,model-view-controller,cmake
I have a simple question about how to organize my simple MVC application in C++. I'm new to CMake and I'm just learning how to use it. Imagine a simple folder organization like the following: -Can someone please tell me if this structure is correct? -If so what is the...

Protobuf cannot be linked on ubuntu


c++,ubuntu,linker,cmake,protocol-buffers
I try to use protobuf but somehow the linking fails (here just snippet): Linking CXX executable app CMakeFiles/app.dir/msg.pb.cc.o: In function `evoswarm::protobuf_AssignDesc_a_5fto_5fb_2eproto()': msg.pb.cc:(.text+0x133): undefined reference to `google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(google::protobuf::Descriptor const*, google::protobuf::Message const*, int const*, int, int, int, int, int, int)' msg.pb.cc:(.text+0x190): undefined reference to...