On Windows using "loot" causes a name collisions with LOOT itself: - for the MSVC project name, it clashes with LOOT's own project, despite the difference in case. This means that you can't build LOOT in Visual Studio when using FetchContent to handle the libloot dependency (running CMake on the CLI works though). - for the PDB file, LOOT has LOOT.pdb and libloot has loot.pdb, which appear to be the same due to file paths being case-insensitive. This makes it more difficult to debug LOOT with the relevant debug info loaded. Renaming the CMake target adds a "lib" prefix to the Visual Studio project name and the artifact filenames: - loot.vcxproj* -> libloot.vcxproj* - loot.dll -> libloot.dll - loot.lib -> libloot.lib - loot.pdb -> libloot.pdb The Linux build artifact filenames are unchanged, as they already had the "lib" prefix.
libloot C++ wrapper
This is a wrapper around libloot that provides a C++ interface that's ABI-compatible with libloot v0.27.0.
The wrapper has two layers:
- a static library built using Cargo, which provides a C++ interface
- a shared library built using CMake, which wraps that C++ interface to provide another that is more idiomatic.
Build
The prerequisites for building libloot and its C++ wrapper are CMake, the Rust toolchain and a C++ toolchain. The CI builds currently use a recent version of CMake, the latest version of Rust, MSVC 2022 on Windows and GCC 13 on Linux, so alternatives such as other versions, Mingw-w64 or Clang may not work without modifications.
To build a release build with debug info on Windows:
cmake -B build .
cmake --build build --parallel --config RelWithDebInfo
To do the same on Linux:
cmake -B build . -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build --parallel
To build a debug build, pass Debug instead of RelWithDebInfo.
The following CMake variables can be used to configure the build:
| Parameter | Values | Default | Description |
|---|---|---|---|
LIBLOOT_BUILD_SHARED |
ON, OFF |
ON |
Whether or not to build a shared libloot binary. |
LIBLOOT_BUILD_TESTS |
ON, OFF |
ON |
Whether or not to build libloot's tests. |
LIBLOOT_INSTALL_DOCS |
ON, OFF |
ON |
Whether or not to install libloot's docs (which need to be built separately). |
RUN_CLANG_TIDY |
ON, OFF |
OFF |
Whether or not to run clang-tidy during build. Has no effect when using CMake's Visual Studio generator. |
An example of using libloot with CMake's FetchContent:
set(LIBLOOT_BUILD_TESTS OFF)
set(LIBLOOT_INSTALL_DOCS OFF)
FetchContent_Declare(libloot
GIT_REPOSITORY "https://github.com/loot/libloot.git"
GIT_TAG "master" # Better to use a specific commit hash.
SOURCE_SUBDIR "cpp")
FetchContent_MakeAvailable(libloot)
add_executable(myapp ${MYAPP_SOURCES})
target_link_libraries(myapp PRIVATE libloot::loot)
Documentation
Install Doxygen, Python and uv and make sure they're accessible from your PATH, then run:
uv run --directory ../docs -- sphinx-build -b html . build/html
Tests
If the tests are built they can be run using:
ctest --test-dir build --output-on-failure --parallel -V
Packaging
To package the build:
cpack --config build/CPackConfig.cmake -C RelWithDebInfo