Building HAL’s MD package¶
Compilation and Installation¶
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.
Setting up the build 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
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
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
Further CMake configuration¶
Compilation flags may be configured via CMake’s text mode interface:
To finish configuration, hit “c” and “g” to apply and recompile with make. Alternatively, you may use CMake’s graphical interface:
The following switch displays the actual commands invoked by make:
An installation prefix may be specified as following:
The compiled program is then installed into this tree by
nice make -j4 install
Updating the build tree¶
After checking out to a different version (or more recent Git commit), switch
to the build directory (e.g.,
build/release) and run:
This instructs CMake to regenerate the build tree using the configuration from the
previous run of CMake. Then compile with
make as usual.
Setting build parameters¶
Parameters may be passed to cmake as environment variables or cache variables.
Environment variables are prepended to the cmake command:
CXXFLAGS="-fPIC -Wall" 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
HALMD requires a C++ compiler with sufficient C++11 support. Building has been tested with the following compilers:
- GCC 5.1.0 (upstream) on openSuSE 12.3 (x86_64) and CentOS 6.3 (x86_64)
- GCC 4.9.2, 4.8.2 (upstream) on openSuSE 12.3 (x86_64) and CentOS 6.3 (x86_64)
- GCC 4.7.3 (upstream) on CentOS 6.3 (x86_64)
- GCC 4.7.2 on openSuSE 12.3 (x86_64)
- GCC 4.6.2 on openSuSE 12.1 (x86_64)
Building with GCC ≥ 5.1 requires the macro definition
_GLIBCXX_USE_CXX11_ABI=0, which may be passed via the environment variable
CXXFLAGS=-D …. For the background, see GCC Dual ABI.
- Clang 3.6.0 (upstream) on openSuSE 12.3 (x86_64)
- Clang 3.5.0, 3.4, 3.3, 3.2 (upstream) on openSuSE 12.3 (x86_64) and CentOS 6.3 (x86_64)
The following C++ compilers fail to build HALMD:
- GCC ≤ 4.5
- Clang ≤ 2.7
- Clang 2.7 on Debian GNU/Linux squeeze (x86_64)
- Intel C++ compiler ≤ 14.0
- XL C++