Creating a PackageConfig for a comlicated package with components

I am trying to use a CMake based set of libraries or framework that does not provide a PackageConfig or Find file. Because it has multiple libraries and executables, i would like to create a single PackageConfig that can be used for all the various targets.

All the examples I have seen so far just have one file and a single call to configure_package_config_file.
I assume you can only call configure_package_config_file once unless your output file is the infile.

But the design of CMake is to put the install in each target’s CMakeList.txt

How do I cleanly create all the export info and update the final ConfigFile ?

Do I create a ConfigFile for each target then somehow roll them into one in the top level CMake ?

Any good examples?

I want to be able to add to the prefix then do something like

find(GraphicsEngine 2.5.2 COMPONENTS core tools appframework REQUIRED imgui OPTIONAL)

I am going to answer my own question, in part.
The config file is designed to be opened repeatably and have multiple exported targets added to it.
I will play some more and see how Components fit into the picture.

There are a few ways to do components. Qt’s way uses components to find subpackages (e.g., find_package(Qt5 COMPONENTS Core) does a find_package(Qt5Core) under the hood). There’s also VTK’s way though that is likely more complicated than most projects need. I think Qt’s way where you make a CMake package per component and then dispatch might be the preferred way to go here.