FS#71086 - [nlohmann-json] pkgconfig and cmake files have incorrect paths

Attached to Project: Community Packages
Opened by Jed Brown (jedbrown) - Tuesday, 01 June 2021, 15:05 GMT
Last edited by David Runge (dvzrv) - Sunday, 01 August 2021, 19:45 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To David Runge (dvzrv)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Cflags here should be -I/usr/include:

$ cat /usr/lib/pkgconfig/nlohmann_json.pc
Name: nlohmann_json
Description: JSON for Modern C++
Version: 3.9.1
Cflags: -I/usr/local/include


The logic is more obtuse for CMake, but by default, it finds a prefix of / instead of /usr/, and thus fails to find headers in /include (which doesn't exist by default).

Additional info:
* package version(s) 3.9.1-2
This task depends upon

Closed by  David Runge (dvzrv)
Sunday, 01 August 2021, 19:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed with nlohmann-json 3.9.1-4
Comment by David Runge (dvzrv) - Tuesday, 01 June 2021, 15:21 GMT
@jedbrown: Thanks for the report.

Judging from the input file we probably have to add/define CMAKE_INSTALL_INCLUDEDIR.
Comment by David Runge (dvzrv) - Tuesday, 01 June 2021, 15:51 GMT
Please check whether nlohmann-json 3.9.1-3 in [community] fixes this issue for you.
Comment by Jed Brown (jedbrown) - Tuesday, 01 June 2021, 16:16 GMT
Unfortunately not. nlohmann_json.pc still incorrectly states /usr/local/include and the CMake is incorrect such that (as an example package that uses nlohmann-json via CMake) yay -S bear fails with

-- Found nlohmann_json: /lib64/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.9.1")
[...]
CMake Error in citnames/CMakeLists.txt:
Imported target "nlohmann_json::nlohmann_json" includes non-existent path

"/include"

in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:

* The path was deleted, renamed, or moved to another location.

* An install or uninstall procedure did not complete successfully.

* The installation package was faulty and references files it does not
provide.



-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
Comment by Eli Schwartz (eschwartz) - Tuesday, 01 June 2021, 18:01 GMT
"/include"

This means on a totally unrelated note, you're invoking cmake as /bin/cmake rather than /usr/bin/cmake

This is problematic since cmake sucks and will then try to find /bin/../include rather than /usr/bin/../include

Check your $PATH, and if it has /bin in it -- and *especially* if it has it before /usr/bin -- fix your system to *not* have /bin in $PATH since it's totally wrong and completely incompatible with Arch Linux's filesystem layout.

...

However:

$ pkg-list-linked-libraries -g nlohmann-json /include
==> grepping nlohmann-json-3.9.1-3-any.pkg.tar.zst ...
[...]
usr/lib/pkgconfig/nlohmann_json.pc:Cflags: -I/usr/local/include
[...]

is still broken
Comment by Jed Brown (jedbrown) - Tuesday, 01 June 2021, 20:25 GMT
Amusing since this is the first time I've had an issue with /bin/cmake since the symlinks were added to filesystem a long time ago. This seems like a fragile *Config.cmake file (the cmake path can be literally anything) rather than an inherent CMake issue, but I'll be sure to keep /bin out of PATH going forward. Thanks.
Comment by Eli Schwartz (eschwartz) - Tuesday, 01 June 2021, 20:50 GMT
Sadly, I've seen this kind of /bin/cmake bug report quite a lot. e.g.  FS#62028   FS#61952   FS#66518 

IIRC the problematic code is created by cmake's builtin helper function for creating *Config.cmake files, using the rationale "we should try to detect the paths relative to the cmake binary because on Windows this is relocatable".
Comment by Ilya K (K900) - Sunday, 01 August 2021, 12:39 GMT
FWIW, this is still broken...
Comment by David Runge (dvzrv) - Sunday, 01 August 2021, 19:44 GMT
@K900: Thanks for the ping. I had already forgotten about this ticket again :S

After some additional digging it appears that it's (yet again) the tests of the project having an adverse effect on the installed files.
I have opened an upstream ticket about this [1] and will close this ticket, as the pkgconfig integration *should be* fixed with nlohmann-json 3.9.1-4.

[1] https://github.com/nlohmann/json/issues/2907

Loading...