0

I'm building https://github.com/open-source-parsers/jsoncpp/tree/0.10.7 for an embedded system because that's the recommended version if c++03 support is still needed. My target is based on Ubuntu 12.04.

CMakeLists.txt has include(GNUInstallDirs) so I'm trying to specify the installation directories with

 cmake -DCMAKE_INSTALL_LIBDIR=/usr -DCMAKE_INSTALL_PREFIX=lib

I've tried various combinations of these and permutations, but cmake insists on installing the shared library in /usr/lib/x86_64-linux-gnu while I need it to be in /usr/lib.

I've followed the advice here: How to use CMAKE_INSTALL_PREFIX but to no avail.

Oddly the INCLUDEDIR variable does put the include files where I want them.

Is there any way of getting the library where I want it without modifying CMakeLists.txt?

Simon Elliott
  • 2,087
  • 4
  • 30
  • 39

1 Answers1

1

While the project includes GNUInstallDirs module, it uses the variable CMAKE_INSTALL_LIBDIR (defined in this module) only for pkg-config file install location.

For libraries the project introduces LIBRARY_INSTALL_DIR variable, and for header files - INCLUDE_INSTALL_DIR.

So you need to set these variables, not the ones defined by GNUInstallDirs module.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • That makes sense, and when I tried it, the correct values were set in CMakeCache.txt, but bizarrely it still does "Installing: /usr/lib/x86_64-linux-gnu/libjsoncpp.so.0" etc – Simon Elliott Jul 23 '19 at 18:51
  • 1
    [The line](https://github.com/open-source-parsers/jsoncpp/blob/0.10.7/src/lib_json/CMakeLists.txt#L51) which determines final installation path contains `"${LIBRARY_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}"`. According to the description of [CMAKE_LIBRARY_ARCHITECTURE](https://cmake.org/cmake/help/v3.9/variable/CMAKE_LIBRARY_ARCHITECTURE.html), it is set by CMake when it detects the system. I am not sure that it is intended to be redefined by the user (`-D` option for `cmake`), but you may try. Alternatively, you may try to edit the project's code. – Tsyvarev Jul 23 '19 at 20:32
  • That variable can't be redefined by the user. Thanks for pointing me at the relevant bit of code. – Simon Elliott Aug 06 '19 at 13:36