Skip to content

Commit c0855c9

Browse files
Add xxHash example (#549)
* Add xxHash example * Fix link error * run code formatters --------- Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
1 parent 7e81149 commit c0855c9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

examples/xxHash/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
2+
3+
project(CPMxxHashExample)
4+
5+
# ---- Dependencies ----
6+
7+
include(../../cmake/CPM.cmake)
8+
9+
CPMAddPackage(
10+
GITHUB_REPOSITORY Cyan4973/xxHash
11+
GIT_TAG v0.8.2
12+
OPTIONS "XXHASH_BUILD_ENABLE_INLINE_API OFF" "XXHASH_BUILD_XXHSUM OFF"
13+
SOURCE_SUBDIR cmake_unofficial
14+
)
15+
16+
# ---- Executable ----
17+
18+
add_executable(CPMxxHashExample main.cpp)
19+
target_compile_features(CPMxxHashExample PRIVATE cxx_std_17)
20+
target_link_libraries(CPMxxHashExample xxHash::xxhash)

examples/xxHash/main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <xxh3.h>
2+
3+
#include <iostream>
4+
5+
int main() {
6+
std::string example = "Hello World!";
7+
XXH64_hash_t hash = XXH3_64bits(example.data(), example.size());
8+
9+
std::cout << "Hash: " << hash << std::endl;
10+
11+
return 0;
12+
}

0 commit comments

Comments
 (0)