[CMake] find_library fails when cross compiling

Oliver Dain oliver at revl.com
Mon Mar 26 21:06:23 EDT 2018


Hi,

I have some find_library lines like the following:

find_library(protobuf_protobuf protobuf PATHS
/Users/oliverdain/Documents/code/revl/.install/${ARCH}/${VARIANT}/protobuf/3.4.1.r1/lib
NO_DEFAULT_PATH )
target_link_libraries(ml_editing PUBLIC ${protobuf_protobuf})

These work find when $ARCH and $VARIANT are set to OSX and either Debug or
Release (my target system). However, If I run

cmake -H.
-B/Users/oliverdain/Documents/code/revl/cpp/build/build/IPHONE/Release
-DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DIOS_PLATFORM=OS
-DCMAKE_BUILD_TYPE=Release -DARCH=IPHONE -DVARIANT=Release

the libraries are reported not found (the standard "CMake Error: The
following variables are used in this project, but they are set to
NOTFOUND." error) even though the libraries are in the specified location.
For example, it says it can't find the protobuf libs but an ls yields:

$ ls
/Users/oliverdain/Documents/code/revl/.install/IPHONE/Release/protobuf/3.4.1.r1/lib
cmake libprotobuf-lite.a libprotobuf.a pkgconfig

Note that if I change the NO_DEFAULT_PATH specification in the find_library
line to NO_CMAKE_FIND_ROOT_PATH everything works as expected and the libs
are found and linked (and I know its the right libs because things also
run).

Is this a bug or is there something I don't understand about
NO_DEFAULT_PATH?

Thanks,
Oliver

PS: I know the hard coded full path names are odd - the CMakeLists.txt
files are actually generated -- it's a long story.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180327/4391c09a/attachment.html>


More information about the CMake mailing list