Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 1.37 KB

File metadata and controls

32 lines (25 loc) · 1.37 KB

How to use mutation++ from your code

mutation++ uses CMake as build toolchain. In particular, starting from version 0.3.0, CMake exports a mutation++Config.cmake file together with the specific configuration files for the build type (e.g. Release, Debug) etc... that allows you to easily include the library into your own code if you also use CMake (ref: find_package(mutation++ CONFIG)). Our examples, that you can find in the examples directory, can be built independently from mutation++. You can take inspiration from the CMakeLists.txt that you find in each example directory in order to require and use mutation++ in your code.

cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.0)
get_filename_component(example_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${example_name})
# Let's require mutation++. It should export a suitable config that also
# exports include directories for Eigen. The `if` is needed to allow the
# examples to build during the process of building the entire mutation++
# tree.
if(NOT TARGET mutation++)
find_package(mutation++ REQUIRED)
endif()
add_executable(${example_name} ${example_name}.cpp)
target_link_libraries(${example_name}
PRIVATE
mutation++
)

So, assuming that you (or your sysadmin) installed mutation++ in a directory that is also in the install prefix where CMake looks for *.cmake files (ref: CMAKE_PREFIX_PATH), you basically just need to find_package(mutation++) and then link your target against mutation++ target:

target_link_libraries(<my-target>
    [PRIVATE|PUBLIC|INTERFACE]
        mutation++::mutation++
)