[CMake] "another target with the same name exists"

kent williams nkwmailinglists at gmail.com
Tue May 27 11:40:49 EDT 2008


Am I insane, or is CMake?

In a subdirectory of our big ol build tree, CMake is freaking out
about duplicate targets in a way that makes no sense to me:

CMake Error at src/iplProg/AutoSeg/ProcessDescription/CMakeLists.txt:3
(ADD_LIBRARY):
  add_library cannot create target "ProcessDescription" because another
  target with the same name already exists.  The existing target is a static
  library created in source directory
  "/scratch/kent/brains2/src/iplProg/AutoSeg/ProcessDescription".  See
  documentation for policy CMP0002 for more details.

Here is the entirety of the 'offending' CMakeLists.txt:

FILE (GLOB ProcessDescription_SRC *.cxx)

ADD_LIBRARY(ProcessDescription ${ProcessDescription_SRC})

Grepping through all the CMakeLists.txt in our source tree, that is
the only place that library is cited as a target.

Note that 'src/iplProg/AutoSeg/ProcessDescription' is the same
directory as   "/scratch/kent/brains2/src/iplProg/AutoSeg/ProcessDescription"

I read the CMP0002 policy description, and I don't see how it applies
in this particular case.  CMake is acting as though it's incorrectly
detecting a target as having been defined twice in exactly the same
place in the same CMakeLists.txt.


More information about the CMake mailing list