[CMake] Fwd: module and cmake

Paul Anton Letnes paul.anton.letnes at gmail.com
Sat May 19 08:42:49 EDT 2012


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:
paulanto at rocks:~/Rayleigh2D $ module avail fftw
fftw/2.1.5          fftw/3.2.2(default)
So, there's two different fftw versions available, and I'm currently
using the default one as such:
paulanto at rocks:~/Rayleigh2D $ module load fftw
paulanto at rocks:~/Rayleigh2D $ module list
Currently Loaded Modulefiles:
 1) fftw/3.2.2
There we go. Now what does it mean to load a module? Well, basically,
the "module" command works by adjusting environment variables:
paulanto at rocks:~/Rayleigh2D $ module show fftw
/share/apps/modulefiles/fftw/3.2.2:
prepend-path     CPATH /share/apps/modulessoftware/fftw/fftw-3.2.2/include
prepend-path     FPATH /share/apps/modulessoftware/fftw/fftw-3.2.2/include
prepend-path     LD_LIBRARY_PATH
/share/apps/modulessoftware/fftw/fftw-3.2.2/lib
prepend-path     LIBRARY_PATH /share/apps/modulessoftware/fftw/fftw-3.2.2/lib
We see that the fftw module sets various paths, and that these will
all be different based on the exact version I'm using on the current
machine. Hence, I can't tell beforehand, in my CMakeLists.txt, where
to search for, say, libfftw3.a.

So why am i ranting on about this? Well, basically
find_package(FFTW3)
does not find the fftw library, 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
up and want to use the more elegant find_package approach, at least
where possible. So, what am I asking?
1) Is there a standard way for CMake to interact with "modules"?
2) Is there a standard way to tell FindXXX.cmake (where XXX=fftw,
hdf5, mkl, etc) where to search for libraries?
3) Can I convince CMake to include link and include directores from
the environment variables, like LIBRARY_PATH, FPATH etc?
4) How do I handle LIBRARY_PATHs with multiple entries, such as this one?
paulanto at rocks:~/Rayleigh2D $ echo $LIBRARY_PATH
/share/apps/modulessoftware/fftw/fftw-3.2.2/lib:/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib:/share/apps/modulessoftware/openmpi/openmpi-1.4.3-intel/lib:/share/apps/modulessoftware/intel/compilers/11.1.059/lib/intel64:/share/apps/modulessoftware/intel/compilers/11.1.059/ipp/em64t/lib:/share/apps/modulessoftware/intel/compilers/11.1.059//mkl/lib/em64t:/share/apps/modulessoftware/intel/compilers/11.1.059/tbb/intel64/cc4.1.0_libc2.4_kernel2.6.16.21/lib

Perhaps I'm not asking the right questions, but hopefully, some can
tell me what I _should_ be asking. Or even better, the answer.

Cheers
Paul

[0] High Performance Computing
[1] http://modules.sourceforge.net/


More information about the CMake mailing list