Compilers: To prevent CMake from identifying mixed toolchains during system introspection, it is good practice to explicitly set CMAKE_C_COMPILER, CMAKE_CXX_COMPILER, CMAKE_Fortran_COMPILER
Optimization and Debugging Symbols: The simplest way to set the optimization level and debug symbol inclusion for your builds is with CMAKE_BUILD_TYPE. For example set one of the following:
CMAKE_BUILD_TYPE=Debug # defaults to -g CMAKE_BUILD_TYPE=Release # defaults to -O3 -DNDEBUG CMAKE_BUILD_TYPE=RelWithDebInfo # defaults to -O2 -g
You may also manually set the relevant flags at configure time and these will supplement any set by the CMAKE_BUILD_TYPE configurations shown immediately above. For example:
CMAKE_C_FLAGS=-O2 CMAKE_CXX_FLAGS=-O2 CMAKE_Fortran_FLAGS=-O2
Shared vs. Static libraries: By default, Dakota builds and links external shared libraries, but can also build static libraries if you need to link against static libraries without position-independent code, e.g,. an installed libblas.a or libmpi.a.
# To build shared libraries ONLY BUILD_STATIC_LIBS:BOOL=OFF BUILD_SHARED_LIBS:BOOL=ON # Build static libraries ONLY BUILD_STATIC_LIBS:BOOL=ON BUILD_SHARED_LIBS:BOOL=OFF
Developer Convenience Macros: These shortcuts are designed to help routine development:
- -C cmake/DakotaDev.cmake: enable MPI, docs, and specification maintenance
- DevDebug:BOOL=ON to turn on most common developer options, with debug build type, static libs, and bounds checking (equivalent to cmake -C cmake/DakotaDebug.cmake -C cmake/DakotaDev.cmake)
- DevDistro:BOOL=ON to turn on most common developer options and distribution build type, shared libs, no bounds checking (equivalent to cmake -C cmake/DakotaDistro.cmake -C cmake/DakotaDev.cmake)
Take care to add additional options or configuration files in the right place before or after these to get the right behavior.
Verbose Make: To see detailed compile/link commands generated by CMake: make VERBOSE=1 (on Unix platforms), or set CMAKE_VERBOSE_MAKEFILE when configuring.