Access export target name list variables

RE: @ClausKlein :

I do not understand your intention or the reason?

The cmake does write correct list of targets into myprojectTargets.cmake file. This file is autogenerated so it is not possible to make modification to this file and remove unset lines: unset(_targetsDefined) unset(_targetsNotDefined) unset(_expectedTargets)
Therefore the variables I need to use in myprojectConfig.cmake/myprojectConfig.cmake.in are not accessible. This is the question I posted, on how to get such access or more generally get the list of targets (_targetsDefined, etc listed in foreach () statement ) useable in myprojectConfig.cmake/myprojectConfig.cmake.in without tracking every target that is added in myriads of sub-projects of a project. cmake gets the list in the foreach(_expectedTarget … target1 target2…targetn) statement and potentially there could be a property or variable this list is obtained from (I checked cmake cache and did not find one).
The reason why to use such list(s) is as the following: print custom warning message to the user about each target imported, warn them that certain targets are imported and they should not import them directly, check versions and address conflicts if they arise with custom warning text rather than frequently meaningless cmake own error/warning.
Thanks for the example, but the cxx.simplelog/CMakeLists.txt shows statements that trigger cmake to create …Targets.cmake file but do not address this question

1 Like