<br><br><div class="gmail_quote">2010/4/13 Alexander Neundorf <span dir="ltr">&lt;<a href="mailto:a.neundorf-work@gmx.net">a.neundorf-work@gmx.net</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Tuesday 13 April 2010, Diego wrote:<br>
&gt; Hello,<br>
&gt; I&#39;m trying to cross-compiling a library for the PSP platform, this is my<br>
&gt; toolchain:<br>
&gt;<br>
&gt; *# The name of the target operating system.<br>
&gt; set(CMAKE_SYSTEM_NAME Generic)<br>
&gt;<br>
&gt; # Which compilers to use for C and C++.<br>
&gt; set(CMAKE_C_COMPILER /usr/local/pspdev/bin/psp-gcc)<br>
&gt; set(CMAKE_CXX_COMPILER /usr/local/pspdev/bin/psp-g++)<br>
&gt;<br>
&gt; set(CMAKE_FIND_ROOT_PATH /usr/local/pspdev/psp)<br>
&gt;<br>
&gt; # Adjust the default behaviour of the FIND_XXX() commands:<br>
&gt; # search headers and libraries in the target environment, search<br>
&gt; # programs in the host environment.<br>
&gt; set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)<br>
&gt; set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)<br>
&gt; set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)*<br>
&gt;<br>
&gt;<br>
&gt; And this is the code (from CmakeLists.txt) to find the zlib.h header<br>
&gt; located in /usr/local/pspdev/psp/include:<br>
&gt;<br>
&gt; *cmake_minimum_required(VERSION 2.6 FATAL_ERROR)<br>
&gt; if(COMMAND cmake_policy)<br>
&gt;     cmake_policy(SET CMP0003 NEW)<br>
&gt; endif(COMMAND cmake_policy)<br>
&gt;<br>
&gt; if(NOT CMAKE_BUILD_TYPE)<br>
&gt;   set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING<br>
&gt;       &quot;Choose the type of build, options are:<br>
&gt;         None Debug Release RelWithDebInfo MinSizeRel Profile.&quot;<br>
&gt;       FORCE)<br>
&gt; endif()<br>
&gt; # Restrict configuration types to the selected build type.<br>
&gt; # Note: This needs to be done before the project command<br>
&gt; set(CMAKE_CONFIGURATION_TYPES &quot;${CMAKE_BUILD_TYPE}&quot; CACHE INTERNAL<br>
&gt; &quot;internal&quot;)<br>
&gt;<br>
&gt; # Set the project name.<br>
&gt; project(MyLibrary C CXX)<br>
&gt;<br>
&gt; FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)<br>
&gt;<br>
&gt; message(STATUS &quot;zlib include dir ${ZLIB_INCLUDE_DIR}&quot;)*<br>
&gt;<br>
&gt; It returns not found but it should.<br>
&gt;<br>
&gt; Setting *CMAKE INCLUDE_PATH* to */usr/local/pspdev/psp/include *(and<br>
&gt; commenting the line set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) works as<br>
&gt; expected.<br>
&gt;<br>
&gt; What I&#39;m doing wrong?<br>
<br>
</div></div>Without testing it...<br>
<br>
You set CMAKE_SYSTEM_NAME to &quot;Generic&quot;, so Modules/Platforms/Generic.cmake is<br>
loaded. This file looks like this:<br>
<br>
---------8&lt;----------------8&lt;-----------------------8&lt;---------------<br>
# This is a platform definition file for platforms without<br>
# operating system, typically embedded platforms.<br>
# It is used when CMAKE_SYSTEM_NAME is set to &quot;Generic&quot;<br>
#<br>
# It is intentionally empty, since nothing is known<br>
# about the platform. So everything has to be specified<br>
# in the system/compiler files ${CMAKE_SYSTEM_NAME}-&lt;compiler_basename&gt;.cmake<br>
# and/or<br>
${CMAKE_SYSTEM_NAME}-&lt;compiler_basename&gt;-${CMAKE_SYSTEM_PROCESSOR}.cmake<br>
<br>
# (embedded) targets without operating system usually don&#39;t support shared<br>
libraries<br>
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)<br>
<br>
---------8&lt;----------------8&lt;-----------------------8&lt;---------------<br>
<br>
IOW, it doesn&#39;t load e.g. UnixPaths.cmake, so CMAKE_SYSTEM_INCLUDE_PATH is<br>
empty.<br>
Maybe it would be a good idea to add at least include/, lib/ and bin/ as<br>
default search paths in Generic.cmake.<br>
<br>
Can you append the following code to Generic.cmake and see if it works then ?<br>
<br>
SET(CMAKE_SYSTEM_INCLUDE_PATH /include &quot;${CMAKE_INSTALL_PREFIX}/include&quot;)<br>
SET(CMAKE_SYSTEM_LIBRARY_PATH /lib &quot;${CMAKE_INSTALL_PREFIX}/lib&quot;)<br>
SET(CMAKE_SYSTEM_PROGRAM_PATH /bin &quot;${CMAKE_INSTALL_PREFIX}/bin&quot;)<br>
<br>
<br>
Alex<br>
</blockquote></div><br>Yes, it works now!<br>The CMAKE_FIND_ROOT_PATH variable it seems isn&#39;t 
really necessary (??).<br><br>Thank you very much by the info about the 
Modules/Platform/ directory :) and by your help.<br>
<br>Best regards.<br>