Migrating fro Autotools to CMake
Migtrating from Autotools to CMake
This document provides a comprehensive list of a autotools configuration options, and where appropriate, their cmake equivalents.
Options for Installation Rules
An installation prefix directory is specified with cmake using -DCMAKE_INSTALL_PREFIX=/my/install/path"
. If not specified, cmake will install to /usr/local
by default, which requires ROOT privilege. Furthermore, the installation prefix can only be specified at configure time.
By default, Octopus has the installation structure:
octopus-install/
bin/
include/
lib/
share/
Fine control over naming conventions can be achieved with the commands defined in the table below, however, it should not be necessary to override the installation rules for the project, and these options are largely untested.
Autotools option | CMake option | Description |
---|---|---|
--bindir=DIR |
-DCMAKE_INSTALL_BINDIR=DIR |
User executables [EPREFIX/bin]. |
--sbindir=DIR |
-DCMAKE_INSTALL_SBINDIR=DIR |
System admin executables [EPREFIX/sbin]. |
--libexecdir=DIR |
-DCMAKE_INSTALL_LIBEXECDIR=DIR |
Program executables [EPREFIX/libexec]. |
--sysconfdir=DIR |
-DCMAKE_INSTALL_SYSCONFDIR=DIR |
Read-only single-machine data [PREFIX/etc]. |
--sharedstatedir=DIR |
-DCMAKE_INSTALL_SHAREDSTATEDIR=DIR |
Modifiable architecture-independent data [PREFIX/m]. |
--localstatedir=DIR |
-DCMAKE_INSTALL_LOCALSTATEDIR=DIR |
Modifiable single-machine data [PREFIX/var]. |
--runstatedir=DIR |
-DCMAKE_INSTALL_RUNSTATEDIR=DIR |
Modifiable per-process data [LOCALSTATEDIR/run]. |
--libdir=DIR |
-DCMAKE_INSTALL_LIBDIR=DIR |
Object code libraries [EPREFIX/lib]. |
--includedir=DIR |
-DCMAKE_INSTALL_INCLUDEDIR=DIR |
C header files [PREFIX/include]. |
--oldincludedir=DIR |
-DCMAKE_INSTALL_OLDINCLUDEDIR=DIR |
C header files for non-gcc [/usr/include]. |
--datarootdir=DIR |
-DCMAKE_INSTALL_DATAROOTDIR=DIR |
Read-only arch.-independent data root [PREFIX/share]. |
--datadir=DIR |
-DCMAKE_INSTALL_DATADIR=DIR |
Read-only architecture-independent data [DATAROOTDIR]. |
--infodir=DIR |
-DCMAKE_INSTALL_INFODIR=DIR |
Info documentation [DATAROOTDIR/info]. |
--localedir=DIR |
-DCMAKE_INSTALL_LOCALEDIR=DIR |
Locale-dependent data [DATAROOTDIR/locale]. |
--mandir=DIR |
-DCMAKE_INSTALL_MANDIR=DIR |
Man documentation [DATAROOTDIR/man]. |
--docdir=DIR |
-DCMAKE_INSTALL_DOCDIR=DIR |
Documentation root [DATAROOTDIR/doc/octopus]. |
--enable-shared[=PKGS] |
-DOCTOPUS_SHARED_LIBS=On |
Build shared libraries [default=no]. |
--enable-static[=PKGS] |
-DOCTOPUS_SHARED_LIBS=Off |
Build static libraries [default=yes]. |
--enable-fast-install[=PKGS] |
N/A | Optimize for fast installation [default=yes]. CMake never relinks targets during installation. Instead, it copies built binaries and libraries from the build tree to the install tree. |
--disable-libtool-lock |
N/A | Avoid locking (might break parallel builds). |
--htmldir=DIR |
N/A | html documentation [DOCDIR]. |
--dvidir=DIR |
N/A | dvi documentation [DOCDIR]. |
--pdfdir=DIR |
N/A | pdf documentation [DOCDIR]. |
--psdir=DIR |
N/A | ps documentation [DOCDIR]. |
--program-prefix=PREFIX |
N/A | Prepend PREFIX to installed program names. |
--program-suffix=SUFFIX |
N/A | Append SUFFIX to installed program names. |
--program-transform-name=PROGRAM |
N/A | Run sed PROGRAM on installed program names. |
--build=BUILD |
N/A | Describes where you’re building the package. |
Optimisation Options
Enabling optimisation for specific vectorial instructions is not directly supported by Octopus cmake, however, general optimisation is defined for GCC and Intel compilers within src/CMakeLists.txt
, in the form of -march=native
and -xHost
, respectively. When -DOCTOPUS_NATIVE=On
, the compiler enables all supported instruction subsets of the local machine’s processor. This comes at the expense of portability.
Autotools option | CMake option | Description |
---|---|---|
--host=HOST |
-DCMAKE_TOOLCHAIN_FILE=/path/to/HOST-toolchain.cmake |
Cross-compile programs to run on HOST [BUILD]. Requires the definition of a HOST_toolchain.cmake , to specify cross compilation options. |
--disable-debug |
-DOCTOPUS_DEBUG=Off |
Disable Octopus assertions, safe (de)allocations and push/pub macros. |
--enable-vectors |
N/A | Enable the use of vectorial instructions. |
--enable-sse2 |
N/A | Enable the use of SSE2 vectorial instructions. |
--enable-fma3 |
N/A | Enable the use of FMA3 vectorial instructions (x86_64). |
--enable-fma4 |
N/A | Enable the use of FMA4 vectorial instructions (x86_64). |
--enable-avx |
N/A | Enable the use of AVX vectorial instructions (x86_64). |
--enable-avx512 |
N/A | Enable the use of AVX512 vectorial instructions (x86_64). |
Enabling External Library Support
If a user wishes to link Octopus to any package, particularly those that are not installed in the standard directories searched by cmake, they can pass the option -D<PACKAGE>_ROOT=DIR
. Calls to find_package(<PACKAGE>)
will search in prefixes specified by the <PACKAGE>_ROOT
CMake variable. The exact package names are case-sensitive, according to what is passed to find_package
in Octopus’s CMakeLists.txt
.
Equivalently, the user can add the relevant search paths to the CMAKE_PREFIX_PATH
, either as an environment variable or as a cmake option. For example:
-DCMAKE_PREFIX_PATH="/opt/homebrew/Cellar/metis/5.1.0;/opt/homebrew/Cellar/fftw/3.3.10_1;/opt/homebrew/opt/openblas"
For find_package(PACKAGE MODULE)
, the corresponding Find<Package>.cmake
typically defines cache entries for the include paths and libraries it finds, such that the user does not have to. However, you can always override those by passing -D
on the command line, according to the general pattern:
<PACKAGE>_INCLUDE_DIR, <PACKAGE>_INCLUDEDIR or <PACKAGE>_INCLUDE_DIRS
<PACKAGE>_LIBRARY or <PACKAGE>_LIBRARIES
In general, this is not recommended as it should not be necessary.
REQUIRED packages are searched for by cmake and cause the configuration to fail if not found. On the contrary, all OPTIONAL packages are also searched for, but do not affect configuration if they are not found. To ignore a package detected by cmake, one can use the cmake option:
-DCMAKE_DISABLE_FIND_PACKAGE_<PKG>=On
Autotools option | CMake option | Description |
---|---|---|
--enable-mpi(=PATH) |
-DOCTOPUS_MPI=On |
MPI support. |
--disable-mpi_mod |
N/A | Support for mpif.h has been dropped. |
--enable-openmp |
-DOCTOPUS_OpenMP=On |
Multi-threaded parallel version using OpenMP. |
--enable-opencl |
-DOCTOPUS_OpenCL=On |
OpenCL support (legacy) |
--enable-nvtx |
-DOCTOPUS_CUDA=On |
NVTX profiling support for Cuda. Enabled with CUDA, in Octopus cmake. |
--enable-cuda |
-DOCTOPUS_CUDA=On |
Cuda support. |
--enable-cuda-mpi |
-DOCTOPUS_CUDA=On |
Cuda-aware MPI support is automatically enabled when possible. |
N/A | -DOCTOPUS_HIP=On |
HIP support. |
--with-cuda-prefix=DIR |
-DCUDAToolkit_ROOT=DIR |
Directory where CUDA was installed. How cmake searches for the CUDA Toolkit is documented here. |
--with-clfft-prefix=DIR |
N/A | Directory where clFFT is installed. |
--with-clfft-include=DIR |
N/A | Directory where clfft headers are installed. |
--with-clblas-prefix=DIR |
N/A | Directory where clBLAS is installed. |
--with-clblas-include=DIR |
N/A | Directory where clblas headers are installed. |
--with-clblast-prefix=DIR |
N/A | Directory where clBlast is installed. |
--with-clblast-include=DIR |
N/A | Directory where clBlast headers are installed. |
--with-libxc-prefix=DIR |
-DLibxc_ROOT=DIR |
Directory where libxc was installed. |
--with-libxc-include=DIR |
-DLibxc_INCLUDEDIR=DIR or -DLibxc_INCLUDE_DIRS=DIR |
Directory where libxc Fortran headers were installed. |
--with-libvdwxc-prefix=DIR |
Dlibvdwxc_ROOT=DIR |
Directory where libvdwxc is installed. |
--with-blas=<lib> |
N/A | Use BLAS library |
--with-lapack=<lib> |
N/A | Use LAPACK library |
--with-gsl-prefix=DIR |
-DGSL_ROOT=DIR |
Prefix where GSL is installed. |
--with-gsl-exec-prefix=DIR |
N/A | Exec prefix where GSL is installed . |
--with-fftw-prefix=DIR |
-DFFTW_ROOT=DIR |
Directory where fftw3 was installed. Only relevant when -DOCTOPUS_FFTW=On , which is the default when MKL is not used. |
--with-pfft-prefix=<lib> |
-Dpfft_ROOT=DIR |
PFFT version 1.0.8 is required, linked with a patched version of FFTW3.3.3. Source and more information at http://www-user.tu-chemnitz.de/~mpip/software.php |
--with-pfft-include=DIR |
-Dpfft_INCLUDE_DIR=DIR |
PFFT Fortran include files directory. |
--with-nfft=DIR |
-Dnfft_ROOT=DIR |
Use NFFT library (optional) http://www-user.tu-chemnitz.de/~potts/nfft/index.php |
--with-pnfft-prefix=DIR |
-Dpnfft_ROOT=DIR |
http://www-user.tu-chemnitz.de/~mpip/software.php. It requires PFFT. |
--with-pnfft-include=DIR |
-Dpnfft_INCLUDE_DIR=DIR |
Directory where PNFFT Fortran include files were installed. |
--with-netcdf-prefix=DIR |
-DnetCDF-Fortran_ROOT=DIR |
Directory where netcdf was installed. |
--with-netcdf-include=DIR |
-DnetCDF-Fortran_INCLUDEDIR=DIR |
Directory where netcdf Fortran headers were installed. |
--with-etsf-io-prefix=DIR |
-Detsf-io_ROOT=DIR |
Directory where etsf-io was installed. |
--with-etsf-io-include=DIR |
-Detsf_io_INCLUDE_DIR=DIR |
Directory where etsf_io Fortran headers were installed. |
--with-berkeleygw-prefix=DIR |
-DBerkeleyGW_ROOT=DIR |
Directory where BerkeleyGW was installed. |
--with-sparskit=<lib> |
-DSPARSKIT_ROOT=DIR |
Directory where SPARSKIT was installed. |
--with-nlopt-prefix=DIR |
-DNLopt_ROOT=DIR |
Directory where NLOPT was installed. The NLOPT library can be downloaded here. |
--with-blacs=<lib> |
By default when using scalapack | Use the BLACS library. |
--with-scalapack=<lib> |
-DOCTOPUS_ScaLAPACK=On |
Use the SCALAPACK library. |
--with-elpa-prefix=DIR |
-DELPA_ROOT=DIR |
Directory where ELPA was installed. |
--with-libfm-prefix=<lib> |
N/A | LIBFM library support has been removed. |
--with-yaml-prefix=DIR |
N/A | Octopus does not directly depend on LIBYAML, which is a dependency of the BigDFT suite. However the regression testing reporting ( -DOCTOPUS_TESTS_REPORT=On ) does require a Perl YAML library. |
--with-futile-prefix=DIR |
N/A | Directory where Futile was installed. Octopus does not directly depend on Futile, which is dependency of PSolver. |
--with-futile-include=DIR |
N/A | Directory where Futile Fortran headers were installed. |
--with-atlab-prefix=DIR |
-Datlab_ROOT=DIR |
Directory where bigdft-atlab was installed. Note that PSolver depends on atlab, and searches for it via FindPSolver.cmake and Findatlab.cmake . |
--with-atlab-include=DIR |
-Datlab_INCLUDEDIR=DIR |
Directory where bigdft-atlab Fortran headers were installed. |
--with-psolver-prefix=DIR |
-DPSolver_ROOT=DIR |
Directory where PSolver was installed. |
--with-psolver-include=DIR |
-DPSolver_INCLUDEDIR=DIR |
Directory where PSolver Fortran headers were installed. |
--with-cgal[=DIR] |
-DCGAL_ROOT=DIR` | Location of cgal installation, default $CGAL_HOME . |
--with-boost[=ARG] |
N/A | Use Boost C++. library. |
--with-boost-libdir=LIB_DIR |
-DBOOST_ROOT=DIR |
Boost library root. |
--with-pspio-prefix=DIR |
Unsupported as of Octopus 16.1 | Directory where pspio was installed. |
--with-metis-prefix=DIR |
-DMETIS_ROOT=DIR |
Directory where external METIS library was installed (must be single-precision). |
--disable-metis |
N/A | Do not compile with internal METIS domain-partitioning library. Internal metis is implemented as a fallback in cmake, and will only be used if an external version of metis cannot be found. |
N/A | -DCMAKE_DISABLE_FIND_PACKAGE_METIS=On |
Compile with internal METIS domain-partitioning library. |
--with-parmetis-prefix=DIR |
-DParMETIS_ROOT=DIR |
Directory where ParMETIS library was installed. |
--with-likwid-prefix=DIR |
-DLIKWID_ROOT=DIR |
Directory where likwid was installed. |
--with-dftbplus-prefix=<path> |
-DDftbPlus_ROOT=DIR |
Root directory of DFTB+. |
--disable-gdlib |
-DCMAKE_DISABLE_FIND_PACKAGE_GD=On |
Do not compile with GD image-processing library. GD is not a REQUIRED Octopus dependency, so configuration will pass if GD is not found. |
Misc Options
Autotools option | CMake option | Description |
---|---|---|
--disable-option-checking |
By default cmake will not check options. To perform option checking, configure with cmake --warn-uninitialized |
Ignore unrecognized --enable /--with autotools options. |
--disable-FEATURE /--enable-FEATURE[=ARG] |
Documented above for all options | Whether or not to include a FEATURE [ARG=yes]. |
--disable-silent-rules / --enable-silent-rules |
-DCMAKE_VERBOSE_MAKEFILE=On |
Verbose build output is disabled by default with cmake. |
--disable-dependency-tracking /--enable-dependency-tracking |
N/A. CMake automatically only rebuild targets that have changed | Have every compile pass generate full header‐file dependency information so that subsequent make runs will only rebuild what actually changed. |
--disable-zdotc-test |
N/A | Assume zdotc works, and do not perform a test. |
--with-pic[=PKGS] |
PIC is enabled by default in cmake when building shared libraries -DOCTOPUS_SHARED_LIBS=On . |
Try to use only PIC/non-PIC objects [default=use both]. |
--with-aix-soname=aix |
N/A | Shared library versioning (aka “SONAME”) variant to provide on AIX, [default=aix]. CMake chooses the library style per‐target, and by default on AIX generates plain .so files (SVR4‐style), to be consistent with other UNIX platforms. |
--with-gnu-ld |
-DCMAKE_LINKER_TYPE=GNU (as of cmake v3.29) |
Assume the C compiler uses GNU ld [default=no]. CMake can specify which linker is used for the link step, for all targets created by created add_library() or add_executable() . |
--with-sysroot[=DIR] |
-DCMAKE_SYSROOT=DIR |
Search for dependent libraries within DIR (or the compiler’s sysroot if not specified). |