[CMake] CMAKE_FIND_ROOT_PATH don't work as expected.
Diego
deldie at gmail.com
Wed Apr 14 10:25:32 EDT 2010
2010/4/13 Alexander Neundorf <a.neundorf-work at gmx.net>
> On Tuesday 13 April 2010, Diego wrote:
> > 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?
>
> Without testing it...
>
> You set CMAKE_SYSTEM_NAME to "Generic", so Modules/Platforms/Generic.cmake
> is
> loaded. This file looks like this:
>
> ---------8<----------------8<-----------------------8<---------------
> # This is a platform definition file for platforms without
> # operating system, typically embedded platforms.
> # It is used when CMAKE_SYSTEM_NAME is set to "Generic"
> #
> # It is intentionally empty, since nothing is known
> # about the platform. So everything has to be specified
> # in the system/compiler files
> ${CMAKE_SYSTEM_NAME}-<compiler_basename>.cmake
> # and/or
> ${CMAKE_SYSTEM_NAME}-<compiler_basename>-${CMAKE_SYSTEM_PROCESSOR}.cmake
>
> # (embedded) targets without operating system usually don't support shared
> libraries
> SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
>
> ---------8<----------------8<-----------------------8<---------------
>
> IOW, it doesn't load e.g. UnixPaths.cmake, so CMAKE_SYSTEM_INCLUDE_PATH is
> empty.
> Maybe it would be a good idea to add at least include/, lib/ and bin/ as
> default search paths in Generic.cmake.
>
> Can you append the following code to Generic.cmake and see if it works then
> ?
>
> SET(CMAKE_SYSTEM_INCLUDE_PATH /include "${CMAKE_INSTALL_PREFIX}/include")
> SET(CMAKE_SYSTEM_LIBRARY_PATH /lib "${CMAKE_INSTALL_PREFIX}/lib")
> SET(CMAKE_SYSTEM_PROGRAM_PATH /bin "${CMAKE_INSTALL_PREFIX}/bin")
>
>
> Alex
>
Yes, it works now!
The CMAKE_FIND_ROOT_PATH variable it seems isn't really necessary (??).
Thank you very much by the info about the Modules/Platform/ directory :) and
by your help.
Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100414/9057ab03/attachment.htm>
More information about the CMake
mailing list