[llvm-dev] add_library cannot create target "LLVMTarget" because an imported target with the same name already exists.
Chris Bieneman via llvm-dev
llvm-dev at lists.llvm.org
Mon Nov 28 14:30:36 PST 2016
Passes are not treated the same in the build system as how we treat runtime libraries. A pass can either be in-tree, or out-of-tree, but not both.
If the pass is a loadable module you might be able to hack around that by naming the library that contains the pass differently for in-tree and out-of-tree builds.
One thing to keep in mind about how CMake works is that it creates dummy targets for all the LLVM build targets when you import the LLVM package. That means if you built your pass in the LLVM tree, its target will be exported in the CMake, so you can't create the same target in a separate CMake file.
> On Nov 28, 2016, at 2:26 PM, Simone Atzeni <simone.at at gmail.com> wrote:
> Hi Chris,
> sorry I was just using a dummy name for the library but that wasn’t the name that was giving me the error.
> However, what I am experiencing is that if I build and install my pass within the LLVM source I cannot install my library if I build it out-of-tree as a standalone library.
> The OpenMP runtime allows that though, any solution?
>> On Nov 28, 2016, at 15:22, Chris Bieneman <beanz at apple.com> wrote:
>> Hi Simone,
>> Sorry for the delayed response.
>> LLVMTarget is a library provided by LLVM, you shouldn't be naming your own targets to conflict with the names already in LLVM. CMake does not allow multiple targets to have the same name because it causes ambiguities in the build system.
>>> On Nov 20, 2016, at 2:00 PM, Simone Atzeni via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>> I am trying to make my pass compiling inside the LLVM tree or outside.
>>> It works when I include my pass inside the tools folder, however when I try to compile it outside the LLVM tree I get the following error:
>>> "add_library cannot create target "LLVMTarget" because an imported target with the same name already exists.”
>>> It happens when I’ve already compiled and installed my target from within LLVM.
>>> I was wondering if there is a way to ignore that and just overwrite the target.
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
More information about the llvm-dev