Skip to content

Latest commit

 

History

History
60 lines (50 loc) · 2.15 KB

INSTALL.md

File metadata and controls

60 lines (50 loc) · 2.15 KB

Building with stringpool

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.

Setting up a vcpkg dependency on stringpool

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.

  1. Add "stringpool" to your list of dependencies in your project's vcpkg.json.

  2. If you don't already have a file named vcpkg-configuration.json in your project, add one with the following content. This file should be located in the same directory as your vcpkg.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.)

  1. Do a CMake + vcpkg build as you normally would (cmake --preset ...).

CMake setup

  1. Add a find_package declaration such as
find_package(stringpool REQUIRED)
  1. 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.

Include stringpool.h

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;
}