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

clang-format target conflicts with other libraries #39

Open
BHare1985 opened this issue Mar 30, 2024 · 1 comment
Open

clang-format target conflicts with other libraries #39

BHare1985 opened this issue Mar 30, 2024 · 1 comment

Comments

@BHare1985
Copy link

BHare1985 commented Mar 30, 2024

Would you consider allowing for OPTIONS/ENV that allows for a custom target for old libraries that happen to use the same build target?

I tried various CMake settings to avoid this but nothing seems to work. See CMP0002 using cmake_policy(SET CMP0002 OLD) and or set(ALLOW_DUPLICATE_CUSTOM_TARGETS TRUE) didn't work and there are many warnings not to do that.

I don't really want to fork either project just to fix this so I am hoping that because this project is specifically about adding clang-formating and the basis for many cpp projects with ModernCppStarter.

It's worth noting that that I don't have python installed so it's hitting

add_custom_target(clang-format ${CLANG_FORMAT_NOT_FOUND_COMMAND_ARGS})

The full error:

CMake Error at cmake-build-debug/_deps/format.cmake-src/CMakeLists.txt:42 (add_custom_target):
  add_custom_target cannot create target "clang-format" because another
  target with the same name already exists.  The existing target is a custom
  target created in source directory
  "C:/mosiac/all/cmake-build-debug/_deps/libzmq-src".
  See documentation for policy CMP0002 for more details.

The CPM I am adding is

CPMAddPackage(
        NAME libzmq
        GIT_TAG v4.3.5
        GITHUB_REPOSITORY zeromq/libzmq
        OPTIONS
            "BUILD_SHARED OFF"
)

Their target can be found in this file:
https://github.com/zeromq/libzmq/blob/2a75ef07be0ba76f86592e10b999331cd6124d52/builds/cmake/Modules/ClangFormat.cmake#L18

@TheLartians
Copy link
Owner

Sure, I can see how an option like CLANG_FORMAT_TARGET_NAME could be useful here. I'll be happy to review a PR that adds this option!

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

2 participants