[CMake] Support for multiple targets with the same name

Amitha Perera perera at cs.rpi.edu
Tue Jun 14 16:27:16 EDT 2005


On Tue 14 Jun 2005, Ken Martin wrote about libraries and executables
with the same name:
> if TARGET_LINK_LIBRARIES is called without any of these special
> signatures the default behavior will be [...] if there are more than
> one target with that name [...] default to a library target. The
> same issue will happen with SET_TARGET_PROPERTIES etc.

If there is an ambiguity, I think the correct behaviour is for CMake
to flag an error. The user should needs to explicitly add "EXECUTABLE"
or "LIBRARY", or whatever else needs to be done to disambiguate. This
avoids unexpected link errors because the dependencies were attached
to an unexpected target. This is especially true in large projects
with many small libraries, because the conflicting target may be
elsewhere in the source tree.

Amitha.


More information about the CMake mailing list