<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(&quot;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(&quot;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>