<div dir="ltr">Can you post your toolchain file as well?  Does it set any of the CMAKE_FIND_ROOT_PATHG_MODE_{INCLUDE,PROGRAM,LIBRARY,PACKAGE} variables to anything?<br></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">- Chuck<br></div></div>
<br><div class="gmail_quote">On Wed, Oct 15, 2014 at 10:04 AM, Guillaume Papin <span dir="ltr"><<a href="mailto:guillaume.papin@parrot.com" target="_blank">guillaume.papin@parrot.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello CMake developers,<br>
<br>
I have a cross-compiled version of Boost and some other libraries under ~/my-project/CrossThirdPartyPrefix.<br>
<br>
I invoke CMake with a CMAKE_TOOLCHAIN_FILE and also I sets CMAKE_FIND_ROOT_PATH<br>
to the directory where my cross-compiled Boost is installed.<br>
<br>
    cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/my-project/plateforms/arm-toolchain.cmake \<br>
        -DCMAKE_FIND_ROOT_PATH=$HOME/my-project/CrossThirdPartyPrefix \<br>
        ~/my-projects/src/<br>
<br>
But I have an error when using FindBoost.cmake:<br>
<br>
In my project's CMakeLists.txt:<br>
    find_package(Boost 1.53.0 REQUIRED COMPONENTS atomic thread system)<br>
<br>
The error:<br>
     CMake Error at .../share/cmake-3.0/Modules/FindBoost.cmake:1179 (message):<br>
       Unable to find the requested Boost libraries.<br>
<br>
       Boost version: 1.55.0<br>
<br>
       Boost include path:<br>
       ~/myproject/CrossThirdPartyPrefix/include<br>
<br>
<br>
       Could not find the following Boost libraries:<br>
<br>
               boost_thread<br>
               boost_system<br>
<br>
       Some (but not all) of the required Boost libraries were found.  You may<br>
       need to install these additional Boost libraries.  Alternatively, set<br>
       BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT<br>
       to the location of Boost.<br>
<br>
<br>
So the first component library (atomic) is found but not the other ones.<br>
<br>
Looking at the code, when the first library is found, Boost_LIBRARY_DIR is set<br>
to the directory that contains the library and then change the further calls of<br>
find_library to use Boost_LIBRARY_DIR as the unique HINTS, and with the<br>
NO_DEFAULT_PATH options set.<br>
<br>
    macro(_Boost_FIND_LIBRARY var)<br>
      find_library(${var} ${ARGN})<br>
<br>
      if(${var})<br>
        # If this is the first library found then save Boost_LIBRARY_DIR.<br>
        if(NOT Boost_LIBRARY_DIR)<br>
          get_filename_component(_dir "${${var}}" PATH)<br>
          set(Boost_LIBRARY_DIR "${_dir}" CACHE PATH "Boost library directory" FORCE)<br>
        endif()<br>
      elseif(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)<br>
        # Try component-specific hints but do not save Boost_LIBRARY_DIR.<br>
        find_library(${var} HINTS ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT} ${ARGN})<br>
      endif()<br>
<br>
      # If Boost_LIBRARY_DIR is known then search only there.<br>
      if(Boost_LIBRARY_DIR)<br>
        set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH)<br>
      endif()<br>
    endmacro()<br>
<br>
* <a href="https://github.com/Kitware/CMake/blob/1b3495d32e1523648da08e138482a654f8765333/Modules/FindBoost.cmake#L322-L325" target="_blank">https://github.com/Kitware/CMake/blob/1b3495d32e1523648da08e138482a654f8765333/Modules/FindBoost.cmake#L322-L325</a><br>
<br>
The issue is that, when using CMAKE_FIND_ROOT_PATH, the Boost_LIBRARY_DIR of the<br>
host (~/myproject/CrossThirdPartyPrefix/lib/ in my case), will be expanded against the root paths.<br>
<br>
To find my libraries I can apply the following fix but I'm not sure if it's the<br>
right solution or not.<br>
<br>
    diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake<br>
    index 3642b3e..aad6575 100644<br>
    --- a/Modules/FindBoost.cmake<br>
    +++ b/Modules/FindBoost.cmake<br>
    @@ -321,7 +321,7 @@ macro(_Boost_FIND_LIBRARY var)<br>
<br>
       # If Boost_LIBRARY_DIR is known then search only there.<br>
       if(Boost_LIBRARY_DIR)<br>
    -    set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH)<br>
    +    set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)<br>
       endif()<br>
     endmacro()<br>
<br>
    @@ -855,7 +855,7 @@ if(_Boost_CHANGE_LIBDIR AND NOT _Boost_LIBRARY_DIR_CHANGED)<br>
     endif()<br>
<br>
     if(Boost_LIBRARY_DIR)<br>
    -  set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH)<br>
    +  set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)<br>
     else()<br>
       set(_boost_LIBRARY_SEARCH_DIRS "")<br>
       if(BOOST_LIBRARYDIR)<br>
<br>
<br>
What I'm wondering is, whether or not Boost_LIBRARY_DIR should be a path on the target or on the host?<br>
<br>
Right now, the workaround I have that doesn't require to modify FindBoost.cmake<br>
is to set Boost_LIBRARY_DIR to /lib/, which will be expanded against the CMAKE_FIND_ROOT_PATH.<br>
<br>
By the way, I'm a happy CMake user, thanks for all the work!<br>
Guillaume<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake-developers" target="_blank">http://public.kitware.com/mailman/listinfo/cmake-developers</a><br>
</blockquote></div><br></div>