Public bug reported:

[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".

[ 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.

** Affects: libjsoncpp (Ubuntu)
     Importance: Undecided
         Status: Fix Released

** Affects: libjsoncpp (Ubuntu Jammy)
     Importance: Undecided
     Assignee: dann frazier (dannf)
         Status: In Progress

** Affects: libjsoncpp (Ubuntu Mantic)
     Importance: Undecided
         Status: Fix Released

** Affects: libjsoncpp (Ubuntu Noble)
     Importance: Undecided
         Status: Fix Released

** Also affects: libjsoncpp (Ubuntu Jammy)
   Importance: Undecided
       Status: New

** Changed in: libjsoncpp (Ubuntu Jammy)
       Status: New => In Progress

** Changed in: libjsoncpp (Ubuntu Jammy)
     Assignee: (unassigned) => dann frazier (dannf)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2063950

Title:
  duplicate JsonCpp::JsonCpp leads to build failures

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libjsoncpp/+bug/2063950/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to