Disable testing in cmake

The project tests that I'm trying to build cannot be built (missing libraries). The tests themselves are not important, but they prevent me from creating and installing the necessary files. Therefore, I want to do it as a quick fix.

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

There is one issue of the ENABLE_TESTING () command. I tried to comment on this, but it did not help. Also tried renaming subdirectory tests. Did not help. This was true only for a special case when "implicit" tests were built.

+3
source share
1 answer

Well, it worked by editing CMakeLists.txt to disable all the BUILD_TESTING, BUILD_TESTING_STATIC and BUILD_TESTING_SHARED flags.

This is easiest to do with the sed command:

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

(In one case, there were "implicit" tests that needed to be taken care of in more detail).

+3
source

Source: https://habr.com/ru/post/1715121/


All Articles