[cmake-developers] Setting target properties before the target is defined ?
Brad King
brad.king at kitware.com
Sun Feb 17 09:52:05 EST 2013
On 2/15/2013 5:54 PM, Alexander Neundorf wrote:
> The thing is, if I generate an error at configure time if at the end of a
> directory a target has been used but has not been defined, i.e. a target Foo
> has been imported which links against a missing imported target, it would
> still be possible that the project can build successfully if this bad imported
> target Foo is simply not used, e.g. because Foo_FOUND is set to FALSE.
Just to make sure I understand correctly, you're bringing up a use case
where an imported target's dependencies are not satisfied but it does
not matter when the imported target is not used by the project?
> How about that: when in the exported and then imported Target.cmake a used
> target is not yet defined, this target name is added to a cmake variable.
> When then cmake calculates the linking, and it can't find a target, it checks
> whether the name is contained in this cmake variable.
> If so, it errors out instead of assuming it is the name of a library.
Yes, the variable would simply be collecting names that, in the scope
of its directory, are expected to be target names. It may be better
to use a directory property and then have the generate-time check
look in the current directory and up. That will avoid problems with
scoping of the variable if the project loads the file from inside
a function scope.
Are you planning to cover this in the ConfigFileTargetChecks topics?
-Brad
More information about the cmake-developers
mailing list