duplicate JsonCpp::JsonCpp leads to build failures

Bug #2063950 reported by dann frazier
10
This bug affects 1 person
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(jsoncpp 1.9.5)
find_package(jsoncpp 1.9.5)
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/x86_64-linux-gnu/cmake/jsoncpp/jsoncpp-namespaced-targets.cmake:5 (add_library):
  add_library cannot create imported target "JsonCpp::JsonCpp" because
  another target with the same name already exists.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/jsoncpp/jsoncppConfig.cmake:41 (include)
  CMakeLists.txt:3 (find_package)

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present. A line of code such as

    cmake_minimum_required(VERSION 3.22)

  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/ubuntu/test/CMakeFiles/CMakeOutput.log".

[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://launchpad.net/~dannf/+archive/ubuntu/libjsoncpp-sru-test/+packages

dann frazier (dannf)
Changed in libjsoncpp (Ubuntu Jammy):
status: New → In Progress
assignee: nobody → dann frazier (dannf)
dann frazier (dannf)
description: updated
Changed in libjsoncpp (Ubuntu Noble):
status: New → Fix Released
Changed in libjsoncpp (Ubuntu Mantic):
status: New → Fix Released
dann frazier (dannf)
description: updated
dann frazier (dannf)
description: updated
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

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/PerformingSRUVerification . 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.

Changed in libjsoncpp (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (libjsoncpp/1.9.5-3ubuntu0.1)

All autopkgtests for the newly accepted libjsoncpp (1.9.5-3ubuntu0.1) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

f3d/unknown (arm64, armhf, s390x)
ignition-fuel-tools/unknown (armhf)
odil/unknown (armhf)
oomd/unknown (armhf)
sysdig/unknown (s390x)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#libjsoncpp

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.