Skip to content

dk949/libut

Repository files navigation

libut

CMake build and test

Various random files I've been saving as gists, all submoduled in one big repo.

This is a collection of C++ headers (header only libraries?) for doing useful things. Such as printing human readable type names or converting string_views to numbers.

All files are in individual directories under include.

Documentation can be found at the top of each file.

Getting libut

The easiest way to include libut in your CMake project is with fetch_content.

Simply add the following to your CMakeLists.txt:

include(FetchContent)
# Set the directory to download dependencies to. Avoids putting them in $buildDir 
set(FETCHCONTENT_BASE_DIR "${PROJECT_SOURCE_DIR}/_deps")
FetchContent_Declare(
  libut
  GIT_REPOSITORY https://github.com/dk949/libut/
  GIT_TAG trunk # alternatively you can use a hash to pin exact venison to use
)
FetchContent_MakeAvailable(libut)

# assuming MY_TARGET is a valid target (executable or library)

target_link_libraries(MY_TARGET UT::target_name)

Currently available targets

  • UT::ptr_containers
  • UT::check
  • UT::pair
  • UT::add_noexcept
  • UT::sv_to_num
  • UT::realloc_unique_ptr
  • UT::assert
  • UT::resource
  • UT::demangle
  • UT::constexpr_hash
  • UT::trim
  • UT::pack_loops
  • UT::curry
  • UT::defer
  • UT::print

A special target UT::all is also available, combining all of the above.

Testing

Test can be ran using Catch2

git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
./vcpkg/vcpkg install catch2
cmake --preset local
cmake --build build
./build/tests/libut_tests
# or
ctest --output-on-failure --test-dir build/tests

NOTE: you can use the local preset to build with ninja, or default to build with the default generator (e.g. "Unix Makefiles" on linux)

License

Each header file has a license (usually at the bottom). For files which don't (such as scripts and CMakeLists.txts), see LICENSE file in the root of this repo.

About

Various C++ utilities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published