[CMake] CMAKE_FIND_ROOT_PATH and find_library()

Ted Middleton middleton.ted at gmail.com
Mon Jul 14 17:22:50 EDT 2014


I've tried this again, but on OSX. The first example,

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

doesn't work - perhaps because find_library() doesn't have any paths to
prepend with CMAKE_FIND_ROOT_PATH? But this,

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

and this,

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

DO work, as expected. Should I raise a bug for the Windows version? Is the
first example supposed to work too?






On Thu, Jul 10, 2014 at 10:55 AM, Ted Middleton <middleton.ted at gmail.com>
wrote:

> 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/20140714/5f70eb9e/attachment-0001.html>


More information about the CMake mailing list