My top-level CMake project depends on some-library
, which I include into my project using
add_subdirectory (some-library)
and then link against it using
target_link_libraries (my-project PRIVATE some-library)
I also want to add install (TARGETS my-rpoject ...)
directives so that my project can be installed to the system via whatever build system is generated (e.g. via sudo ninja install
if using the -GNinja
generator).
However, if some-library
also defines some install (TARGETS some-library ...)
directives, they get lumped in with the installation of my project's targets, which given a few subdirectory dependencies creates a bunch of extra, needless cruft in the system's installation directories which I'd like to avoid.
How can I get CMake to exclude any install (...)
targets from submodules/dependency projects added with add_subdirectory ()
and keep only the ones in my top-level project?