Setup guide

Algiane Froehly edited this page Sep 28, 2016 · 14 revisions

Setup guide

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:

cd build

I/ Configuration

Basic configuration

To configure the project you must run the cmake command followed by the path toward the project's CMakeLists.txt file:

cmake ..

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
Release compilation in release mode (add -O3 flag): fast executable
RelWithDebInfo release mode with debug informations (-O3 -g flags): a little slower executable
Debug debug mode with (-g flag): very slow executable
MinSizeRel minimum size mode (-Os flag): executable of small size
empty mode (no flag): slow executable
LIBMMG3D_STATIC enable or disable the static mmg3d library compilation
ON enabled
OFF disabled
LIBMMG3D_SHARED enable or disable the shared mmg3d library compilation
ON enabled
OFF disabled
LIBMMG2D_STATIC enable or disable the static mmg2d library compilation
ON enabled
OFF disabled
LIBMMG2D_SHARED enable or disable the shared mmg2d library compilation
ON enabled
OFF disabled
LIBMMGS_STATIC enable or disable the static mmgs library compilation
ON enabled
OFF disabled
LIBMMGS_SHARED enable or disable the shared mmgs library compilation
ON enabled
OFF disabled
LIBMMG_STATIC enable or disable the static mmg library compilation
ON enabled
OFF disabled
LIBMMG_SHARED enable or disable the shared mmg library compilation
ON enabled
OFF disabled
USE_SCOTCH enable or disable the SCOTCH library link
ON enabled
OFF disabled
TEST_LIBMMG3D enable or disable the compilation of examples of the mmg3d library usage
ON enabled
OFF disabled
TEST_LIBMMG2D enable or disable the compilation of examples of the mmg2d library usage
ON enabled
OFF disabled
TEST_LIBMMGS enable or disable the compilation of examples of the mmgs library usage
ON enabled
OFF disabled
TEST_LIBMMG enable or disable the compilation of examples of the mmg library usage
ON enabled
OFF disabled

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

By default:

  • 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).

II/ Compilation

Just run the make command with suitable arguments in the mmg/build/ directory:

  • to build both the mmgs and the mmg3d applications:
make
  • to build only the mmgs application:
make mmgs
  • to build only the mmg3d application:
make mmg3d

III/ Installation

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:
make install
  • 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.

Example:
For example, to set the installation location to the ~/myappli/ folder:

cmake -D CMAKE_INSTALL_PREFIX=~/myappli ..
make install

Outputs

Produced outputs

Default outputs

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.

Outputs locations

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).

Output Location
applications (mmgs, mmg3d, libmmg3d_example0_a…) $CMAKE_INSTALL_PREFIX/bin
libraries (libmmg3d.a…) $CMAKE_INSTALL_PREFIX/lib
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:

export PATH=$CMAKE_INSTALL_PREFIX/bin:$PATH

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.