[CMake] Re: Find* and cross compiling
Alexander Neundorf
a.neundorf-work at gmx.net
Sat Dec 29 11:39:58 EST 2007
On Saturday 29 December 2007, Rodolfo Schulz de Lima wrote:
> > By setting the mode to ONLY cmake will look ONLY in the directories with
> > the
> > CMAKE_FIND_ROOT_PATH prefix.
>
> Yes, I do this. The problem is that those scripts hardwire some default
> paths to the native places where headers and libraries are found. When we
> cross-compile, those defaults should be changed. If the scripts didn't
> hardwire those default paths, they'd use the correct defaults set up by
> CMake.
>
> For instance, look at what FindOpenAL does:
>
> FIND_PATH(OPENAL_INCLUDE_DIR al.h
> PATHS
> $ENV{OPENALDIR}
> NO_DEFAULT_PATH
> PATH_SUFFIXES include/AL include/OpenAL include
> )
> FIND_PATH(OPENAL_INCLUDE_DIR al.h
> PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
> NO_DEFAULT_PATH
> PATH_SUFFIXES include/AL include/OpenAL include
> )
> FIND_PATH(OPENAL_INCLUDE_DIR al.h
> PATHS
> ~/Library/Frameworks
> /Library/Frameworks
> /usr/local
> /usr
> /sw # Fink
> /opt/local # DarwinPorts
> /opt/csw # Blastwave
> /opt
> [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\
> Development\ Kit\\1.00.0000;InstallDir]
> PATH_SUFFIXES include include/lua51 include/lua5.1 include/lua
> )
Well, cross compiling in cmake is very new, so no script has been written with
cross compiling in mind.
The example above should work, let's say you have
set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
the the command above should search:
/usr/i586-mingw32msvc/include
/usr/i586-mingw32msvc/usr/include
/usr/i586-mingw32msvc/usr/local/include
etc.
> Other native locations (as /sw, /opt/local, /opt/csw) should only be
> searched if not cross-compiling.
/sw, /opt/local and /opt/csw won't be searched when
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM/LIBRARY/INCLUDE are set to "ONLY" in the
toolchain file. If they are searched nevertheless, it is a bug, but I'm quite
sure it should work.
Can you please send me a small test case ?
Alex
More information about the CMake
mailing list