Feature: Allow add_subdirectory to exclude specific targets from the build tree
I recently found usage for ALLOW_DUPLICATE_CUSTOM_TARGETS in one of our projects, when two external dependencies both added an uninstall
target to the tree.
A subdirectory with EXCLUDE_FROM_ALL
is correctly excluded from the installation process, but as CMake does not provide a builtin uninstallation method, a make uninstall
is usually implemented as custom target.
While a powerful builtin uninstall method would for sure be the "real" solution, that wouldn't allow including existing external projects without touching them. So, I propose something like:
add_subdirectory(externalLib [EXCLUDE_FROM_ALL] [EXCLUDE_TARGETS <targets>])
I also believe there exist some weird edge cases in the world of software dependencies where this is helpful for other things than uninstall
.