How to add addiction to targets

I defined a custom target in cmake. Now I want this target to be created only when the cmake test target was completed. How can i achieve this.

Suppose I have a make coverage target, which should depend on the target make test , which must be called before, or call make test before executing.

How can I define this behavior in cmake?

Here is my code that did not work properly. I want to make coverage depend on what you need to make the call first.

  ADD_CUSTOM_TARGET( coverage COMMAND /bin/bash ${LIBPIPE_BINARY_DIR}/cmake/scripts/coverage.sh DEPENDS test ) 
+4
source share
2 answers

The CMake FAQ states that add_custom_command/add_custom_target that define custom targets have a DEPENDS parameter.

Edit

This will not work for the built-in target test due to the following function request .

But you can always create a custom check target or whatever, as suggested in CMake Help

+2
source

You cannot add the sentence "DEPENDS test". Predefined / built-in goals in CMake (everything, installation, packaging, verification, cleaning) are not available as real goals in the CMakeLists.txt file. Thus, you cannot express dependence on the built-in goal.

This article has a great feature request for tracking CMake errors, but it has not yet been implemented. See http://public.kitware.com/Bug/view.php?id=8438

However, you can change your team for your custom purpose, however, so that it first calls "do a test" and then runs your coverage team.

+7
source

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


All Articles