Skip to content

clang-format target conflicts with other libraries #39

@BHare1985

Description

@BHare1985

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions