[CMake] CMAKE_FIND_ROOT_PATH don't work as expected.

Diego deldie at gmail.com
Mon Apr 12 19:06:22 EDT 2010


Hello,
I'm trying to cross-compiling a library for the PSP platform, this is my
toolchain:

*# The name of the target operating system.
set(CMAKE_SYSTEM_NAME Generic)

# Which compilers to use for C and C++.
set(CMAKE_C_COMPILER /usr/local/pspdev/bin/psp-gcc)
set(CMAKE_CXX_COMPILER /usr/local/pspdev/bin/psp-g++)

set(CMAKE_FIND_ROOT_PATH /usr/local/pspdev/psp)

# Adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)*


And this is the code (from CmakeLists.txt) to find the zlib.h header located
in /usr/local/pspdev/psp/include:

*cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
if(COMMAND cmake_policy)
    cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
      "Choose the type of build, options are:
        None Debug Release RelWithDebInfo MinSizeRel Profile."
      FORCE)
endif()
# Restrict configuration types to the selected build type.
# Note: This needs to be done before the project command
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE INTERNAL
"internal")

# Set the project name.
project(MyLibrary C CXX)

FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)

message(STATUS "zlib include dir ${ZLIB_INCLUDE_DIR}")*

It returns not found but it should.

Setting *CMAKE INCLUDE_PATH* to */usr/local/pspdev/psp/include *(and
commenting the line set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) works as
expected.

What I'm doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100413/24a7b7f0/attachment.htm>


More information about the CMake mailing list