HALMD uses CMake to generate its make files, which is similar to the more commonly used Autotools suite recognisable by the configure script accompanying a software package, but much faster and much easier to develop with.
With cmake, out-of-tree compilation is preferred, so we generate the compilation or build tree in a separate directory. This allows one to have multiple builds of the same software at the same time, for example a release build with aggressive optimisation and a debug build including debugging symbols. Note that the build directory may be a subdirectory in the source tree.
In the cloned HALMD repository, switch to a new build directory:
mkdir -p build/release && cd build/release
If the third-party packages are installed in standard locations, run
cmake ../..
This will detect all necessary software, and then generate the make files. If third-party packages are not found in standard locations, make sure to correctly set the environment variable CMAKE_PREFIX_PATH, see Software prerequisites.
Compilation is done using make, which supports parallel builds:
nice make -j4
The default installation directory is /usr/local, which may be adjusted by invoking
cmake -DCMAKE_INSTALL_PREFIX=$HOME/opt/halmd-version ../..
For compilation and subsequent installation type:
nice make -j4 install
Compilation flags may be configured via CMake’s text mode interface:
ccmake .
To finish configuration, hit “c” and “g” to apply and recompile with make. Alternatively, you may use CMake’s graphical interface:
cmake-gui .
The following switch displays the actual commands invoked by make:
CMAKE_VERBOSE_MAKEFILE ON
An installation prefix may be specified as following:
CMAKE_INSTALL_PREFIX /your/home/directory/usr
The compiled program is then installed into this tree by
nice make -j4 install
After checking out to a different version (or more recent Git commit), switch to the build directory (e.g., build/release) and run:
cmake .
This instructs CMake to regenerate the build tree using the configuration from the previous run of CMake. Then compile with make as usual.
Parameters may be passed to cmake as environment variables or cache variables.
Environment variables are prepended to the cmake command:
CXXFLAGS="-fPIC -Wall" cmake ../..
Useful environment variables for CMake
Cache variables are appended using the -D option:
cmake -DCMAKE_BUILD_TYPE=Release ../..
The following example demonstrates how to compile separate, dynamically linked executables for each backend, which are statically linked to all libraries except the standard C and C++ libraries:
CXXFLAGS="-fPIC -Wall"
NVCCFLAGS="-Xcompiler -fPIC -Xptxas -v -arch sm_12" \
cmake \
-DCMAKE_BUILD_TYPE=Release \
../..
The options given here correspond to the default values.
HALMD includes an extensive, preliminary test suite, which may be started in the build tree by
ctest
HALMD is known to compile with these C++ compilers.
GCC 4.6
GCC 4.4
Note that CUDA ≤ 3.0 is not compatible with GCC 4.4.
GCC 4.3
GCC 4.1
Clang 2.8
Intel C++ compiler
XL C++
The following C++ compilers fail to compile HALMD.