Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCAP CMake Builder

This repo provides a wrapper to build and install MCAP via CMake.

Build, Install and Test

Prerequisites

# apt package manager
sudo apt install lz4 liblz4-dev zstd libzstd-dev

# homebrew package manager
brew install lz4 zstd
  • pkgconf may also need to be install on some systems.

The current version of the MCAP C++ library can be double checked at foxglove/mcap#developer-quick-start and updated in CMakeLists.txt set (VERSION …) as needed.

To build and install run:

git clone --recursive git@github.com:ERIC-Robotics/mcap_builder.git
cd mcap_builder

mkdir build && cd build
cmake -S ../ -B . # -Wno-dev reduces CMake-developer-specific warnings clutter
sudo make install

you can change the install folder by setting CMAKE_INSTALL_PREFIX (as for any CMake project).

The MCAP C++ sources are vendored as a git submodule under extern/mcap, so --recursive is required. If you already cloned without it, run:

git submodule update --init --recursive

This is the only step that needs internet access — configuring and building afterwards works fully offline.

Test: Check Installation Usability

cd test/mcap_builder_check
mkdir build && cd build
cmake -S ../ -B .
make
./mcap_builder_check
# Successfully included and used mcap library!
# LZ4: Not available
# ZSTD: Available

Usage

MCAP Is Installed

If you built and installed as described above, to include MCAP in your library first you need to add it to your CMake:

find_package(mcap)

target_link_libraries(<target> PUBLIC mcap)

and in your code, you can include reader.hpp or writer.hpp.

Build MCAP Locally

If you do not want to install MCAP, and you want to build it as part of your project, add mcap_builder as a git submodule of your own repo. This keeps the whole build fully offline after the initial clone — no FetchContent network fetch at configure time.

Add the submodule:

git submodule add https://github.com/ERIC-Robotics/mcap_builder.git extern/mcap_builder
git submodule update --init --recursive

In your CMakeLists.txt:

add_subdirectory(extern/mcap_builder)

# create your targets

target_link_libraries(<target> PUBLIC mcap)

mcap_builder itself vendors MCAP as a nested submodule, so --init --recursive pulls both in one shot. Make sure your own project's clone/CI instructions use git clone --recursive (or run git submodule update --init --recursive after cloning) so both submodules are populated before configuring — this is the only step that needs internet access.

To update the pinned version later:

cd extern/mcap_builder
git fetch --tags
git checkout <tag-or-branch>
cd ../..
git add extern/mcap_builder

Macros

  • Do not add MCAP_IMPLEMENTATION macro, as that is handled for you by this wrapper.
  • This Cmake wrapper automatically detects if LZ4 and zstd are available, and
    • if present, links them to the mcap library
    • if they are not present automatically define MCAP_COMPRESSION_NO_LZ4 and MCAP_COMPRESSION_NO_ZSTD

Notes

MCAP is natively a header-only library, but in this wrapper, it is built into a binary library.

This has two benefits:

  • it allows to improve the compilation time of your project
  • simplify its usage, by removing the need to specify any macros (see the section above).

The MCAP C++ source is vendored under extern/mcap as a git submodule pinned to the tag in set(VERSION ...) in CMakeLists.txt. When bumping VERSION, also update the submodule pin:

cd extern/mcap
git fetch --tags
git checkout releases/cpp/v<new-version>
cd ../..
git add extern/mcap

About

Add support to build and install MCAP with CMake

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages