Skip to content

A header-only library for things I keep writing for every project

License

Notifications You must be signed in to change notification settings

snewell/houseguest

Repository files navigation

Houseguest

codacy

Houseguest is a header-only library that provides some functionality I keep writing for every project I touch.

Building/Installing

Houseguest's build is managed using CMake; because it's header-only, the build only manages unit tests and building documentation.

$ mkdir build_dir
$ cd build_dir
$ cmake /path/to/houseguest
$ make && make test
$ make docs
$ make install

The following options are supported:

  • HOUSEGUEST_BUILD_TESTS (defaults to ON). Build unit tests in all supported standards. This option requires GTest. GTest (and required flags) will be detected using find_package.
  • HOUSEGUEST_BUILD_DOCS (defualts to ON). Add a target (docs) to generate documentation; documentation will also be installed. This option requires Doxygen. Doxygen's path will be detected using find_program.
  • HOUSEGUEST_MAXIMUM_TEST_STANDARD (defaults to 17). Control which C++ standards are used when building tests. Tests will be built for each standard supported, up to the maximum standard specified. Note that this option provides no sanity checking, so 14, 15, and 16 each have the same result (tests will be built for C++14, but no later standard). The default represents the latest standard houseguest supports, so setting this option to a higher standard (e.g., 20) has no effect.

Using

The simplest way to include houseguest in a project is using CMake. First, add the appropriate find_package command, then include houseguest in any target_link_libraries declarations.

find_package(Houseguest REQUIRED)
add_executable(foo foo.cpp)
target_link_libraries(foo PRIVATE Houseguest::houseguest)
add_library(bar bar.cpp)
target_link_libraries(bar PRIVATE Houseguest::houseguest)

Provided find_package worked, target_link_libraries will handle the necessary include paths. It will not provide any necessary standard flags (e.g., std=c++17) since houseguest is designed to support multiple standards; add those if your compiler defaults to a standard earlier than C++14.

Supported Standards

Right now, I'm only targetting C++14 and later. Some things will change depending on the standard (e.g., default types if later standards provide superior options), but these should be transparent for the most part. If compiled using a later standard, additional static_asserts and attributes will be leveraged to improve compiler diagnostics.

Supported Compilers

Houseguest should be very portable and work with any standards-compliant compiler. It's known to work correctly (i.e., compiles without warnings and all tests pass) with gcc-7.3.0 and clang-6.0.0 (with both libc++ and libstdc++). I also run several static analysis tools (cppcheck, clang-tidy, and clang's static analyzer) and regularly build with clang's sanitizers (address, thread, and undefined behavior) to try and ferret out portability and quality issues.

For reference, the warning flags I use are: -pipe -Wall -Wextra -Wshadow -Wundef -pedantic. These aren't embedded in CMakeLists.txt to avoid portability issues with compilers I don't have access to (e.g., Visual Studio).

About

A header-only library for things I keep writing for every project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published