Module reference¶
cc.cmake¶
Adds C support. Appends EXTRA_CFLAGS to CMAKE_C_FLAGS. If environment variable CFLAGS is set, then the CFLAGS are used and no other flags are used or appended.
Variables used:
EXTRA_CFLAGS
Variables modified:
CMAKE_C_FLAGS
Environment variables used:
CFLAGS
autocmake.yml configuration:
docopt:
- "--cc=<CC> C compiler [default: gcc]."
- "--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: '']."
define: "'-DCMAKE_C_COMPILER={0} -DEXTRA_CFLAGS=\"{1}\"'.format(arguments['--cc'], arguments['--extra-cc-flags'])"
ccache.cmake¶
Adds ccache support. The user should export the appropriate environment variables to tweak the program’s behaviour, as described in its manpage. Notice that some additional compiler flags might be needed in order to avoid unnecessary warnings.
Variables defined:
CCACHE_FOUND
autocmake.yml configuration:
docopt: "--ccache=<USE_CCACHE> Toggle use of ccache <ON/OFF> [default: ON]."
define: "'-DUSE_CCACHE={0}'.format(arguments['--ccache'])"
code_coverage.cmake¶
Enables code coverage by appending corresponding compiler flags.
Variables modified (provided the corresponding language is enabled):
CMAKE_Fortran_FLAGS
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
autocmake.yml configuration:
docopt: "--coverage Enable code coverage [default: OFF]."
define: "'-DENABLE_CODE_COVERAGE={0}'.format(arguments['--coverage'])"
custom_color_messages.cmake¶
Colorize CMake output. Code was found on StackOverflow: http://stackoverflow.com/a/19578320
- Usage within CMake code:
message(“This is normal”) message(“${Red}This is Red${ColourReset}”) message(“${Green}This is Green${ColourReset}”) message(“${Yellow}This is Yellow${ColourReset}”) message(“${Blue}This is Blue${ColourReset}”) message(“${Magenta}This is Magenta${ColourReset}”) message(“${Cyan}This is Cyan${ColourReset}”) message(“${White}This is White${ColourReset}”) message(“${BoldRed}This is BoldRed${ColourReset}”) message(“${BoldGreen}This is BoldGreen${ColourReset}”) message(“${BoldYellow}This is BoldYellow${ColourReset}”) message(“${BoldBlue}This is BoldBlue${ColourReset}”) message(“${BoldMagenta}This is BoldMagenta${ColourReset}”) message(“${BoldCyan}This is BoldCyan${ColourReset}”) message(“${BoldWhite}This is BoldWhitenn${ColourReset}”)
Has no effect on WIN32.
cxx.cmake¶
Adds C++ support. Appends EXTRA_CXXFLAGS to CMAKE_CXX_FLAGS. If environment variable CXXFLAGS is set, then the CXXFLAGS are used and no other flags are used or appended.
Variables used:
EXTRA_CXXFLAGS
Variables modified:
CMAKE_CXX_FLAGS
Environment variables used:
CXXFLAGS
autocmake.yml configuration:
docopt:
- "--cxx=<CXX> C++ compiler [default: g++]."
- "--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: '']."
define: "'-DCMAKE_CXX_COMPILER={0} -DEXTRA_CXXFLAGS=\"{1}\"'.format(arguments['--cxx'], arguments['--extra-cxx-flags'])"
default_build_paths.cmake¶
Sets binary and library output directories to ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} and ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}, respectively.
Variables modified:
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
CMAKE_LIBRARY_OUTPUT_DIRECTORY
CMAKE_RUNTIME_OUTPUT_DIRECTORY
definitions.cmake¶
Add preprocessor definitions (example: –add-definitions=”-DTHIS -DTHAT=137”). These are passed all the way down to the compiler.
Variables used:
PREPROCESSOR_DEFINITIONS
autocmake.yml configuration:
docopt: "--add-definitions=<STRING> Add preprocesor definitions [default: '']."
define: "'-DPREPROCESSOR_DEFINITIONS=\"{0}\"'.format(arguments['--add-definitions'])"
export_header.cmake¶
Generates export header for your API using best practices. This module wraps https://cmake.org/cmake/help/v3.0/module/GenerateExportHeader.html and it is needed because of these, Very Good Indeed, reasons: https://gcc.gnu.org/wiki/Visibility. If you are not afraid of jargon, please also have a look at https://www.akkadia.org/drepper/dsohowto.pdf.
Variables used:
PROJECT_NAME (defined by project())
fc.cmake¶
Adds Fortran support. Appends EXTRA_FCFLAGS to CMAKE_Fortran_FLAGS. If environment variable FCFLAGS is set, then the FCFLAGS are used and no other flags are used or appended.
Variables used:
EXTRA_FCFLAGS
Variables defined:
CMAKE_Fortran_MODULE_DIRECTORY
Variables modified:
CMAKE_Fortran_FLAGS
Environment variables used:
FCFLAGS
autocmake.yml configuration:
docopt:
- "--fc=<FC> Fortran compiler [default: gfortran]."
- "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']."
define: "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])"
fc_optional.cmake¶
Adds optional Fortran support. Appends EXTRA_FCFLAGS to CMAKE_Fortran_FLAGS. If environment variable FCFLAGS is set, then the FCFLAGS are used and no other flags are used or appended.
Variables used:
EXTRA_FCFLAGS
ENABLE_FC_SUPPORT
Variables defined:
CMAKE_Fortran_MODULE_DIRECTORY
Variables modified:
CMAKE_Fortran_FLAGS
Variables defined:
ENABLE_FC_SUPPORT
Environment variables used:
FCFLAGS
autocmake.yml configuration:
docopt:
- "--fc=<FC> Fortran compiler [default: gfortran]."
- "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']."
- "--fc-support=<FC_SUPPORT> Toggle Fortran language support (ON/OFF) [default: ON]."
define:
- "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])"
- "'-DENABLE_FC_SUPPORT={0}'.format(arguments['--fc-support'])"
git_info.cmake¶
Creates git_info.h in the build directory. This file can be included in sources to print Git repository version and status information to the program output.
autocmake.yml configuration:
url_root: https://github.com/dev-cafe/autocmake/raw/master/
fetch:
- "%(url_root)modules/git_info/git_info.h.in"
googletest.cmake¶
Includes Google Test sources and adds a library “googletest”.
Variables used:
GOOGLETEST_ROOT
autocmake.yml configuration:
define: "'-DGOOGLETEST_ROOT=external/googletest/googletest'"
int64.cmake¶
Enables 64-bit integer support for Fortran projects.
Variables modified (provided the corresponding language is enabled):
CMAKE_Fortran_FLAGS
autocmake.yml configuration:
docopt: "--int64 Enable 64bit integers [default: False]."
define: "'-DENABLE_64BIT_INTEGERS={0}'.format(arguments['--int64'])"
accelerate.cmake¶
Find and link to ACCELERATE.
Variables defined:
ACCELERATE_FOUND - describe me, uncached
ACCELERATE_LIBRARIES - describe me, uncached
ACCELERATE_INCLUDE_DIR - describe me, uncached
autocmake.yml configuration:
url_root: https://github.com/dev-cafe/autocmake/raw/master/
docopt: "--accelerate Find and link to ACCELERATE [default: False]."
define: "'-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate'])"
fetch:
- "%(url_root)modules/find/find_libraries.cmake"
- "%(url_root)modules/find/find_include_files.cmake"
acml.cmake¶
Find and link to ACML.
Variables defined:
ACML_FOUND
ACML_LIBRARIES
ACML_INCLUDE_DIR
autocmake.yml configuration:
docopt: "--acml Find and link to ACML [default: False]."
define: "'-DENABLE_ACML={0}'.format(arguments['--acml'])"
atlas.cmake¶
Find and link to ATLAS.
Variables defined:
ATLAS_FOUND
ATLAS_LIBRARIES
ATLAS_INCLUDE_DIR
autocmake.yml configuration:
docopt: "--atlas Find and link to ATLAS [default: False]."
define: "'-DENABLE_ATLAS={0}'.format(arguments['--atlas'])"
blas.cmake¶
Find and link to BLAS.
Variables defined:
BLAS_FOUND
BLAS_LIBRARIES
BLAS_INCLUDE_DIR
autocmake.yml configuration:
docopt: "--blas Find and link to BLAS [default: False]."
define: "'-DENABLE_BLAS={0}'.format(arguments['--blas'])"
cblas.cmake¶
Find and link to CBLAS.
Variables defined:
CBLAS_FOUND - describe me, uncached
CBLAS_LIBRARIES - describe me, uncached
CBLAS_INCLUDE_DIR - describe me, uncached
autocmake.yml configuration:
url_root: https://github.com/dev-cafe/autocmake/raw/master/
docopt: "--cblas Find and link to CBLAS [default: False]."
define: "'-DENABLE_CBLAS={0}'.format(arguments['--cblas'])"
fetch:
- "%(url_root)modules/find/find_libraries.cmake"
- "%(url_root)modules/find/find_include_files.cmake"
goto.cmake¶
Find and link to Goto BLAS.
Variables defined:
GOTO_FOUND
GOTO_LIBRARIES
GOTO_INCLUDE_DIR
autocmake.yml configuration:
docopt: "--goto Find and link to GOTO [default: False]."
define: "'-DENABLE_GOTO={0}'.format(arguments['--goto'])"
lapack.cmake¶
Find and link to LAPACK.
Variables defined:
LAPACK_FOUND
LAPACK_LIBRARIES
LAPACK_INCLUDE_DIR
autocmake.yml configuration:
docopt: "--lapack Find and link to LAPACK [default: False]."
define: "'-DENABLE_LAPACK={0}'.format(arguments['--lapack'])"
lapacke.cmake¶
Find and link to LAPACKE.
Variables defined:
LAPACKE_FOUND - describe me, uncached
LAPACKE_LIBRARIES - describe me, uncached
LAPACKE_INCLUDE_DIR - describe me, uncached
autocmake.yml configuration:
url_root: https://github.com/dev-cafe/autocmake/raw/master/
docopt: "--lapacke Find and link to LAPACKE [default: False]."
define: "'-DENABLE_LAPACKE={0}'.format(arguments['--lapacke'])"
fetch:
- "%(url_root)modules/find/find_libraries.cmake"
- "%(url_root)modules/find/find_include_files.cmake"
math_libs.cmake¶
Detects and links to BLAS and LAPACK libraries.
Variables used:
MATH_LIB_SEARCH_ORDER, example: set(MATH_LIB_SEARCH_ORDER MKL ESSL OPENBLAS ATLAS ACML SYSTEM_NATIVE)
ENABLE_STATIC_LINKING
ENABLE_BLAS
ENABLE_LAPACK
BLAS_FOUND
LAPACK_FOUND
BLAS_LANG
LAPACK_LANG
BLAS_TYPE
LAPACK_TYPE
ENABLE_64BIT_INTEGERS
CMAKE_HOST_SYSTEM_PROCESSOR
BLACS_IMPLEMENTATION
MKL_FLAG
Variables defined:
MATH_LIBS
BLAS_FOUND
LAPACK_FOUND
Variables modified:
CMAKE_EXE_LINKER_FLAGS
Environment variables used:
MATH_ROOT
BLAS_ROOT
LAPACK_ROOT
MKL_ROOT
MKLROOT
autocmake.yml configuration:
docopt:
- "--blas=<BLAS> Detect and link BLAS library (auto or off) [default: auto]."
- "--lapack=<LAPACK> Detect and link LAPACK library (auto or off) [default: auto]."
- "--mkl=<MKL> Pass MKL flag to the Intel compiler and linker and skip BLAS/LAPACK detection (sequential, parallel, cluster, or off) [default: off]."
- "--scalapack=<SCALAPACK_LIBRARIES> Link line for ScaLAPACK libraries [default: ]"
- "--blacs=<BLACS_IMPLEMENTATION> Implementation of BLACS for MKL ScaLAPACK (openmpi, intelmpi, sgimpt) [default: openmpi]"
define:
- "'-DENABLE_BLAS={0}'.format(arguments['--blas'])"
- "'-DENABLE_LAPACK={0}'.format(arguments['--lapack'])"
- "'-DMKL_FLAG={0}'.format(arguments['--mkl'])"
- "'-DMATH_LIB_SEARCH_ORDER=\"MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE\"'"
- "'-DBLAS_LANG=Fortran'"
- "'-DLAPACK_LANG=Fortran'"
- "'-DSCALAPACK_LIBRARIES=\"{0}\"'.format(arguments['--scalapack'])"
- "'-DBLACS_IMPLEMENTATION=\"{0}\"'.format(arguments['--blacs'])"
warning: "the math_libs.cmake module is deprecated and will be removed in future versions"
mpi.cmake¶
Enables MPI support.
Variables used:
ENABLE_MPI
MPI_FOUND
Variables modified (provided the corresponding language is enabled):
CMAKE_Fortran_FLAGS
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
autocmake.yml configuration:
docopt: "--mpi Enable MPI parallelization [default: False]."
define: "'-DENABLE_MPI={0}'.format(arguments['--mpi'])"
omp.cmake¶
Enables OpenMP support.
Variables used:
ENABLE_OPENMP
OPENMP_FOUND
Variables modified (provided the corresponding language is enabled):
CMAKE_Fortran_FLAGS
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
autocmake.yml configuration:
docopt: "--omp Enable OpenMP parallelization [default: False]."
define: "'-DENABLE_OPENMP={0}'.format(arguments['--omp'])"
profile.cmake¶
Enable profiling by appending corresponding compiler flags.
Variables modified (provided the corresponding language is enabled):
CMAKE_Fortran_FLAGS
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
autocmake.yml configuration:
docopt: "--profile Enable profiling [default: False]"
define: "'-DENABLE_PROFILING={0}'.format(arguments['--profile'])"
python_interpreter.cmake¶
Detects Python interpreter.
Variables used:
PYTHON_INTERPRETER - User-set path to the Python interpreter
Variables defined:
PYTHONINTERP_FOUND - Was the Python executable found
PYTHON_EXECUTABLE - path to the Python interpreter
PYTHON_VERSION_STRING - Python version found e.g. 2.5.2
PYTHON_VERSION_MAJOR - Python major version found e.g. 2
PYTHON_VERSION_MINOR - Python minor version found e.g. 5
PYTHON_VERSION_PATCH - Python patch version found e.g. 2
autocmake.yml configuration:
docopt: "--python=<PYTHON_INTERPRETER> The Python interpreter (development version) to use. [default: '']."
define: "'-DPYTHON_INTERPRETER=\"{0}\"'.format(arguments['--python'])"
python_libs.cmake¶
Detects Python libraries and headers. Detection is done basically by hand as the proper CMake package will not find libraries and headers matching the interpreter version.
Dependencies:
python_interpreter - Sets the Python interpreter for headers and libraries detection
Variables used:
PYTHONINTERP_FOUND - Was the Python executable found
Variables defined:
PYTHONLIBS_FOUND - have the Python libs been found
PYTHON_LIBRARIES - path to the python library
PYTHON_INCLUDE_DIRS - path to where Python.h is found
PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
safeguards.cmake¶
Provides safeguards against in-source builds and bad build types.
Variables used:
PROJECT_SOURCE_DIR
PROJECT_BINARY_DIR
CMAKE_BUILD_TYPE
save_flags.cmake¶
Take care of updating the cache for fresh configurations.
Variables modified (provided the corresponding language is enabled):
DEFAULT_Fortran_FLAGS_SET
DEFAULT_C_FLAGS_SET
DEFAULT_CXX_FLAGS_SET
sccache.cmake¶
Adds sccache support. The user should export the appropriate environment variables to tweak the program’s behaviour, as described in its manpage. Notice that some additional compiler flags might be needed in order to avoid unnecessary warnings.
Variables defined:
SCCACHE_FOUND
autocmake.yml configuration:
docopt: "--sccache=<USE_SCCACHE> Toggle use of sccache <ON/OFF> [default: ON]."
define: "'-DUSE_SCCACHE={0}'.format(arguments['--sccache'])"
src.cmake¶
Adds ${PROJECT_SOURCE_DIR}/src as subdirectory containing CMakeLists.txt.
version.cmake¶
Determine program version from file “VERSION” (example: “14.1”) The reason why this information is stored in a file and not as CMake variable is that CMake-unaware programs can parse and use it (e.g. Sphinx). Also web-based hosting frontends such as GitLab automatically use the file “VERSION” if present.
Variables defined:
PROGRAM_VERSION