adding component to existing namespace/package


Let say I’ve already got a bunch of libraries that can be link into other project by:

find_package(PackageName COMPONENTS Comp1 Comp2...)

How can I make another library project that can be added to PackageName as a new component (without touching existing projects: for instance, I may want to allow third party contributors to add component to an existing package)?

I hope that the question is clear enough,

PackageName’s configuration would have to use the given COMPONENTS names to do the search for you. There’s nothing built-in to allow for this.


I just see a similar question to which you seem to give the opposite answer: Using the same namespace for multiple independant projects - #2 by ben.boeckel
Can you clarify?
Or how can I edit local PackageName’s configuration file to declare the new components (ideally directly from the new library cmake project)?


Not sure I understand where the opposite answer is provided. There’s no rule about NAMESPACE needing to be unique. However, there’s also nothing that makes a single project understand everything that does share a NAMESPACE.

The config file could have something like:

foreach (component IN LISTS other_components)
  find_package("project_${component}" QUIET)
  if (found)
    set(project_${component}_FOUND 1)
  else ()
    set(project_${component}_FOUND 0)
  endif ()
endforeach ()