Skip to content

Add xxHash example #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/xxHash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(CPMxxHashExample)

# ---- Dependencies ----

include(../../cmake/CPM.cmake)

CPMAddPackage(
GITHUB_REPOSITORY Cyan4973/xxHash
GIT_TAG v0.8.2
OPTIONS "XXHASH_BUILD_ENABLE_INLINE_API OFF" "XXHASH_BUILD_XXHSUM OFF"
SOURCE_SUBDIR cmake_unofficial
)

# ---- Executable ----

add_executable(CPMxxHashExample main.cpp)
target_compile_features(CPMxxHashExample PRIVATE cxx_std_17)
target_link_libraries(CPMxxHashExample xxHash::xxhash)
12 changes: 12 additions & 0 deletions examples/xxHash/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <xxh3.h>

#include <iostream>

int main() {
std::string example = "Hello World!";
XXH64_hash_t hash = XXH3_64bits(example.data(), example.size());

std::cout << "Hash: " << hash << std::endl;

return 0;
}