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

[BUG] CMake error when using PyBind11 and range-v3 as submodules #2420

Closed
est77 opened this issue Aug 21, 2020 · 2 comments · Fixed by #2423
Closed

[BUG] CMake error when using PyBind11 and range-v3 as submodules #2420

est77 opened this issue Aug 21, 2020 · 2 comments · Fixed by #2423

Comments

@est77
Copy link

est77 commented Aug 21, 2020

The PR that introduced this error is #2370

add_library cannot create target "headers" because another target with the
same name already exists. The existing target is a custom target created
in source directory "extern/range-v3". See
documentation for policy CMP0002 for more details.

Would it be possible to rename the target to something less generic to avoid this issue?
(I opened another issue in range-v3 repo).

Thanks.

@est77 est77 changed the title [BUG] CMake error when using PyBind11 an range-v3 as submodules [BUG] CMake error when using PyBind11 and range-v3 as submodules Aug 21, 2020
@henryiii
Copy link
Collaborator

I was a little worried about making that "headers" due to this issue. I have an idea, actually...

@henryiii
Copy link
Collaborator

The only non-imported target is headers, so working around this is pretty easy. Here's the idea:

Rename headers to pybind11_headers. For add_directory, have an alias pybind11::headers. For config mode, also alias pybind11::pybind11_headers to pybind11::headers.

The other alternative would be to name it something different if this is a subdirectory, but that can be troublesome.

henryiii added a commit to henryiii/pybind11 that referenced this issue Aug 21, 2020
henryiii added a commit to henryiii/pybind11 that referenced this issue Aug 21, 2020
henryiii added a commit to henryiii/pybind11 that referenced this issue Aug 21, 2020
henryiii added a commit to henryiii/pybind11 that referenced this issue Aug 21, 2020
henryiii added a commit that referenced this issue Aug 22, 2020
* fix: reduce target collision in add_submodule mode

Closes #2420

* fix: update CMakeLists.txt
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

Successfully merging a pull request may close this issue.

2 participants