[CMake] CMAKE_FIND_ROOT_PATH and find_library()

Ted Middleton middleton.ted at gmail.com
Thu Jul 10 13:55:36 EDT 2014


I'm using cmake 3.0.0 on win7 64-bit and I'm having a difficult time with
CMAKE_FIND_ROOT_PATH. The cross-compiling cmake page as well as the
find_library() docs seem to suggest that if CMAKE_FIND_ROOT_PATH is
non-empty, find_library() will use it to prepend any paths it searches,
sort of like an alternate sysroot? But that doesn't seem to be happening in
my set-up and I can't figure out why? When I run this:

   cmake_minimum_required( VERSION 3.0 )
   project( "cmakefindlibtest" )
   list( APPEND CMAKE_FIND_ROOT_PATH "C:/DEV/lib" )
   find_library( punycode_library_test punycode  )
   message( "punycode_library_test is now ${punycode_library_test}" )

In this case, ${punycode_library_test} ends up being
punycode_library_test-NOTFOUND. I thought that maybe this was because my
CMAKE_LIBRARY_PATH was empty - perhaps the problem here is that
find_library() doesn't have any paths to prepend with CMAKE_FIND_ROOT_PATH
in the first place, so I tried this:

   cmake_minimum_required( VERSION 3.0 )
   project( "cmakefindlibtest" )
   list( APPEND CMAKE_FIND_ROOT_PATH "C:/DEV/" )
   list( APPEND CMAKE_LIBRARY_PATH "lib" )
   find_library( punycode_library_test punycode  )
   message( "punycode_library_test is now ${punycode_library_test}" )

This doesn't work either, and neither does

    cmake_minimum_required( VERSION 3.0 )
    project( "cmakefindlibtest" )
    list( APPEND CMAKE_FIND_ROOT_PATH "C:/DEV/" )
    find_library( punycode_library_test punycode PATHS "lib" )
    message( "punycode_library_test is now ${punycode_library_test}" )

When I specify PATHS "C:/DEV/lib" to find_library(), or I add "C:/DEV/lib"
to CMAKE_LIBRARY_PATH, I can find the punycode.lib sitting in my C:/DEV/lib
directory, but I'd like to know what's going wrong with
CMAKE_FIND_ROOT_PATH because I'm trying to use it for cross-compiling and
it doesn't seem to be doing anything the way that I'm using it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140710/1baa987b/attachment.html>


More information about the CMake mailing list