MeshLib Documentation
Loading...
Searching...
No Matches
MeshLib CMake Setup Guide

How to Use MeshLib with CMake

CMake Integration Support

MeshLib provides CMake integration support for Linux and macOS. Please note that CMake integration is not currently supported on Windows. Example CMake configuration files are available to demonstrate how to link against the pre-built libraries. You can find these examples in the examples directory.

Quick Integration Guide

Find MeshLib CMake Configuration Files

For a start, find the MeshLib package:

find_package(MeshLib CONFIG REQUIRED)

Include the MeshLib Headers

Ensure that the include directory from the installed MeshLib package is added to your project's include directories. In your CMake configuration (CMakeLists.txt), add:

include_directories(${MESHLIB_INCLUDE_DIR})
# or
target_include_directories(your_project_name PUBLIC ${MESHLIB_INCLUDE_DIR})

Link the MeshLib Libraries

Specify which MeshLib libraries to link with your project:

target_link_libraries(your_project_name PUBLIC MeshLib::MRMesh)
# if you want to use viewer libraries
target_link_libraries(your_project_name PUBLIC MeshLib::MRMesh MeshLib::MRViewer)

Find Third-Party Dependencies

MeshLib have extended functionality that may have additional dependencies that need to be linked. Check the example CMakeLists.txt provided in the examples directory to see how to add required dependencies:

target_include_directories(your_project_name PUBLIC ${MESHLIB_THIRDPARTY_INCLUDE_DIR})
target_link_directories(your_project_name PUBLIC ${MESHLIB_THIRDPARTY_LIB_DIR})