[CMake] Better BlueGene/P and cross-compile support for CMake
Brad King
brad.king at kitware.com
Fri Jun 25 15:06:00 EDT 2010
Alexander Neundorf wrote:
> On Wednesday 23 June 2010, Todd Gamblin wrote:
>> 3a. First, using this setup, FindMPI fails because the last library it
>> needs is in /bgsys/drivers/ppcfloor/runtime/SPI, not
>> /bgsys/drivers/ppcfloor/runtime/SPI/lib. CMAKE_FIND_ROOT_PATH seems to
>> assume that its elements are just above a lib directory, but that's not how
>> things are structured on BG/P (you can blame IBM). So, if I just use the
>> root path for searching, find_library fails for libs in runtime/SPI.
>
> I guess you need a special Platform/BlueGeneP.cmake file, which not simply
> includes UnixPaths.cmake, but sets some special directories.
> Please add a bug report for this on http://public.kitware.com/Bug/ too.
Good idea. There is a distinction to understand here:
(1) CMAKE_FIND_ROOT_PATH is meant for cross-compiling and should
appear only in toolchain files. It re-roots all search paths.
Usually the goal is to find libraries only from the target
platform SDK (and not the host), which is why we suggest using
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
Typically CMAKE_FIND_ROOT_PATH should be set to the *top* of the
SDK tree, such as "/bgsys/drivers/ppcfloor" in your case.
(2) CMAKE_SYSTEM_PREFIX_PATH, CMAKE_SYSTEM_LIBRARY_PATH, and
similar variables are meant for controlling the search *within*
the target platform SDK to find different types of files. See
help for find_library, find_program, and find_path for specific
details. This is where the "<prefix>/lib" assumption occurs:
- find_library looks in <CMAKE_SYSTEM_PREFIX_PATH>/lib
- find_library looks in CMAKE_SYSTEM_LIBRARY_PATH, but the
Modules/Platform/UnixPaths.cmake file sets this variable
with "/lib" at the end of most of its paths.
What Alex suggests is to create a Modules/Platform/BlueGeneP.cmake
file that defines CMAKE_SYSTEM_LIBRARY_PATH to something like
/runtime/SPI
and other paths relative to CMAKE_FIND_ROOT_PATH entries. This
tells CMake how to find libraries within the target platform SDK.
IIRC, you can try this out by setting CMAKE_SYSTEM_LIBRARY_PATH
directly in your toolchain file, but I do not remember for sure
if it works there.
-Brad
More information about the CMake
mailing list