2
0
mirror of https://github.com/boostorg/hash2.git synced 2026-01-19 04:12:12 +00:00

Add CMake main project support

This commit is contained in:
Peter Dimov
2024-12-03 22:26:40 +02:00
parent f91854437d
commit 26b16023dc
4 changed files with 96 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/__build__/

View File

@@ -23,8 +23,77 @@ target_link_libraries(boost_hash2
target_compile_features(boost_hash2 INTERFACE cxx_std_11)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(CTest) # defines BUILD_TESTING
include(FetchContent)
FetchContent_Declare(boostorg_cmake GIT_REPOSITORY https://github.com/boostorg/cmake GIT_TAG master)
FetchContent_MakeAvailable(boostorg_cmake)
FetchContent_GetProperties(boostorg_cmake)
list(APPEND CMAKE_MODULE_PATH ${boostorg_cmake_SOURCE_DIR}/include)
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(deps
# hash2
assert
config
container_hash
describe
mp11
# tests
array
core
utility
# benchmark
unordered
# example
endian
# secondaries
static_assert
throw_exception
io
preprocessor
type_traits
predef
)
set(BUILD_TESTING OFF) # Hide cache variable
list(LENGTH deps n)
set(i 0)
foreach(dep IN LISTS deps)
math(EXPR i "${i}+1")
message(STATUS "Fetching boostorg/${dep} [${i}/${n}]")
FetchContent_Declare(boostorg_${dep} GIT_REPOSITORY https://github.com/boostorg/${dep} GIT_TAG master EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(boostorg_${dep})
endforeach()
unset(BUILD_TESTING)
add_subdirectory(benchmark)
add_subdirectory(example)
endif()

10
benchmark/CMakeLists.txt Normal file
View File

@@ -0,0 +1,10 @@
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
link_libraries(Boost::hash2 Boost::core Boost::unordered)
add_executable(buffer buffer.cpp)
add_executable(unordered unordered.cpp)
add_executable(average average.cpp)
add_executable(keys keys.cpp)

16
example/CMakeLists.txt Normal file
View File

@@ -0,0 +1,16 @@
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
link_libraries(Boost::hash2 Boost::unordered Boost::endian)
add_executable(md5sum md5sum.cpp)
add_executable(hash2sum hash2sum.cpp)
add_executable(compile_time compile_time.cpp)
add_executable(compile_time_2 compile_time_2.cpp)
add_executable(hash_without_seed hash_without_seed.cpp)
add_executable(hash_with_uint64_seed hash_with_uint64_seed.cpp)
add_executable(hash_with_byte_seed hash_with_byte_seed.cpp)
add_executable(hash_with_any_seed hash_with_any_seed.cpp)
add_executable(hash_32_64 hash_32_64.cpp)
add_executable(xxh128_from_xxh64 xxh128_from_xxh64.cpp)