LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   cmake: how to set libdir=/usr/local/lib64? (https://www.linuxquestions.org/questions/slackware-14/cmake-how-to-set-libdir%3D-usr-local-lib64-4175635726/)

olevenets2 08-05-2018 03:20 PM

cmake: how to set libdir=/usr/local/lib64?
 
hello, I'm trying to compile a libvibble library:

https://packages.debian.org/ru/sid/libwibble-dev

on my Slackware, it uses cmake and when building the package uses usr/local/lib/pkgconfig/, ignoring the system settings $ PKG_CONFIG_PATH . How can I get it to use /usr/local/lib64? The LIB_SUFFIX configuration is not supported by this project.

jostber 08-05-2018 03:35 PM

Will these commands work?

https://stackoverflow.com/questions/...m-command-line

Didier Spaier 08-05-2018 03:36 PM

from the root of the tree, mkdir build && cd build && ccmake ..
Pressing c to configure, it displays:
Code:

CMAKE_BACKWARDS_COMPATIBILITY  *2.4                                         
 CMAKE_BUILD_TYPE                *                                           
 CMAKE_INSTALL_PREFIX            */usr/local                                 
 EXECUTABLE_OUTPUT_PATH          *                                           
 HAVE_TUT                        *OFF                                         
 LIBRARY_OUTPUT_PATH            *                                           
 RX_PATH                        */usr/include

So I assume that you need this option when running cmake: -DCMAKE_INSTALL_PREFIX=/usr

olevenets2 08-05-2018 03:52 PM

Hmm, i do not see any effect in two cases.

You can try to change my slackbuild, maybe I made a mistake somewhere:

https://paste.ee/p/G0AFV

Didier Spaier 08-05-2018 04:14 PM

1 Attachment(s)
I just built and installed a package using your SalckBuild with no issue and ran the binary at random against a header with no issue. So, what's wrong? I attach the content of the package.
Code:

didier[/tmp]$ wibble-test-genrunner header module_utils.h
#undef NDEBUG
#include "module_utils.h"
#define RUN(x,y) x().y()


olevenets2 08-05-2018 04:19 PM

Quote:

usr/lib/
usr/lib/libwibble.a
usr/lib/pkgconfig/
usr/lib/pkgconfig/libwibble.pc
for 64-bit systems this should be usr/lib64

Didier Spaier 08-05-2018 04:35 PM

Does that really matter? The thing works.

But you can just move these files after having in the SlackBuild after make install if you want.

USUARIONUEVO 08-05-2018 04:40 PM

Quote:

Originally Posted by Didier Spaier (Post 5888120)
Does that really matter? The thing works.

But you can just move these files after having in the SlackBuild after make install if you want.

not good ide, this file contains filepaths


Code:

usr/lib/pkgconfig/libwibble.pc
-DLIBRARY_OUTPUT_PATH=/usr/lib64 ???

olevenets2 08-05-2018 04:42 PM

This is necessary, otherwise other programs that depend on the libwibble library will not work because of the incorrect libdir.

Could you make changes to the script? I also think that libwibble.pc also needs to fix libdir

olevenets2 08-05-2018 04:46 PM

Quote:

Originally Posted by USUARIONUEVO (Post 5888121)
-DLIBRARY_OUTPUT_PATH=/usr/lib64 ???

does not work

orbea 08-05-2018 07:22 PM

Quote:

Originally Posted by olevenets2 (Post 5888096)
hello, I'm trying to compile a libvibble library:

https://packages.debian.org/ru/sid/libwibble-dev

on my Slackware, it uses cmake and when building the package uses usr/local/lib/pkgconfig/, ignoring the system settings $ PKG_CONFIG_PATH . How can I get it to use /usr/local/lib64? The LIB_SUFFIX configuration is not supported by this project.

The short answer is that you can't. Whoever wrote this CMakeLists.txt never considered this use case and it would need to be fixed. See the lines in wibble/CMakeLists.txt which contain "DESTINATION".

a4z 08-06-2018 02:24 AM

you would need to fix the cmake

if this is the source of this lib, than I guess here for the generated pkg-config file

https://github.com/metux/libwibble/b...eLists.txt#L68

and here
https://github.com/metux/libwibble/b...eLists.txt#L76

for the install location


what does this lib actually do?

phenixia2003 08-06-2018 03:11 AM

Hello,

The patch below should do the trick:
Code:

--- wibble/CMakeLists.txt.orig        2018-08-06 10:04:02.959164066 +0200
+++ wibble/CMakeLists.txt        2018-08-06 10:07:29.051173261 +0200
@@ -65,20 +65,31 @@
 
 set( prefix "${CMAKE_INSTALL_PREFIX}" )
 set( exec_prefix "${prefix}/bin" )
+
+if (DEFINED WIBBLE_LIBARCH)
+  if (NOT DEFINED libdir)
+    set ( libdir "${prefix}/lib${WIBBLE_LIBARCH}" )
+  endif ()
+  set ( WIBBLE_DESTINATION "lib${WIBBLE_LIBARCH}" )
+else ()
+  set(WIBBLE_DESTINATION "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
+endif()
+
 if (NOT DEFINED libdir)
        set( libdir "${prefix}/lib" )
 endif()
 set( includedir "${prefix}/include" )
 
+
 # cmake-time configuration
 configure_file( ${wibble_SOURCE_DIR}/libwibble.pc.in
                ${wibble_BINARY_DIR}/libwibble.pc @ONLY )
 
 # make install
-install( TARGETS wibble DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE} COMPONENT wibble_dev )
+install( TARGETS wibble DESTINATION ${WIBBLE_DESTINATION} COMPONENT wibble_dev )
 
 if( NOT WIN32 )
-install( FILES ${wibble_BINARY_DIR}/libwibble.pc DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig COMPONENT wibble_dev )
+install( FILES ${wibble_BINARY_DIR}/libwibble.pc DESTINATION ${WIBBLE_DESTINATION}/pkgconfig COMPONENT wibble_dev )
 install( FILES libwibble.m4 DESTINATION share/aclocal COMPONENT wibble_dev )
 install( FILES wibble-test-genrunner.1 DESTINATION share/man/man1 COMPONENT wibble_dev )
 endif( NOT WIN32 )

This patch adds the variable WIBBLE_LIBARCH which allows to specify the architecture.

Sample usage :

Code:

$ cd libwibble-1.1
$ patch -p0< /path/to/wibble.patch

$ mkdir _build
$ cd _build
$ cmake -DCMAKE_INSTALL_PREFIX=/usr -DWIBBLE_ARCH=64 ..
...
$ make install DESTDIR=./TEST
$ ls TEST/usr
bin  include  lib64  share

$ ls TEST/usr/lib64
libwibble.a  pkgconfig

$ cat TEST/usr/lib64/pkgconfig
prefix=/usr
exec_prefix=/usr/bin
libdir=/usr/lib64
includedir=/usr/include

Name: libwibble
Description: Library of useful C++ code
Version: 1.1
Libs: -L${libdir} -lwibble
Cflags: -I${includedir}

--
SeB

olevenets2 08-06-2018 04:52 PM

phenixia2003, thank you very much, your patch works fine!


All times are GMT -5. The time now is 05:01 AM.