Clone this wiki locally
The Mmg project uses the CMake build system. It requires at least the CMake-3.0.0 release. In the following, we assume that you've clone or forked the mmg repository in the mmg/ directory.
First of all, you need to create a directory for the temporary files of CMake:
cd mmg mkdir build
In the following, we will work in this folder:
To configure the project you must run the
cmake command followed by the path toward the project's CMakeLists.txt file:
Advanced configuration: main options
You can customize the project configuration by passing arguments to the
cmake command. The most useful variables that can be set are detailed here.
|Variable name||Object||Authorized values and effects|
|CMAKE_BUILD_TYPE||allow to choose the compiler flags||
|LIBMMG3D_STATIC||enable or disable the static mmg3d library compilation||
|LIBMMG3D_SHARED||enable or disable the shared mmg3d library compilation||
|LIBMMG2D_STATIC||enable or disable the static mmg2d library compilation||
|LIBMMG2D_SHARED||enable or disable the shared mmg2d library compilation||
|LIBMMGS_STATIC||enable or disable the static mmgs library compilation||
|LIBMMGS_SHARED||enable or disable the shared mmgs library compilation||
|LIBMMG_STATIC||enable or disable the static mmg library compilation||
|LIBMMG_SHARED||enable or disable the shared mmg library compilation||
|USE_SCOTCH||enable or disable the SCOTCH library link||
|TEST_LIBMMG3D||enable or disable the compilation of examples of the mmg3d library usage||
|TEST_LIBMMG2D||enable or disable the compilation of examples of the mmg2d library usage||
|TEST_LIBMMGS||enable or disable the compilation of examples of the mmgs library usage||
|TEST_LIBMMG||enable or disable the compilation of examples of the mmg library usage||
For example, the following command turns the project in debug mode, enables the compilation of the shared mmg3d library and disables the use of the SCOTCH library:
cmake -D CMAKE_BUILD_TYPE=Debug -D LIBMMG3D_SHARED=ON -D USE__SCOTCH=OFF ..
Default configuration options
- the project is configured in release mode;
- it uses SCOTCH library if it is found;
- it builds the static mmg3d library (but not the shared one and the examples).
Just run the
make command with suitable arguments in the mmg/build/ directory:
- to build both the mmgs and the mmg3d applications:
- to build only the mmgs application:
- to build only the mmg3d application:
The mmg applications, libraries and headers are installed onto the directory indicated in the CMAKE_INSTALL_PREFIX CMake's variable. This variable defaults to /usr/local.
Thus, root access may be required for the installation operation:
- first, try to install with default permissions:
if errors occurs:
if you are root, try to use the root permissions:
sudo make install
if you have no root access, change the installation location. It requires to modify the project configuration.
For example, to set the installation location to the ~/myappli/ folder:cmake -D CMAKE_INSTALL_PREFIX=~/myappli .. make install
The mmg project compilation produce the following ouptuts:
- the mmgs_O3 application;
- the mmg3d_O3 application;
- the libmmg3d.a static library;
Outputs for customized configuration
The mmg's executables are postfixed by the compiler flag used to build it, thus you will obtain:
- the mmgs_O3 and mmg3d_O3 applications in Release mode;
- the mmgs_O3d and mmg3d_O3d applications in RelWithDebInfo mode;
- the mmgs_Os and mmg3d_Os applications in MinSizeRel mode;
- the mmgs and mmg3d applications in empty mode.
Depending on your configuration options, the mmg project compilation may produce some additional outputs:
- the libmmg3d.a static library;
- the libmmg3d.so or libmmg3d.dylib shared library;
- the libmmg3d_example0_a, libmmg3d_example0_b, libmmg3d_example1, libmmg3d_example2, libmmg3d_example3, libmmg3d_fortran_a and libmmg3d_fortran_b applications.
In this section we denote by $CMAKE_INSTALL_PREFIX the value of the CMAKE_INSTALL_PREFIX CMake's variable (so in our previous example, $CMAKE_INSTALL_PREFIX refers to the ~/myappli folder).
|applications (mmgs, mmg3d, libmmg3d_example0_a…)||$CMAKE_INSTALL_PREFIX/bin|
|header files (libmmg3d.h…)||$CMAKE_INSTALL_PREFIX/include|
Note that the $CMAKE_INSTALL_PREFIX/bin directory must be available in your PATH. If not, you need to add it:
If you have multiple installations of mmg in various directories, remember that your system uses the first executable that he find. Thus, after the previous export, the mmg applications of the $CMAKE_INSTALL_PREFIX/bin folder are used before the mmg applications found in the /usr/local/bin directory.