cmake find_library() not finding library specified by PATHS

2.1k views Asked by At

I have a find_library() statement that matches below (this is based on the amazon kinesis project):

find_library(SRTP_LIBRARIES NAMES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_LIB_PREFIX})

The OPEN_SRC_INSTALL_LIB_PREFIX correctly points to the location where this library is located. I can observe this directly. However, this find_library() call fails and I am confused as to why it would do so.

I thought that maybe cmake is searching through other paths first and ignoring my specified path, so I also tried it with the NO_DEFAULT_PATH flag, as that should limit the search to only be in the paths specified:

find_library(SRTP_LIBRARIES NAMES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_LIB_PREFIX} NO_DEFAULT_PATH)

... still no luck.

Any ideas why this would not work? I've verified the OPEN_SRC_INSTALL_LIB_PREFIX is the valid directory of the library via message() prints.

Note that this is cross compiling, although I don't see why that would change the behavior of find_library() unless I'm missing something from the documentation

1

There are 1 answers

0
ryeager On BEST ANSWER

First want to note I'm on cmake 17.5.

Ok, so the documentation is a bit confusing, but it seems that the NO_DEFAULT_PATH would only use the paths specified by the PATHS argument and none of the other cache variables, but that doesn't seem to be the case if CMAKE_SYSROOT is set.

Using the NO_CMAKE_FIND_ROOT_PATH is what actually causes find_library() to ignore the cached paths.