[cmake-developers] Targets with same name in different projects

Tobias Hunger tobias.hunger at gmail.com
Thu Mar 30 07:13:14 EDT 2017


Hello,

I found a project recently which looks odd in the Qt Creator project
tree. Looking into it I found that this project has several projects
defined and two of those define the same target (same SOURCE file,
same name, etc.). It seems like both projects somehow include the same
CMakeLists.txt file defining that target (have not yet checked for the
specifics).

So I was wondering: Is this even allowed? The CMake manual says target
names must be unique within a project. I had always read that as
"unique within one build system", but now I am confused:-) Maybe this
is actually about PROJECTs defined in CMakeLists.txt files?

If different PROJECTs may have targets with the same name: How do I
call cmake to build one of those targets via the command line
interface but not the other?

Best Regards,
Tobias


More information about the cmake-developers mailing list