By default cpp_cc_build_time_copy (recently added in https://github.com/BlueBrain/hpc-coding-conventions/pull/95) creates a target that is always built that depends on the output file, ensuring that it is already up to date. This potentially generates a large number of top-level always-built targets, which can be rather slow when using legacy make/Makefiles. The Ninja build system does not seem to have the same problem.
This commit adds an optional NO_TARGET flag, which sets up the rule to copy the file but does not create a top-level always-built target. This means that the caller can create a single such target depending on many files, which is much more efficient when using make/Makefiles.
By default
cpp_cc_build_time_copy
(recently added in https://github.com/BlueBrain/hpc-coding-conventions/pull/95) creates a target that is always built that depends on the output file, ensuring that it is already up to date. This potentially generates a large number of top-level always-built targets, which can be rather slow when using legacy make/Makefiles. The Ninja build system does not seem to have the same problem.This commit adds an optional
NO_TARGET
flag, which sets up the rule to copy the file but does not create a top-level always-built target. This means that the caller can create a single such target depending on many files, which is much more efficient when using make/Makefiles.For example this:
creates two top-level rules while
creates just one. When large numbers of files are being copied then this difference can be significant.
Note that if
NO_TARGET
is passed and no dependency is declared on theOUTPUT
file in the sameCMakeLists.txt
the file will not be copied. See, for example, https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory and https://cmake.org/cmake/help/latest/command/add_custom_command.html.