duplicate JsonCpp::JsonCpp leads to build failures
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libjsoncpp (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Fix Committed
|
Undecided
|
dann frazier | ||
Mantic |
Fix Released
|
Undecided
|
Unassigned | ||
Noble |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[Impact]
Users trying to build software that links w/ jammy's libjsoncpp library will hit a build failure if that software uses cmake and another library that also requires libjsoncpp because libjsoncpp's cmake config does not protect against duplicate imports. This can be reproduced by building a a newer version of cmake itself using system libjsoncpp (I was trying to build 3.27.4, but I also checked that it impacts cmake master).
[Test Case]
This can be demonstrated by calling find_package twice in a row:
$ mkdir test && cd test
$ cat > CMakeLists.txt << EOF
project(test)
find_package(
find_package(
EOF
$ cmake .
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/lib/
add_library cannot create imported target "JsonCpp::JsonCpp" because
another target with the same name already exists.
Call Stack (most recent call first):
/usr/
CMakeLists.txt:3 (find_package)
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_
cmake_
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
See also "/home/
[Fix]
Backport a fix from mantic that adds a guard in the .cmake file.
[ What Could Go Wrong ]
We could cause reverse dependencies to fail to build from source due to an inadvertent error. We can mitigate this by doing a test rebuild of the reverse dependencies, which I've done in a PPA:
https:/
Changed in libjsoncpp (Ubuntu Jammy): | |
status: | New → In Progress |
assignee: | nobody → dann frazier (dannf) |
description: | updated |
Changed in libjsoncpp (Ubuntu Noble): | |
status: | New → Fix Released |
Changed in libjsoncpp (Ubuntu Mantic): | |
status: | New → Fix Released |
description: | updated |
description: | updated |
Hello dann, or anyone else affected,
Accepted libjsoncpp into jammy-proposed. The package will build now and be available at https:/ /launchpad. net/ubuntu/ +source/ libjsoncpp/ 1.9.5-3ubuntu0. 1 in a few hours, and then in the -proposed repository.
Please help us by testing this new package. See https:/ /wiki.ubuntu. com/Testing/ EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.
If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification- needed- jammy to verification- done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification- failed- jammy. In either case, without details of your testing we will not be able to proceed.
Further information regarding the verification process can be found at https:/ /wiki.ubuntu. com/QATeam/ PerformingSRUVe rification . Thank you in advance for helping!
N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.