Despite reading the documentation I can't figure out whether CMake's command find_library searches or not the directories listed in LD_LIBRARY_PATH.
My tests give mixed results.
From the documentation (I didn't reproduced the text related to cmake variables nor parameters of find_library, which are not relevant here):
If
NO_DEFAULT_PATHis specified, then no additional paths are added to the search. IfNO_DEFAULT_PATHis not specified, the search process is as follows:...
- Search the standard system environment variables. This can be skipped if
NO_SYSTEM_ENVIRONMENT_PATHis an argument.
- Directories in
LIB. On Windows hosts:<prefix>/lib/<arch>ifCMAKE_LIBRARY_ARCHITECTUREis set, and<prefix>/libfor each<prefix>/[s]bininPATH, and<entry>/libfor other entries inPATH, and the directories inPATHitself....
So LD_LIBRARY_PATH is not used by find_library. This is confirmed reading the source code.
The mixed results of your tests may come from an other variable, but without a detailed description of these tests, this is just a guess.
According to the current documentation and a small test, it seems that LD_LIBRARY_PATH is not considered.
The documentation for find_library says
If
NO_DEFAULT_PATHis specified, then no additional paths are added to the search. IfNO_DEFAULT_PATHis not specified, the search process is as follows:
- Search paths specified in cmake-specific cache variables. These are intended to be used on the command line with a
-DVAR=value. This can be skipped ifNO_CMAKE_PATHis passed.
<prefix>/lib/<arch>if CMAKE_LIBRARY_ARCHITECTURE is set, and<prefix>/libfor each<prefix>inCMAKE_PREFIX_PATHCMAKE_LIBRARY_PATHCMAKE_FRAMEWORK_PATH- Search paths specified in cmake-specific environment variables. These are intended to be set in the user’s shell configuration. This can be skipped if
NO_CMAKE_ENVIRONMENT_PATHis passed.
<prefix>/lib/<arch>ifCMAKE_LIBRARY_ARCHITECTUREis set, and<prefix>/libfor each<prefix>inCMAKE_PREFIX_PATHCMAKE_LIBRARY_PATHCMAKE_FRAMEWORK_PATH- Search the paths specified by the
HINTSoption. These should be paths computed by system introspection, such as a hint provided by the location of another item already found. Hard-coded guesses should be specified with thePATHSoption.- Search the standard system environment variables. This can be skipped if
NO_SYSTEM_ENVIRONMENT_PATHis an argument.
- Directories in
LIB,<prefix>/lib/<arch>ifCMAKE_LIBRARY_ARCHITECTUREis set, and<prefix>/libfor each<prefix>/[s]bininPATH, and<entry>/libfor other entries inPATH, and the directories inPATHitself.- Search cmake variables defined in the Platform files for the current system. This can be skipped if
NO_CMAKE_SYSTEM_PATHis passed.
<prefix>/lib/<arch>ifCMAKE_LIBRARY_ARCHITECTUREis set, and<prefix>/libfor each<prefix>inCMAKE_SYSTEM_PREFIX_PATHCMAKE_SYSTEM_LIBRARY_PATHCMAKE_SYSTEM_FRAMEWORK_PATH- Search the paths specified by the
PATHSoption or in the short-hand version of the command. These are typically hard-coded guesses.
Since CMAKE_PREFIX_PATH and CMAKE_LIBRARY_PATH are specified to be empty (by default), the question is equivalent to the following: Is LD_LIBRARY_PATH considered by CMAKE_SYSTEM_PREFIX_PATH or CMAKE_SYSTEM_LIBRARY_PATH. According to a simple test I made with CMake 3.7.1, LD_LIBRARY_PATH is not considered by them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With