[CMake] (no subject)

Matt Wilbur wilburm at gmail.com
Wed Jan 1 11:13:08 EST 2014


Hello CMakers,

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.

You’ll see between Experiment 2 and Experiment 3 below, where the only
difference is setting

set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

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.

Furthermore CMAKE_FIND_ROOT_PATH_MODE_INCLUDE seems to have this impact
only when cross-compiling, not when

Thoughts?  Is this behavior seem odd to anyone else?

Matt


Experiment 1:

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
find_path(ZLIB_INCLUDE_DIR NAMES zlib.h PATHS
/home/vagrant/Projects/cmake-test/zlib-1.2.8 NO_DEFAULT_PATH)
message("Found: ${ZLIB_INCLUDE_DIR}”)

Output from cmake:

cmake ..

-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found: /home/vagrant/Projects/cmake-test/zlib-1.2.8
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/vagrant/Projects/another-cmake-test/build

Experiment 2:

CMakeLists.txt:  same as above

Toolchain file:

# this one is important
SET(CMAKE_SYSTEM_NAME Linux)

# specify the cross compiler
set(CMAKE_C_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++)

# where is the target environment
set(CMAKE_FIND_ROOT_PATH /opt/freescale-2010.09)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Output from cmake:

-- The C compiler identification is GNU 4.5.1
-- The CXX compiler identification is GNU 4.5.1
-- Check for working C compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc
-- Check for working C compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-g++
-- Check for working CXX compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found: ZLIB_INCLUDE_DIR-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/vagrant/Projects/another-cmake-test/build

Experiment 3:

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

find_path(ZLIB_INCLUDE_DIR NAMES zlib.h PATHS
/home/vagrant/Projects/cmake-test/zlib-1.2.8 NO_DEFAULT_PATH)
message("Found: ${ZLIB_INCLUDE_DIR}”)

Toolchain file:

 this one is important
SET(CMAKE_SYSTEM_NAME Linux)

# specify the cross compiler
set(CMAKE_C_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /opt/freescale-2010.09/bin/powerpc-linux-gnu-g++)

# where is the target environment
set(CMAKE_FIND_ROOT_PATH /opt/freescale-2010.09)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)

Output from cmake:

cmake -DCMAKE_TOOLCHAIN_FILE=../TC-powerpc-e500v2.cmake ..

-- The C compiler identification is GNU 4.5.1
-- The CXX compiler identification is GNU 4.5.1
-- Check for working C compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc
-- Check for working C compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-g++
-- Check for working CXX compiler:
/opt/freescale-2010.09/bin/powerpc-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found: /home/vagrant/Projects/cmake-test/zlib-1.2.8
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/vagrant/Projects/another-cmake-test/build
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140101/8069a354/attachment.htm>


More information about the CMake mailing list