Create a custom target that depends on make test completing

Hello everybody,

This question is pretty easy to understand. I have a large bunch of tests. I want to have a target that runs after all the tests are done.

# If Valgrind is enabled, create output directory and move error script over
if(${USE_VALGRIND_MEMCHECK} OR ${USE_VALGRIND_MEMCHECK_RANDOM})
        file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/valgrind_logs/")
        configure_file(
          "${PROJECT_SOURCE_DIR}/tests/valgrind_wrappers/valgrind_error_report.sh.in"
          "${PROJECT_BINARY_DIR}/valgrind_wrappers/valgrind_error_report.sh"
          )
        add_custom_target(valgrind_memcheck_report
                COMMAND "${PROJECT_BINARY_DIR}/valgrind_wrappers/valgrind_error_report.sh"
                DEPENDS test)
endif()

The custom target doesn’t work:

# make valgrind_memcheck_report
make[2]: *** No rule to make target 'src/CMakeFiles/test.dir/all', needed by 'src/CMakeFiles/valgrind_memcheck_report.dir/all'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:1544: src/CMakeFiles/valgrind_memcheck_report.dir/rule] Error 2
make: *** [Makefile:821: valgrind_memcheck_report] Error 2

Suggestions?

That sounds like this (old) issue.

Thank you. It is indeed the same issue.