Package: nlohmann-json-dev
Version: 2.1.1-1.1
Severity: important
Tags: patch

Dear Maintainer,

When trying to build my project which depends on nlohmann-json-dev 2.1.1, using
CMake leads to configuration files not found. See the error message below:

    Could not find a package configuration file provided by "nlohmann_json"
    (requested version 2.1.1) with any of the following names:

      nlohmann_jsonConfig.cmake
      nlohmann_json-config.cmake

    Add the installation prefix of "nlohmann_json" to CMAKE_PREFIX_PATH or set
    "nlohmann_json_DIR" to a directory containing one of the above files.  If
    "nlohmann_json" provides a separate development package or SDK, be sure it
    has been installed.

This is due to the files not being installed correctly on the system. The
package installs them to the following paths:

    /usr/lib/cmake/*.cmake

However, according to CMake documentation~[1], the files should be found under
one of the following directories:

    <prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/
    <prefix>/(lib/<arch>|lib*|share)/<name>*/
    <prefix>/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/
    <prefix>/<name>*/(lib/<arch>|lib*|share)/cmake/<name>*/
    <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/
    <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/

Therefore, the directory for nlohmann-json should rather be:

    /usr/lib/cmake/nlohmann_json/

and not

    /usr/lib/cmake/

I did include a patch for fixing this in the attchments of this mail.

Note that the package doesn't seem to build now in unstable due to tests failing
to compile. If you're to provide a new version for this package in order to
address this issue, you may have to disable tests (or go around the issue if you
investigate more than I did). I have attached a patch (for debian/rules file)
for this as well which you can use.

Regards,

[1]: https://cmake.org/cmake/help/v3.13/command/find_package.html

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (900, 'testing'), (800, 'unstable'), (700, 'experimental'), (600, 
'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.5.0-2-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_USER, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- no debconf information

-- 
Simon Désaulniers
sim.desaulni...@gmail.com
commit cd93409ebc0bac1a0c61a4262801a96673c29995
Author: Simon Désaulniers <sim.desaulni...@gmail.com>
Date:   Mon May 11 18:17:55 2020 -0400

    patches: cmake path should contain project name
    
    According to
    https://cmake.org/cmake/help/v3.13/command/find_package.html.

diff --git a/debian/patches/0002-fix-path-for-cmake-files.patch b/debian/patches/0002-fix-path-for-cmake-files.patch
index edcf86ba..0bdc9d4a 100644
--- a/debian/patches/0002-fix-path-for-cmake-files.patch
+++ b/debian/patches/0002-fix-path-for-cmake-files.patch
@@ -7,7 +7,7 @@ Subject: fix path for cmake files
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 30e3966..6279544 100644
+index 30e3966..839d2cb 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -13,7 +13,7 @@ set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
@@ -15,7 +15,7 @@ index 30e3966..6279544 100644
  set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
  set(JSON_CONFIGVERSION_FILENAME "${JSON_PACKAGE_NAME}ConfigVersion.cmake")
 -set(JSON_CONFIG_DESTINATION "cmake")
-+set(JSON_CONFIG_DESTINATION "lib/cmake")
++set(JSON_CONFIG_DESTINATION "lib/cmake/${PROJECT_NAME}/")
  set(JSON_INCLUDE_DESTINATION "include/nlohmann")
  
  set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
diff --git a/debian/patches/bea1665ac9a5e7aa4fa93668ff35723385a27bfd.patch b/debian/patches/bea1665ac9a5e7aa4fa93668ff35723385a27bfd.patch
index 4db82c9e..ecd746fe 100644
--- a/debian/patches/bea1665ac9a5e7aa4fa93668ff35723385a27bfd.patch
+++ b/debian/patches/bea1665ac9a5e7aa4fa93668ff35723385a27bfd.patch
@@ -7,11 +7,11 @@ Subject: [PATCH] modify json.hpp to compile with recent gcc
 
 https://github.com/nlohmann/json/issues/606
 ---
- src/json.hpp | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
+ src/json.hpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/json.hpp b/src/json.hpp
-index c2e1f20..48d797d 100644
+index 6dfc183..5259d06 100644
 --- a/src/json.hpp
 +++ b/src/json.hpp
 @@ -6054,7 +6054,7 @@ class basic_json
commit 5df7a99f4fff4e564da65ad884926dd6aff402b6
Author: Simon Désaulniers <sim.desaulni...@gmail.com>
Date:   Mon May 11 19:39:35 2020 -0400

    rules: don't build tests

diff --git a/debian/rules b/debian/rules
index 9ab5610f..8701eb09 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,9 @@ override_dh_clean:
 	dh_clean
 	make -C doc clean
 
+override_dh_auto_configure:
+	dh_auto_configure -- -DBuildTests=OFF
+
 override_dh_auto_build:
 	make re2c
 	make -C doc

Attachment: signature.asc
Description: PGP signature

Reply via email to