RINGMesh  Version 5.0.0
A programming library for geological model meshes
How to integrate RINGMesh in anther cmake project

This page explain how to complete a CMakeLists.txt of a project using RINGMesh as dependency.

Define a user-defined variable to get RINGMesh directory path

The code below define a variable RINGMesh_HOME containing the path to the RINGMesh directory. The user can change the default value (parent directory of the current cmake project).

SET(RINGMesh_HOME "${PROJECT_SOURCE_DIR}/../RINGMesh" CACHE PATH "Path to RINGMesh project (mandatory dependency)")

Find the RINGMesh cmake configuration file

The code below finds the RINGMesh cmake configuration file from the variable RINGMesh_HOME. Several variables are defined toward RINGMesh, geogram, zlib and tinyxml2 includes, and RINGMesh and geogram libraries. There are some variations between Linux and Windows. All RINGMesh includes are added to the current project includes. The RINGMesh libraries are added to a variable EXTRA_LIBS in which all the libraries, used in the current cmake project, i.e., not only RINGMesh, are added. All this steps are defined in the cmake/RINGMeshConfig.cmake file.

message(STATUS "Using RINGMesh directory = ${RINGMesh_HOME}")
find_package(RINGMesh REQUIRED PATHS ${RINGMesh_HOME}/cmake)
set_ringmesh_includes_and_libs(EXTRA_LIBS)

Link your code with RINGMesh

Add this line to link your library (called MyLib) with RINGMesh:

target_link_libraries(MyLib ${EXTRA_LIBS})

As said previously, EXTRA_LIBS may contain other libraries than the ones of RINGMesh.

To link your binaries (e.g., MyBin) with RINGMesh, you can use the following line:

target_link_libraries(MyBin MyLib ${EXTRA_LIBS})

or potentially:

target_link_libraries(MyBin MyLib ${RINGMesh_LIBRARIES})