4.2. Building OpenFAST with CMake on Linux and Mac¶
We describe here how to install OpenFAST (or any of its modules) using the CMake
build system on Linux or Mac OS systems. Separate CMake documentation is
provided for Windows Cygwin users: see Section 4.4. Also, some template
build scripts are available in openfast/share
.
4.2.1. Required software for building OpenFAST¶
In order to build OpenFAST using CMake, one needs the following minimum set of packages installed:
- Fortran compiler (GNU compiler version above 4.6.0 or Intel compiler version above 11)
- C/C++ compiler
- GNU Make (version 3.81 or later)
- CMake (version 2.8.12 or later)
4.2.2. OpenFAST third-party-library (TPL) dependencies¶
OpenFAST has the following dependencies:
- LAPACK libraries. Users should set
BLAS_LIBRARIES
andLAPACK_LIBRARIES
appropriately for CMake if the library is not found in standard paths. Use BLASLIB as an example when using Intel MKL. - Optional: For the C++ API, HDF5 (provided by
HDF5_ROOT
) and yaml-cpp (provided byYAML_ROOT
) - Optional: For the testing framework, Python 3+
4.2.3. CMake build instructions¶
If one has the appropriate TPLs, CMake, and git installed, obtaining and building OpenFAST can be accomplished as follows:
# obtain the source code; e.g., from the command line using git:
git clone https://github.com/OpenFAST/OpenFAST.git
# go to the OpenFAST directory
cd OpenFAST
# create a directory called `build`
mkdir build
# go to the build directory
cd build
# execute CMake with the default options, which will create a Makefile
cmake ../
# execute a make command (with no target provided, equivalent to `make all`
make
This will build the OpenFAST suite in the build
directory, which can be deleted for a clean build.
There are many Makefile
targets (besides all
), which can be listed via help
:
# list available make targets
make help
# make a specific target, e.g.
make beamdyn_driver
4.2.3.1. Current CMake options¶
Below is a list of current CMake options including their default settings (which will effect, e.g., the targets in a resulting Makefile
.
BUILD_DOCUMENTATION
- Build documentation (Default: OFF)BUILD_FAST_CPP_API
- Enable building OpenFAST - C++ API (Default: OFF)BUILD_SHARED_LIBS
- Enable building shared libraries (Default: OFF)CMAKE_BUILD_TYPE
- Choose the build type: Debug Release (Default: Release)CMAKE_INSTALL_PREFIX
- Install path prefix, prepended onto install directories.DOUBLE_PRECISION
- Treat REAL as double precision (Default: ON)FPE_TRAP_ENABLED
- Enable Floating Point Exception (FPE) trap in compiler options (Default: OFF)ORCA_DLL_LOAD
- Enable OrcaFlex library load (Default: OFF)USE_DLL_INTERFACE
- Enable runtime loading of dynamic libraries (Default: ON)
CMake options can be executed from the command line as, e.g., the CMake command above could be exectuted as
# e.g., to enable Makefile for local building of sphinx-based documentation
cmake -DBUILD_DOCUMENTATION:BOOL=ON ..
# e.g., to compile OpenFAST in single precision
cmake -D:DOUBLE_PRECISION:BOOL=OFF ..
4.2.3.2. Parallel build¶
GNU Make has a parellel build option with the -jobs
or -j
flag, and the OpenFAST
CMake configuration handles setting up the dependencies for Make so the build can be
parallelized. However, it is important to note that the only parallel portion
of the build process is in compiling the modules. Due to some interdependency between
modules, the max parallel level is around 12. The remaining portion of the build,
mainly compiling the OpenFAST library itself, takes a considerable amount of time
and cannot be parallelized.
An example parallel build command is make -j 8
.