[CMake] Fwd: module and cmake

Eric Noulard eric.noulard at gmail.com
Sat May 19 09:39:33 EDT 2012


2012/5/19 Rolf Eike Beer <eike at sf-mail.de>:
> Am Samstag, 19. Mai 2012, 14:42:49 schrieb Paul Anton Letnes:
>> Hi all.
>>
>> I am currently trying to create a more tidy CMakeLists.txt script for
>> a simulation code I'm working on. The target platforms are mac and
>> linux desktops (for development) and HPC [0] servers (all linux or, in
>> some hypothetical future, unix systems). For the desktop/laptop case,
>> it's mostly easy enough, as one installs libraries in a standard
>> location - /opt, /usr/local, or something of that sort. On HPC
>> servers, it is very common to install software in "modules". I am not
>> sure how well aquainted the CMake crowd is with the module system [1]
>> so I'll post a brief explanation.
>>
>> HPC servers often have a large amount of users with varying
>> requirements. Therefore, it is common to require, say, two different
>> versions of a library, or the same library for two different
>> compilers. As an example, a machine I'm currently using has several
>> modules for the FFTW library. Example:
>
> [...]
>
>> So why am i ranting on about this? Well, basically
>> find_package(FFTW3)  does not find the fftw library,
>
> This module is not part of CMake, so you should complain somewhere else.

Yes right but may be Paul could have a look at this thread
http://www.cmake.org/pipermail/cmake/2012-January/048742.html

where he can find some explaination about the interaction between
"module system"
and CMake. Since "module" plays with environment variable CMake may
or may not be seing the environment change depending on how it is called.


>> and other libraries I'm using (hdf5,
>> mkl, ...) share the same fate. Previously I've just hand-added all
>> sorts of include_directories and link_directories but I'm getting fed
>
> link_directories() is surely not the solution you need. In fact, it usually
> creates only more problems.
>
> But to have some useful information: set CMAKE_PREFIX_PATH to the path where
> the libraries can be found without the lib/ or include/ suffix, CMake will add
> them itself.

Eike is right and I think you (Paul) should read the documentation of
find_package more carefully:
cmake --help-command find_package

the algorithm used to search library, path, files etc... is explained in there.
After that you can try:

cmake --help-variable CMAKE_PREFIX_PATH
cmake --help-variable CMAKE_INCLUDE_PATH
cmake --help-variable CMAKE_LIBRARY_PATH
cmake --help-variable CMAKE_PROGRAM_PATH
...
Concerning the questions:
>> 1) Is there a standard way for CMake to interact with "modules"?

No, beside the fact that CMake do already use some PATH env var that
module is playing with.

>> 2) Is there a standard way to tell FindXXX.cmake (where XXX=fftw,
>> hdf5, mkl, etc) where to search for libraries?

Yes read find_package documentation.

>> 3) Can I convince CMake to include link and include directores from
>>   the environment variables, like LIBRARY_PATH, FPATH etc?

Yes you can using $ENV{ENV_VAR_NAME} in order to set
some CMAKE_xxx_PATH variable.

>> 4) How do I handle LIBRARY_PATHs with multiple entries, such as this one?

I'm not sure I understand the question?
CMake has builtin list support:
cmake --help-command list
if you replace the ":" by a ";"
(see cmake --help-command string)
you'll get a CMake list and can use it in CMAKE_xxxx_PATH var.


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list