<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>With a bit of thought and source code reading, I sorted this out. Let me know if you'd like me to post my answer to my own question.</div><div><br></div><div>Matt</div><div><br>On Jan 1, 2014, at 11:13 AM, Matt Wilbur <<a href="mailto:wilburm@gmail.com">wilburm@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">Hello CMakers,</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">I’m seeing behavior with find_path that seems to be inconsistent with the cmake documentation. According to the documentation (as I understand it), when NO_DEFAULT_PATH is set, the CMAKE_FIND_ROOT_PATH should have no impact on where find_path looks. However it seems to be having a big impact when the CMAKE_TOOLCHAIN_FILE is used. </div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">You’ll see between Experiment 2 and Experiment 3 below, where the only difference is setting </div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">and this means the difference between success and failure of find_path, even though CMAKE_FIND_ROOT_PATH should have no impact if NO_DEFAULT_PATH is used.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Furthermore CMAKE_FIND_ROOT_PATH_MODE_INCLUDE seems to have this impact only when cross-compiling, not when </div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thoughts? Is this behavior seem odd to anyone else?</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Matt</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Experiment 1:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">CMakeLists.txt:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>cmake_minimum_required(VERSION 2.8)</div><div>set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</div><div>find_path(ZLIB_INCLUDE_DIR NAMES zlib.h PATHS /home/vagrant/Projects/cmake-test/zlib-1.2.8 NO_DEFAULT_PATH)</div>
<div>message("Found: ${ZLIB_INCLUDE_DIR}”)</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Output from cmake:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">cmake ..</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>-- The C compiler identification is GNU 4.6.3</div>
<div>-- The CXX compiler identification is GNU 4.6.3</div><div>-- Check for working C compiler: /usr/bin/cc</div><div>-- Check for working C compiler: /usr/bin/cc -- works</div><div>-- Detecting C compiler ABI info</div><div>
-- Detecting C compiler ABI info - done</div><div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div><div>-- Detecting CXX compiler ABI info - done</div>
<div>Found: /home/vagrant/Projects/cmake-test/zlib-1.2.8</div><div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: /home/vagrant/Projects/another-cmake-test/build</div></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Experiment 2:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
CMakeLists.txt: same as above</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Toolchain file: </div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><div># this one is important</div><div>SET(CMAKE_SYSTEM_NAME Linux)</div><div><br></div><div># specify the cross compiler</div><div>set(CMAKE_C_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc)</div>
<div>set(CMAKE_CXX_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++)</div><div><br></div><div># where is the target environment</div><div>set(CMAKE_FIND_ROOT_PATH /opt/freescale-2010.09)</div><div><br></div><div>
# search for programs in the build host directories</div><div>SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)</div><div># for libraries and headers in the target directories</div><div>SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)</div>
<div>SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Output from cmake:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>-- The C compiler identification is GNU 4.5.1</div><div>-- The CXX compiler identification is GNU 4.5.1</div><div>-- Check for working C compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc</div>
<div>-- Check for working C compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc -- works</div><div>-- Detecting C compiler ABI info</div><div>-- Detecting C compiler ABI info - done</div><div>-- Check for working CXX compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++</div>
<div>-- Check for working CXX compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++ -- works</div><div>-- Detecting CXX compiler ABI info</div><div>-- Detecting CXX compiler ABI info - done</div><div>Found: ZLIB_INCLUDE_DIR-NOTFOUND</div>
<div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: /home/vagrant/Projects/another-cmake-test/build</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br>
</div><div style="font-family:arial,sans-serif;font-size:13px">Experiment 3:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">CMakeLists.txt:</div>
<div style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>cmake_minimum_required(VERSION 2.8)</div><div><br></div><div>find_path(ZLIB_INCLUDE_DIR NAMES zlib.h PATHS /home/vagrant/Projects/cmake-test/zlib-1.2.8 NO_DEFAULT_PATH)</div>
<div>message("Found: ${ZLIB_INCLUDE_DIR}”)</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Toolchain file:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><div> this one is important</div><div>SET(CMAKE_SYSTEM_NAME Linux)</div><div><br></div><div># specify the cross compiler</div><div>set(CMAKE_C_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc)</div>
<div>set(CMAKE_CXX_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++)</div><div><br></div><div># where is the target environment</div><div>set(CMAKE_FIND_ROOT_PATH /opt/freescale-2010.09)</div><div><br></div><div>
# search for programs in the build host directories</div><div>SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)</div><div># for libraries and headers in the target directories</div><div>SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)</div>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Output from cmake:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div>
<div style="font-family:arial,sans-serif;font-size:13px"><div>cmake -DCMAKE_TOOLCHAIN_FILE=../TC-powerpc-e500v2.cmake ..</div><div><br></div><div>-- The C compiler identification is GNU 4.5.1</div><div>-- The CXX compiler identification is GNU 4.5.1</div>
<div>-- Check for working C compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc</div><div>-- Check for working C compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc -- works</div><div>-- Detecting C compiler ABI info</div>
<div>-- Detecting C compiler ABI info - done</div><div>-- Check for working CXX compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++</div><div>-- Check for working CXX compiler: /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++ -- works</div>
<div>-- Detecting CXX compiler ABI info</div><div>-- Detecting CXX compiler ABI info - done</div><div>Found: /home/vagrant/Projects/cmake-test/zlib-1.2.8</div><div>-- Configuring done</div><div>-- Generating done</div><div>
-- Build files have been written to: /home/vagrant/Projects/another-cmake-test/build</div></div></div>
</div></blockquote><blockquote type="cite"><div><span>--</span><br><span></span><br><span>Powered by <a href="http://www.kitware.com">www.kitware.com</a></span><br><span></span><br><span>Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a></span><br><span></span><br><span>Kitware offers various services to support the CMake community. For more information on each offering, please visit:</span><br><span></span><br><span>CMake Support: <a href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a></span><br><span>CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a></span><br><span>CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a></span><br><span></span><br><span>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br><span><a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a></span></div></blockquote></body></html>