Skip to content

Commit

Permalink
Add CMake main project support
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Dec 3, 2024
1 parent f918544 commit 26b1602
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/__build__/
69 changes: 69 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 10 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 26b1602

Please sign in to comment.