Skip to content

Differing include directory #4

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
jplatte opened this issue Jul 8, 2014 · 7 comments
Closed

Differing include directory #4

jplatte opened this issue Jul 8, 2014 · 7 comments

Comments

@jplatte
Copy link
Contributor

jplatte commented Jul 8, 2014

Hi, I am using jsoncpp in one of my projects, which I am compiling natively and for the web with emscripten (basically works like any cross-compiler).

I found that finding the jsoncpp headers is a bit of an unnecessary hurdle there because by default they are installed in the directory ${prefix}/include/json (that's what I have when cross-compiling), while in my native environment (arch linux), jsoncpp headers are in ${prefix}/include/jsoncpp/json to avoid conflicts with other packages using ${prefix}/include/json.

Could you please change the include directories name from "json" to "jsoncpp" so packagers don't have to work around this anymore and the headers are found in one common place?

@cdunn2001
Copy link
Contributor

This comes up from time to time. It's difficult to change the default header location because it would break existing code.

What if it were an option to CMake? What build system are you using?

@jplatte
Copy link
Contributor Author

jplatte commented Jul 9, 2014

I know it would break existing code, that's why I suggested to do it with the next major release (API break).

I don't think adding an option to CMake that controls this would help, at least I wouldn't like to drop the additional check for the include directory then because both directories would still be supported.

What would help is adding pkg-config support (perhaps have a look at this, I recently found it but didn't try it out), at least for those using the GNU build system – like me – but I personally would prefer a renaming of the include dir; also because quite some people are of the opinion that pkg-config should generally be avoided, independent of the build system used.

@cdunn2001
Copy link
Contributor

I still don't think jsoncpp is definitely unique.

while in my native environment (arch linux), jsoncpp headers are in ${prefix}/include/jsoncpp/json

What causes them to end up there?

I don't understand what's wrong with a parameter to CMake. People using

#include <json/value.h>

should not be broken by our change, I think.

@jplatte
Copy link
Contributor Author

jplatte commented Jul 10, 2014

What causes them to end up there?

It's the PKGBUILD of the jsoncpp package in the arch linux repositories:

# $Id: PKGBUILD 188521 2013-06-15 07:18:30Z andrea $
# Maintainer: Andrea Scarpino <[email protected]>
# Contributor: Jonahtan Schaeffer <[email protected]>
# COntributor: Drake Arconis <[email protected]>

pkgname=jsoncpp
pkgver=0.5.0
pkgrel=4
pkgdesc="A JSON C++ library"
url='http://jsoncpp.sourceforge.net/'
license=('custom:Public_Domain')
arch=('i686' 'x86_64')
depends=('gcc-libs')
makedepends=('scons')
source=("http://downloads.sourceforge.net/$%7Bpkgname%7D/$%7Bpkgname%7D-src-$%7Bpkgver%7D.tar.gz")
md5sums=('24482b67c1cb17aac1ed1814288a3a8f')

build() {
  cd ${pkgname}-src-${pkgver}
  scons platform=linux-gcc
}

package() {
  cd ${pkgname}-src-${pkgver}

  install -d "${pkgdir}"/usr/include/jsoncpp
  cp -r include/json "${pkgdir}"/usr/include/jsoncpp/json

  install -Dm644 buildscons/linux-gcc-*/src/lib_json/libjson_linux-gcc*libmt.so \
    "${pkgdir}"/usr/lib/libjsoncpp.so

  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

Maybe I'm misunderstanding what you mean with a CMake parameter. Do you mean each project using jsoncpp should work around the possibility of having the json directory inside an additional jsoncpp directory (like here) or do you mean a CMake parameter in jsoncpp itself, giving packagers a simple option to change the directory the headers will be installed to?

@cdunn2001
Copy link
Contributor

That is using a very old version of the package:

Also, that is a custom build-script which specifies the project directory. The files are still included via

#include <json/json.h>

after -I/usr/include/jsoncpp. It also uses scons, whereas we now recommend cmake.

We would not mind letting the builder choose the directory in <json/*.h>. In fact, that is already possible if you run python amalgamate.py -h.

@jplatte
Copy link
Contributor Author

jplatte commented Jul 11, 2014

About the PKGBUILD issues: You should probably tell the maintainer about that.

But concerning this...

after -I/usr/include/jsoncpp.

That's exactly what I don't like (although you're right that it would be even worse when they just renamed the json directory to jsoncpp).

It means that each project using jsoncpp has to add this flag to its build system to make it work on systems that work around the reuse of the json include directory across libraries. It may also be possible that other systems do the same, only with another name for the "wrapping" include directory (json-cpp for example). Then this would need another include for each project using json-cpp that wants to be buildable on that system.

@cdunn2001
Copy link
Contributor

pkg-config support could be nice. See Issue #18.

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

2 participants