Subject: Re: bug#18926: cmake-build-system should set CMAKE_INSTALL_LIBDIR and CMAKE_PREFIX_PATH

From: Andreas Enge <[email-masked]>
Date: Sun, 1 Mar 2015 10:58:47 +0100

The patch does not work. I thought this was due to it returning the .cmake
files themselves and not the directory containing them. Here, for instance,
it contains
   /gnu/store/h30r6z3fc67h8557kd63vjjdlfpc58wj-libqtxdg-1.1.0/share/cmake/qt5xdg/qt5xdg-config.cmake
Inside the build directory, I tried an
export CMAKE_MODULE_PATH=/gnu/store/h30r6z3fc67h8557kd63vjjdlfpc58wj-libqtxdg-1.1.0/share/cmake/qt5xdg
with the same error message.

Then I followed the advice given on screen and set
export CMAKE_PREFIX_PATH=/gnu/store/h30r6z3fc67h8557kd63vjjdlfpc58wj-libqtxdg-1.1.0
which worked.

export Qt5Xdg_DIR=/gnu/store/h30r6z3fc67h8557kd63vjjdlfpc58wj-libqtxdg-1.1.0/share/cmake/qt5xdg
worked as well. But I do not see how to implement this kind of package
specific path in guix.

The following explains why CMAKE_MODULE_PATH has no effect here:
   http://www.cmake.org/cmake/help/v3.0/command/find_package.html
Apparently, there is a "module mode" and a "config mode". The first one uses
CMAKE_MODULE_PATH and looks for files called FindPACKAGE.cmake. We are in the
second case here, where a file PACKAGEConfig.cmake or package-config.cmake
is looked for.

Further below on that page, it is explained where these config files are
looked for. On unix like systems, this is
<prefix>/(lib/<arch>|lib|share)/cmake/<name>*/ 
<prefix>/(lib/<arch>|lib|share)/<name>*/
<prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/

The <prefix> part can be set by CMAKE_PREFIX_PATH.

What would be desirable is the following:
In the definition of a search path, we need an additional transformation
(if it is not already there). We need to look for the regular expression
   (.+)/(lib|lib64|share)/.+\.cmake$
or maybe
   (.+)/(lib|lib/[^/]+|share)/.+\.cmake$
and put
   \1
into CMAKE_PREFIX_PATH.

I think that would also make the lines
      (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
      (setenv "CMAKE_INCLUDE_PATH" (getenv "CPATH"))
in guix/build/cmake-build-system obsolete.

Concerning the "lib64" part, I still have doubts. The documentation speaks
of "lib/<arch>"; yet, there are packages which install into "lib64" (like
libqtxdg, needed for liblxqt, which triggered this discussion).

So if the suggestion above does not work, we can in a second step try
to play with CMAKE_INSTALL_LIBDIR.

Andreas