Getting Started
UTL requires a C++17 compiler. There are no runtime dependencies; the tests use GoogleTest.
CMake with find_package
Install the library once:
git clone https://github.com/adamek727/Unit-Template-Library
cd Unit-Template-Library
cmake -B build
cmake --install build
Then in your project:
find_package(utl REQUIRED)
target_link_libraries(your_target utl::utl)
CMake with add_subdirectory
Add the repository as a git submodule:
git submodule add https://github.com/adamek727/Unit-Template-Library libs/utl
And in your CMakeLists.txt:
add_subdirectory(libs/utl)
target_link_libraries(your_target utl::utl)
CMake with FetchContent
include(FetchContent)
FetchContent_Declare(utl
GIT_REPOSITORY https://github.com/adamek727/Unit-Template-Library
GIT_TAG v3.1.0)
FetchContent_MakeAvailable(utl)
target_link_libraries(your_target utl::utl)
Conan
A header-only recipe ships in conanfile.py. Until the package is on Conan
Center, export it locally with conan create ., then depend on
unit-template-library/3.1.0 and link utl::utl.
vcpkg
An overlay port lives in packaging/vcpkg/ports:
vcpkg install unit-template-library --overlay-ports=packaging/vcpkg/ports
In every case the imported CMake target is utl::utl.
Single header
For a zero-setup drop-in, copy single_include/utl/utl.hpp (an amalgamation of
the whole library generated by tools/amalgamate.py) into your project and
include it directly. The opt-in utl/io.hpp is not part of the amalgamation.
Include the headers
#include <utl/utl.hpp>
Building the examples and tests
git clone https://github.com/adamek727/Unit-Template-Library
cd Unit-Template-Library
cmake -B build -DENABLE_TESTS=1 -DENABLE_EXAMPLES=1
cmake --build build -j
ctest --test-dir build
./build/examples/usage_example