Skip to content

1.7.4: pkg-config file (wrong includedir) #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tgurr opened this issue Jul 11, 2016 · 14 comments
Closed

1.7.4: pkg-config file (wrong includedir) #497

tgurr opened this issue Jul 11, 2016 · 14 comments

Comments

@tgurr
Copy link

tgurr commented Jul 11, 2016

In 1.7.2 everything looked okay:

prefix=/usr/x86_64-pc-linux-gnu
exec_prefix=${prefix}
libdir=/usr/x86_64-pc-linux-gnu/lib
includedir=/usr/x86_64-pc-linux-gnu/include/jsoncpp

Name: jsoncpp
Description: A C++ library for interacting with JSON
Version: 1.7.2
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}

and in 1.7.4 at least the includedir looks wrong to me:

prefix=/usr/x86_64-pc-linux-gnu
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}//usr/x86_64-pc-linux-gnu/include/jsoncpp

Name: jsoncpp
Description: A C++ library for interacting with JSON
Version: 1.7.4
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}
@cdunn2001
Copy link
Contributor

See #493. 1.7.4 is a "pre-release tag". We might need to revert, but hopefully you and @zorun can find a workable solution.

@zorun
Copy link

zorun commented Jul 11, 2016

It's apparently hard to make everyone happy...

@tgurr can you provide the arguments you pass to cmake? Also, was 1.7.3 fine for you? Because as mentioned in #493, 1.7.3 was broken for Archlinux.

For reference, here is the cmake invocation and resulting pkg-config file on Archlinux:

cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_STATIC_LIBS=OFF
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: jsoncpp
Description: A C++ library for interacting with JSON
Version: 1.7.4
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}

@tgurr
Copy link
Author

tgurr commented Jul 13, 2016

Here is what it looks like with 1.7.3:

prefix=/usr/x86_64-pc-linux-gnu
exec_prefix=${prefix}
libdir=lib
includedir=/usr/x86_64-pc-linux-gnu/include/jsoncpp

Name: jsoncpp
Description: A C++ library for interacting with JSON
Version: 1.7.3
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}

The CMake arguments we pass:

-DCMAKE_COLOR_MAKEFILE:BOOL=TRUE
-DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE
-DCMAKE_BUILD_TYPE:STRING=None
-DCMAKE_C_FLAGS:STRING=-pipe -O2 -march=native
-DCMAKE_CXX_FLAGS:STRING=-march=native -O2 -pipe
-DCMAKE_AR:PATH=x86_64-pc-linux-gnu-ar
-DCMAKE_RANLIB:PATH=x86_64-pc-linux-gnu-ranlib
-DCMAKE_NM:PATH=x86_64-pc-linux-gnu-nm
-DCMAKE_C_COMPILER:PATH=x86_64-pc-linux-gnu-cc
-DCMAKE_CXX_COMPILER:PATH=x86_64-pc-linux-gnu-c++
-DCMAKE_INSTALL_PREFIX:PATH=/usr/x86_64-pc-linux-gnu
-DCMAKE_SYSTEM_PREFIX_PATH:PATH=/usr/x86_64-pc-linux-gnu
-DCMAKE_INSTALL_LIBDIR:STRING=lib
-DCMAKE_INSTALL_DATAROOTDIR:PATH=/usr/share/
-DINCLUDE_INSTALL_DIR=/usr/x86_64-pc-linux-gnu/include/jsoncpp
-DBUILD_SHARED_LIBS:BOOL=TRUE
-DJSONCPP_WITH_CMAKE_PACKAGE:BOOL=TRUE
-DJSONCPP_WITH_POST_BUILD_UNITTEST:BOOL=FALSE
-DJSONCPP_WITH_WARNING_AS_ERROR:BOOL=FALSE
-DJSONCPP_WITH_TESTS=TRUE

This allows us to natively cross compile, e.g. x86_64 lands in /usr/x86_64-pc-linux-gnu, i686 in /usr/i686-pc-linux-gnu and so on.

@zorun
Copy link

zorun commented Jul 13, 2016

Ok, so you just need to build with -DINCLUDE_INSTALL_DIR=include/jsoncpp instead (this is now relative to CMAKE_INSTALL_PREFIX). By the way, jsoncpp automatically adds a directory called json, so you would end up with headers in /usr/x86_64-pc-linux-gnu/include/jsoncpp/json/. But that was probably already the case with 1.7.2.

By the way, you have the same problem I had, which is that libdir is a relative path in 1.7.3. If you try to compile a program that uses pkg-config to find jsoncpp 1.7.3, it will fail to compile.

@cdunn2001 maybe it's worth mentioning in the release notes that people customizing these variables (probably distribution packagers) may need to change absolute paths into relative paths?

@tgurr
Copy link
Author

tgurr commented Jul 13, 2016

I've a problem setting -DINCLUDE_INSTALL_DIR=include/jsoncpp since when I do that I get a CMake error:

-- JsonCpp Version: 1.7.4
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.11", minimum required is "2.6") 
-- Configuring done
-- Generating done
CMake Error in src/lib_json/CMakeLists.txt:
  Target "jsoncpp_lib" INTERFACE_INCLUDE_DIRECTORIES property contains path:

    "/var/tmp/paludis/build/dev-libs-jsoncpp-1.7.4/work/build/include/jsoncpp"

  which is prefixed in the build directory.

About /usr/x86_64-pc-linux-gnu/include/jsoncpp/json/ you're correct, we're doing this on purpose to avoid conflicts with the json-c package.

@cdunn2001
Copy link
Contributor

We need you both to come to an agreement. I am not an expert on cmake and would rather not take this decision myself.

@zorun
Copy link

zorun commented Jul 28, 2016

Yes, I tried to work this out, but I'm no expert on cmake either.

@tgurr as a workaround, you can patch INCLUDE_INSTALL_DIR in the main CMakeLists.txt. For some reason, changing this variable in the file instead of passing it as an option to cmake avoids the runtime error.

@anatol
Copy link

anatol commented Aug 2, 2016

What is recommended solution for this problem? Is it something that is going to be fixed in jsoncpp build script?

@ppaalanen
Copy link

On Gentoo, installed jsoncpp 1.7.7, and the pc-file looks like this:

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir=${prefix}//usr/include/jsoncpp

Which leads to -I/usr/usr/include/jsoncpp which is wrong.

The build script looks like this: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/jsoncpp/jsoncpp-1.7.7.ebuild

Are you saying that this is a distribution error and they should fix INCLUDE_INSTALL_DIR?

@zorun
Copy link

zorun commented Oct 7, 2016

The build script you link to says:

# Follow Debian, Ubuntu, Arch convention for headers location
# bug #452234
-DINCLUDE_INSTALL_DIR="${EPREFIX}"/usr/include/jsoncpp

But Archlinux installs headers in /usr/include/json (which seems to be the default), not /usr/include/jsoncpp. The build script does not use INCLUDE_INSTALL_DIR at all: https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/jsoncpp

From what I see here in the CMake documentation this variable should probably be relative, not absolute.

@ppaalanen
Copy link

@zorun I actually tried to patch the INCLUDE_INSTALL_DIR to be relative, but then cmake itself fails as described in the comment by @tgurr .
Note that installing to /usr/include is not possible, as there are several packages that would all provide the files in /usr/include/json and conflict, hence the jsoncpp must be added in the path.

How can we have both a correct .pc file and install the headers into a directory named by the package to avoid conflicts?

@SoapGentoo
Copy link
Contributor

With my pull request (#562), this issue is solved now in Gentoo, as GNUInstallDirs is supposed to be used with relative paths. I believe this issue can be closed now.

@tgurr
Copy link
Author

tgurr commented Dec 19, 2016

Thanks! 1.8.0 works for me as well (passing -DCMAKE_INSTALL_INCLUDEDIR=include/jsoncpp results in a correct pkg-config file).

@tgurr tgurr closed this as completed Dec 19, 2016
cdunn2001 added a commit that referenced this issue Dec 19, 2016
See #497, bottom comment.
@zorun
Copy link

zorun commented Dec 20, 2016

Thanks a lot for the fix @SoapGentoo ! It still works fine for Arch Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants