stringpool is essentially just a CMake project. It depends on C++20, gtest, and xxhash. If CMake can find these on your system, stringpool should build. However, you will likely find using vcpkg to be easier.
When your project uses vcpkg to depend on stringpool, vcpkg will automatically acquire stringpool's transitive dependencies. If you're new to vcpkg, consult vcpkg documentation, as the steps here don't cover setup of vcpkg itself.
-
Add
"stringpool"to your list of dependencies in your project'svcpkg.json. -
If you don't already have a file named
vcpkg-configuration.jsonin your project, add one with the following content. This file should be located in the same directory as yourvcpkg.json.
{
"default-registry": {
"kind": "builtin",
"baseline": "<latest git commit hash of official registry>"
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/geoff-m/vcpkg-registry",
"baseline": "<latest git commit hash of geoff-m/vcpkg-registry>",
"packages": ["stringpool"]
}
]
}(If your project already has a vcpkg-configuration.json, merge the "registries" entry above into it.)
- Do a CMake + vcpkg build as you normally would (
cmake --preset ...).
- Add a
find_packagedeclaration such as
find_package(stringpool REQUIRED)- Link your target to
stringpool::stringpool, e.g.
target_link_libraries(my-app PRIVATE stringpool::stringpool)Note that including stringpool requires at least C++20.
Linking to stringpool should automatically set CMAKE_CXX_STANDARD to 20 if it is unspecified.
If you force the language version to less than 20, expect the build to fail.
Sample usage:
#include <stringpool.h>
#include <format>
#include <iostream>
int main() {
stringpool::pool p;
const auto greeting = p.intern("Hello");
std::cout << std::format("{}, World!\n", greeting);
return 0;
}