Quickstart
After picking your LIBRA flavor as described here, proceed onward to the appropriate section below. Make sure you’ve checked the requirements first!
Setup your repo:
Create
CMakeLists.txt
in the root of your repo. Within that file, create something like this:cmake_minimum_required(VERSION 3.21 FATAL_ERROR) # whatever version you like project(my_project CXX) # languages can be anything cmake supports include(libra/project) # Whatever other cmake config you like starts here
Create
CMakeLists.txt
in the root of your repo. Within that file, create something like this:cmake_minimum_required(VERSION 3.21 FATAL_ERROR) # whatever version you like project(my_project CXX) # languages can be anything cmake supports include(libra/project) # Whatever other cmake config you like starts here
Add the libra repository as a sub-module
libra/
in your repo OR direct your meta-level build system to cloned LIBRA intolibra/
in your repo.Create
cmake/project-local.cmake
in the root of your project repo. This is where you define what targets you want to build, how to build them, etc. See project-local.cmake: How To Hook Into LIBRA for more details.Make LIBRA accessible to CMake:
In
conanfile.py
put the following:def build_requirements(self): self.tool_requires("cmake/3.30") self.tool_requires("libra/0.8.0") # arbitrary LIBRA version
git clone https://github.com/jharwell/libra.git /path/to/libra cd /path/to/libra cmake -DCMAKE_INSTALL_PREFIX=/path/to/prefix . make install
Link
libra/cmake/project.cmake
->CMakeLists.txt
in the root of your repo. On linux:ln -s libra/cmake/project.cmake CMakeLists.txt
Build your project:
Via conan:
conan build .
from the root of the repo. Or:
cmake --build . -t <target> --preset conan-{debug,release}
from the root of the repo. Or:
make <target>
from the
build/{Debug,Release,...}
directory.mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=/path/to/prefix .. make
The prefix must be the same as where LIBRA was installed to, or
find_package()
won’t work out-of-the-box. If you need a different install prefix at this stage, you can do:cmake -DCMAKE_PREFIX_PATH=/path/to/prefix -DCMAKE_INSTALL_PREFIX=/path/to/wherever ..
CMAKE_PREFIX_PATH
is a list of dirs telling CMake where to look for packages.mkdir build && cd build cmake .. make