Issue
Is it possible to debug find_library
from CMake?
What I want is a list of considered paths. My use case is a call like
find_library (FOO_LIBRARY
NAMES foo foo.so.0)
and there is /lib64/libfoo.so.0
on my system. However CMake does not find it. I checked that FIND_LIBRARY_USE_LIB64_PATHS
is set to TRUE
.
Solution
With CMake 3.17 this got added:
The “CMAKE_FIND_DEBUG_MODE” variable was introduced to print extra find call information during the cmake run to standard error. Output is designed for human consumption and not for parsing.
So you pass either -DCMAKE_FIND_DEBUG_MODE=ON
or --debug-find
to your CMake command.
Here is an example output when searching for libFOO:
find_library considered the following locations:
/usr/local/lib64/(lib)FOO(\.so|\.a)
/usr/local/lib/(lib)FOO(\.so|\.a)
/usr/local/lib64/(lib)FOO(\.so|\.a)
/usr/local/lib/(lib)FOO(\.so|\.a)
/usr/local/lib64/(lib)FOO(\.so|\.a)
/usr/local/(lib)FOO(\.so|\.a)
/usr/lib64/(lib)FOO(\.so|\.a)
/usr/lib/(lib)FOO(\.so|\.a)
/usr/lib64/(lib)FOO(\.so|\.a)
/usr/lib/(lib)FOO(\.so|\.a)
/usr/lib64/(lib)FOO(\.so|\.a)
/usr/(lib)FOO(\.so|\.a)
/lib64/(lib)FOO(\.so|\.a)
/lib/(lib)FOO(\.so|\.a)
/opt/(lib)FOO(\.so|\.a)
The item was not found.
Answered By - usr1234567 Answer Checked By - Mary Flores (WPSolving Volunteer)