Is include_guard
still expected to only work for include
and not add_subdirectory
(see https://gitlab.kitware.com/cmake/cmake/-/issues/17895 )?
We have a setup where modules add_subdirectory
their direct dependencies, which often means that we get diamond inclusions (A adds B & C which both add D). We were originally protecting against this via if( NOT target ) return() endif()
, but include_guard(GLOBAL)
appeared to do this without adding extra boilerplate.
Nothing in the include_guard
documentation explicitly makes a distinction between inclusion via include
vs add_subdirectory
.