aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
How to create a simple project with aGrUM and cmake

As a build system, aGrUM uses CMake (http://www.cmake.org). A minimal project with agrum should look like this (for a project foo):

  • in the project folder, a sub-folder src,
  • in src folder, your *.{cpp|h|etc.} files
  • in the project folder, a file CMakeLists.txt like this one :
project(FOO)
# do not forget to change "FOO", "FOO_SOURCE" and "FOO_SOURCE_DIR" with the name of your project
# do not forget to change the target "foo" with the name of your executable
cmake_minimum_required(VERSION 3.13)
# make RELEASE the default option
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
project(EXAMPLE)
# do not forget to change this line: the path where you installed aGrUM with ("act install -d...")
set(AGRUM_INSTALLATION_DIRECTORY "/home/xxx/usr")
set(aGrUM_DIR "${AGRUM_INSTALLATION_DIRECTORY}/lib/cmake/aGrUM/")
find_package(aGrUM CONFIG REQUIRED)
file(GLOB_RECURSE FOO_SOURCE ${FOO_SOURCE_DIR}/src/*.cpp)
add_executable (foo ${FOO_SOURCE})
target_include_directories (foo PRIVATE src)
# here we link to agrumBASE since we're only using the base component
target_link_libraries (foo PRIVATE agrumBASE)
# (in this folder)
# to compile release version
#
# cmake -DCMAKE_BUILD_TYPE=RELEASE -B build .
# cmake --build build
#
# to compile debug version
#
# cmake -DCMAKE_BUILD_TYPE=Debug -B build_debug .
# cmake --build build_debug
#
*
cmake -B build_release .
cmake --build build
  • build/foo is the executable.