Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use if also using CPMAddPackage for LLVM dependency and building Clang #31

Open
christopherbate opened this issue Feb 10, 2022 · 2 comments

Comments

@christopherbate
Copy link

If a project uses CPM to pull in LLVM and builds the clang project of LLVM, then the target names clang-format and check-clang-format will conflict. Locally I fixed this by adding run- prefixes to each target.

@TheLartians
Copy link
Owner

TheLartians commented Feb 20, 2022

Ah that makes sense, I hadn't considered the LLVM project when I created the target names. To not break existing workflows, perhaps it would make sense to add an option CMAKE_FORMAT_PREFIX that adds a prefix to the target names to avoid such collisions?

Thanks for raising the issue!

@TheophileBlard
Copy link

I have the same issue, triggered by find_package(Clang)

CMake Error at /usr/lib/llvm-10/lib/cmake/clang/ClangTargets.cmake:37 (message):
Some (but not all) targets in this export set were already defined.
Targets Defined: clang-format

My current fix is to add CPMAddPackage("gh:TheLartians/Format.cmake@1.7.3") at the end of my CMakeLists.txt, after the find_package(Clang) statement. Adding a CMAKE_FORMAT_PREFIX option would work, but I believe you should ultimately change the default name of the target (such name collision can happen really easily).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants