Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable testing in cmake

Tags:

testing

cmake

The tests of a project that I try to build fail to build (missing libraries). The tests themselves are not important, but prevents me from building and installing the essential files. So I want to do this as a quick-fix.

How do I do to turn of the build of the tests in a cmake project? Should I edit the CMakeLists.txt file in the root or in the subdirectory tests? How should I edit it?

There are one issuing of the command ENABLE_TESTING(). I tried to comment that one out, but it didn't help. Also tried to rename the subdirectory tests. Did not help either. This was only true for a special case where "implicit" tests were being built.

like image 603
dala Avatar asked Aug 13 '09 21:08

dala


People also ask

Does CMake facilitate unit tests?

¶ CMake facilitates testing your software through special testing commands and the CTest executable. First, we will discuss the key testing commands in CMake. To add testing to a CMake-based project, simply include(CTest) and use the add_test command.

What is CMake CTest?

The ctest executable is the CMake test driver program. CMake-generated build trees created for projects that use the enable_testing() and add_test() commands have testing support. This program will run the tests and report results.

What is Enable_testing in CMake?

enable_testing() Enables testing for this directory and below. This command should be in the source directory root because ctest expects to find a test file in the build directory root. This command is automatically invoked when the CTest module is included, except if the BUILD_TESTING option is turned off.

Is CTest part of CMake?

CTest is the part of CMake that handles testing your code. CTest allows for an easy way to run your newly built programs with various argument and option settings, and then check the results against expected output.


1 Answers

Ok, it worked by editing the CMakeLists.txt to turn off all the flags BUILD_TESTING, BUILD_TESTING_STATIC and BUILD_TESTING_SHARED.

This can most easily be accomplished with this sed command:

sed --in-place=.BACKUP 's/\(BUILD_TESTING[A-Z_]*\) ON/\1 OFF/' CMakeLists.txt

(In one cases there were "implicit" tests that had to be taken care of in a more elaborate way.)

like image 198
dala Avatar answered Sep 22 '22 06:09

dala