3.1. Compiling and Linking Client Code¶
The build system installs not only header files and the actual library, but also import files that other CMake-based projects can use to link against libMØD. The source code listed below can be found here.
For example, we could make a simple program from the following source:
#include <mod/graph/Graph.hpp>
#include <iostream>
int main() {
auto g = mod::graph::Graph::fromDFS("[T]");
std::cout << "Graph name: " << g->getName() << "\n";
}
The program can then be build as a CMake project with the following:
cmake_minimum_required(VERSION 3.15)
project(LibmodTestProject CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(mod REQUIRED)
add_executable(doStuff main.cpp)
target_link_libraries(doStuff mod::libmod)