[CMake] Fwd: module and cmake
Johannes Zarl
johannes.zarl at jku.at
Sat May 19 17:11:20 EDT 2012
Hello Paul,
I don't know about your specific find_package file for FFTW, but we do use
modules together with CMake, so I'll add my thoughts:
As Eric already said, the modules command alters your environment. CMake
doesn't know about shell modules, but most find_package commands provide some
way to tell them about the location of a package by specifying an environment
variable (normally something like <PACKAGE>_ROOT or <PACKAGE>_DIR). You'll
have to look in the find-package script if this is the case with your
FindFFTW.cmake script. If it's not written in the documentation on top of that
file, search for "$ENV".
If your FindFFTW3.cmake does not examine any environment variable, you should
fix it in your project (and file a bug with the original project, if it's not
your project). If that's not an option, it's probably best if you just set
whatever variable your findFFTW3.cmake script expects as a clue as parameter
to cmake (e.g. "cmake .. -DFFTW3_INCLUDE_DIR=$FFTW3_ROOT/include").
So in summary, you should fix your module file to provide a suitable variable
pointing to your installation root, and you should also fix poorly written
FindXXX.cmake scripts circulating in the wild.
Somewhat off-topic, because it's got nothing to do with cmake and your
specific problem: it's probably a good idea to prepend PKG_CONFIG_PATH with
the pkgconfig directory of fftw. That way, autotool-based projects will be
able to find it as well.
Cheers,
Johannes
On Saturday 19 May 2012 14:42:49 Paul Anton Letnes wrote:
> 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/intel
> 64:/share/apps/modulessoftware/intel/compilers/11.1.059/ipp/em64t/lib:/shar
> e/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_kernel
> 2.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/
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list