range-v3
range-v3 copied to clipboard
Import target cmake error when using range-v3 as dependency
I've installed range-v3 via apt-get install on Ubuntu 20.04 and run into the following error when I try to build a project with colcon that has multiple dependencies that depend on range-v3:
CMake Error at /usr/lib/cmake/range-v3/range-v3-config.cmake:2 (add_library):
add_library cannot create imported target "range-v3::meta" because another
target with the same name already exists.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
CMake Error at /usr/lib/cmake/range-v3/range-v3-config.cmake:3 (add_library):
add_library cannot create imported target "range-v3::concepts" because
another target with the same name already exists.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
CMake Error at /usr/lib/cmake/range-v3/range-v3-config.cmake:4 (add_library):
add_library cannot create imported target "range-v3::range-v3" because
another target with the same name already exists.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/sebastian/min_range_v3_error/build/CMakeFiles/CMakeOutput.log".
After investigating the error a bit, I figured out that colcon uses a custom CMake macro that calls find_package(range-v3 REQUIRED)
multiple times in the same context. From my understanding, this should not cause any problems, so I am wondering if the error is somewhere within range-v3's CMake files.
You can reproduce the error on Ubuntu 20.04 after installing sudo apt-get install librange-v3-dev
and try to build the minimal example you find attached (min_range_v3_error.zip) with
cd min_range_v3_error
mkdir build
cd build
cmake ..
In the CMakeLists.txt file, I call find_package twice which causes the error
find_package(range-v3 REQUIRED)
find_package(range-v3 REQUIRED)
Do you think this is a small bug on the range-v3 side or are we including range-v3 incorrect as a dependency? Thanks in advance for your help!
This shouldn't happen after https://github.com/ericniebler/range-v3/commit/4abf6d6149c6c845d3ff84b395a37de01b104372.
It seems like this commit is not part of any released version, or am I mistaken? The Debian release in focal is 0.10.0 and on jamming 0.11.0. Are there any plans to create a new release in the future that includes this fix?