1
votes

I'm new to Cmake and trying to build a KDE project (okular) which requires an optional package(libspectre). I did a default make install and the library files are in the location "/usr/lib/x86_64-linux-gnu".

In the generators/CMakeLists.txt, I tried to replace the "macro_optional_find_package(LibSpectre)" with the following:

find_library(LIBSPECTRE_LIBRARY NAMES libspectre PATHS "/usr/lib/x86_64-linux-gnu/")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibSpectre DEFAULT_MSG LIBSPECTRE_LIBRARY)

Which seems to not find the libspectre library. I tried replacing PATHS with HINTS and also changing 'libspectre' to 'spectre' after NAMES. But it doesn't seem to recognize.

Any help is appreciated!

1
What is exact name (with extension) of the library's file (under /usr/lib/x86_64-linux-gnu/) which you want to find? Are you sure, that given find_library() call is executed? (Try to add message() call after it). As you build project for yourself, it is better just to set LIBSPECTRE_LIBRARY variable in CMake cache. No needs to modify scripts for that. - Tsyvarev
Hi, The name of the library file is libspectre.so.1. It's a symlink to libspectre.so.1.1.7. I will try your suggestions. Thanks! - fastforward

1 Answers

1
votes

CMake doesn't aware about library's so-version, it checks only precize .so extension.

You may create libspectre.so - symlink to libspectre.so.1. So

find_library(LIBSPECTRE_LIBRARY NAMES spectre PATHS "/usr/lib/x86_64-linux-gnu/")

will work.