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]: Unusable for installable projects whose other dependencies also define a check target #1641

Open
ingomueller-net opened this issue Mar 15, 2024 · 4 comments

Comments

@ingomueller-net
Copy link

Describe the issue

I am working on a project that depends on LLVM. LLVM uses installable targets (using CMake's install command), which forces my project to do the same. If I want to use abseil-cpp or any project that depends on it, I thus need to set ABSL_ENABLE_INSTALL=ON.

Furthermore, LLVM also defines a check target in its CMake files. This clashes with the check target of Abseil.

This only happens with ABSL_ENABLE_INSTALL=ON. Otherwise, the target names are prefixed with absl_, see the definition of absl_cc_library.

Steps to reproduce the problem

What version of Abseil are you using?

Any version from about four years ago until today.

What operating system and version are you using?

Any.

What compiler and version are you using?

Any.

What build system are you using?

Any version of CMake older than 2.6.0.

Additional context

Of course, the clash is also due to to LLVM using a non-prefixed target name. However, I'd argue that this doesn't absolve abseil-cpp from being well-behaved and prefix it's target names as an effort to keep them unique no matter what other project it is used with.

@derekmauro
Copy link
Member

Steps to reproduce the problem is not filled in. Please do so.

You also say that this is relevant to any version of CMake older than 2.6.0. I just want to confirm that this is correct as our minimum supported CMake version is 3.13. Does this work still not work with a supported CMake version?

@ingomueller-net
Copy link
Author

Clone this project to abseil-cpp and create CMakeLists.txt with the following content:

add_custom_target(check)
add_subdirectory(abseil-cpp)

Create an empty folder, cd into the folder, and run cmake .. -DABSL_ENABLE_INSTALL=ON, observe the following error:

CMake Error at abseil-cpp/CMake/AbseilHelpers.cmake:317 (add_library):
  add_library cannot create target "check" because another target with the
  same name already exists.  The existing target is a custom target created
  in source directory
  "/.../".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  abseil-cpp/absl/log/CMakeLists.txt:424 (absl_cc_library)

@eliasdaler
Copy link

eliasdaler commented Apr 11, 2024

Stumbled upon a similar problem too, but this time when trying to use crc32c along with abseil.

When ABSL_ENABLE_INSTALL is set to ON, it creates a library named "crc32c" which introduces conflicts.

CMake Error at build/_deps/absl-src/CMake/AbseilHelpers.cmake:251 (add_library):
  add_library cannot create target "crc32c" because another target with the
  same name already exists.  The existing target is a static library created
  in source directory
  "/build/_deps/crc32c-src".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  build/_deps/absl-src/absl/crc/CMakeLists.txt:54 (absl_cc_library)

@anthonyalayo
Copy link

I also encountered this in nghttp2/nghttp2#2204

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

4 participants