how to automatically collect the created target?

I want to generate myself package using cmake, and a essential code is:

install(TARGETS packageA packgeB ...
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)

The packageA packageB ... indicates the created target. Is there any method to automatically collect these created target? Does I must manually input the targets?

Any suggestion is appreciated~~~

You need to manually list the targets in install commands.

You may try to use GitHub - aminya/project_options: A general-purpose CMake library that makes using CMake easier the package_project() Funktion