2022-09-30 22:36:59 -04:00
|
|
|
#[===================================================================[
|
|
|
|
|
parallel-hashmap library by Gregory Popovitch
|
|
|
|
|
|
|
|
|
|
CMake projects that wish to use this library may do
|
|
|
|
|
something like :
|
|
|
|
|
|
|
|
|
|
include(FetchContent)
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
|
parallel-hashmap
|
|
|
|
|
GIT_REPOSITORY https://github.com/greg7mdp/parallel-hashmap.git
|
2022-10-01 16:04:30 -04:00
|
|
|
GIT_TAG v1.3.8 # adjust tag/branch/commit as needed
|
2022-09-30 22:36:59 -04:00
|
|
|
)
|
|
|
|
|
FetchContent_MakeAvailable(parallel-hashmap)
|
|
|
|
|
|
|
|
|
|
...
|
2023-01-19 16:24:50 -05:00
|
|
|
include_directories(${parallel-hashmap_SOURCE_DIR})
|
2022-09-30 22:36:59 -04:00
|
|
|
|
|
|
|
|
#]===================================================================]
|
|
|
|
|
|
2021-11-18 21:06:48 -05:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
2019-03-22 21:26:45 -04:00
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
|
|
|
|
|
include(DetectVersion)
|
|
|
|
|
|
2022-09-30 22:36:59 -04:00
|
|
|
cmake_policy(SET CMP0048 NEW) ## set VERSION as documented by the project() command.
|
|
|
|
|
cmake_policy(SET CMP0076 NEW) ## accept new policy
|
|
|
|
|
|
|
|
|
|
if(NOT CMAKE_CXX_STANDARD)
|
|
|
|
|
set(CMAKE_CXX_STANDARD 11) ## compile with C++11 support
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT CMAKE_CXX_STANDARD_REQUIRED)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT DEFINED PHMAP_MASTER_PROJECT)
|
|
|
|
|
set(PHMAP_MASTER_PROJECT OFF)
|
|
|
|
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
|
|
|
set(PHMAP_MASTER_PROJECT ON)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2019-03-24 10:28:46 -04:00
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
project(phmap VERSION ${DETECTED_PHMAP_VERSION} LANGUAGES CXX)
|
|
|
|
|
|
2022-09-30 22:36:59 -04:00
|
|
|
## ----------------------------- options -----------------------------
|
|
|
|
|
option(PHMAP_INSTALL "Enable installation" ${PHMAP_MASTER_PROJECT})
|
|
|
|
|
|
|
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
set(PHMAP_DIR parallel_hashmap)
|
2022-05-07 16:12:57 -04:00
|
|
|
set(PHMAP_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap.h
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_base.h
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_bits.h
|
2022-09-30 22:36:59 -04:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_config.h
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_dump.h
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_fwd_decl.h
|
2022-05-07 16:12:57 -04:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_utils.h
|
2022-09-30 22:36:59 -04:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/meminfo.h
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/btree.h)
|
2019-03-22 21:26:45 -04:00
|
|
|
|
2019-03-23 23:26:11 -04:00
|
|
|
include(helpers)
|
2019-03-22 21:26:45 -04:00
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
add_library(${PROJECT_NAME} INTERFACE)
|
2019-03-22 21:26:45 -04:00
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
target_sources(${PROJECT_NAME} INTERFACE ${PHMAP_HEADERS})
|
2019-03-22 21:26:45 -04:00
|
|
|
|
|
|
|
|
target_include_directories(
|
2019-03-23 10:33:16 -04:00
|
|
|
${PROJECT_NAME} INTERFACE
|
2019-03-26 08:35:11 -04:00
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
2019-03-23 10:33:16 -04:00
|
|
|
$<INSTALL_INTERFACE:include>)
|
|
|
|
|
|
2022-09-30 22:36:59 -04:00
|
|
|
if(PHMAP_INSTALL)
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
|
|
install(
|
|
|
|
|
DIRECTORY ${PROJECT_SOURCE_DIR}/${PHMAP_DIR}/
|
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PHMAP_DIR})
|
|
|
|
|
|
|
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
|
EXPORT ${PROJECT_NAME}-targets)
|
|
|
|
|
|
|
|
|
|
export(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
|
|
|
|
endif()
|
2019-03-23 10:33:16 -04:00
|
|
|
|
|
|
|
|
## ------------------------- building tests and examples -------------
|
2022-09-30 22:36:59 -04:00
|
|
|
option(PHMAP_BUILD_TESTS "Whether or not to build the tests" ${PHMAP_MASTER_PROJECT})
|
|
|
|
|
option(PHMAP_BUILD_EXAMPLES "Whether or not to build the examples" ${PHMAP_MASTER_PROJECT})
|
2019-03-23 10:33:16 -04:00
|
|
|
|
2019-03-27 20:37:51 -04:00
|
|
|
if(MSVC)
|
2019-04-06 14:00:14 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
2019-03-27 20:37:51 -04:00
|
|
|
endif()
|
|
|
|
|
|
2023-06-25 14:48:00 -04:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR})
|
|
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
if (PHMAP_BUILD_TESTS)
|
2019-03-24 18:44:50 -04:00
|
|
|
|
2022-09-30 22:36:59 -04:00
|
|
|
if (NOT PHMAP_GTEST_LIBS)
|
|
|
|
|
include(cmake/DownloadGTest.cmake)
|
|
|
|
|
|
|
|
|
|
check_target(gtest)
|
|
|
|
|
check_target(gtest_main)
|
|
|
|
|
check_target(gmock)
|
|
|
|
|
set(PHMAP_GTEST_LIBS gmock_main)
|
|
|
|
|
endif()
|
2019-03-23 23:26:11 -04:00
|
|
|
|
2019-03-26 09:00:55 -04:00
|
|
|
enable_testing()
|
|
|
|
|
|
2019-03-25 21:18:16 -04:00
|
|
|
## ---------------- regular hash maps ----------------------------
|
|
|
|
|
phmap_cc_test(NAME container_memory SRCS "tests/container_memory_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-23 23:26:11 -04:00
|
|
|
|
2019-03-25 21:18:16 -04:00
|
|
|
phmap_cc_test(NAME hash_policy_testing SRCS "tests/hash_policy_testing_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-24 18:10:20 -04:00
|
|
|
|
2019-03-25 21:18:16 -04:00
|
|
|
phmap_cc_test(NAME node_hash_policy SRCS "tests/node_hash_policy_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-24 18:10:20 -04:00
|
|
|
|
2019-03-25 21:18:16 -04:00
|
|
|
phmap_cc_test(NAME raw_hash_set SRCS "tests/raw_hash_set_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 21:18:16 -04:00
|
|
|
|
|
|
|
|
phmap_cc_test(NAME raw_hash_set_allocator SRCS "tests/raw_hash_set_allocator_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 21:18:16 -04:00
|
|
|
|
|
|
|
|
## ---------------- regular hash maps ----------------------------
|
|
|
|
|
phmap_cc_test(NAME flat_hash_set SRCS "tests/flat_hash_set_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-24 18:10:20 -04:00
|
|
|
|
2019-03-25 21:18:16 -04:00
|
|
|
phmap_cc_test(NAME flat_hash_map SRCS "tests/flat_hash_map_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 21:18:16 -04:00
|
|
|
|
2019-03-24 18:10:20 -04:00
|
|
|
phmap_cc_test(NAME node_hash_map SRCS "tests/node_hash_map_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-24 18:10:20 -04:00
|
|
|
|
|
|
|
|
phmap_cc_test(NAME node_hash_set SRCS "tests/node_hash_set_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-24 18:10:20 -04:00
|
|
|
|
2019-03-25 21:18:16 -04:00
|
|
|
## --------------- parallel hash maps -----------------------------------------------
|
|
|
|
|
phmap_cc_test(NAME parallel_flat_hash_map SRCS "tests/parallel_flat_hash_map_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 21:18:16 -04:00
|
|
|
|
|
|
|
|
phmap_cc_test(NAME parallel_flat_hash_set SRCS "tests/parallel_flat_hash_set_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 21:18:16 -04:00
|
|
|
|
2019-03-25 07:58:34 -04:00
|
|
|
phmap_cc_test(NAME parallel_node_hash_map SRCS "tests/parallel_node_hash_map_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 07:58:34 -04:00
|
|
|
|
|
|
|
|
phmap_cc_test(NAME parallel_node_hash_set SRCS "tests/parallel_node_hash_set_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-03-25 07:58:34 -04:00
|
|
|
|
2019-04-07 09:19:04 -04:00
|
|
|
phmap_cc_test(NAME parallel_flat_hash_map_mutex SRCS "tests/parallel_flat_hash_map_mutex_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-04-07 09:19:04 -04:00
|
|
|
|
2019-08-18 22:50:47 +08:00
|
|
|
phmap_cc_test(NAME dump_load SRCS "tests/dump_load_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2019-12-30 13:42:48 -05:00
|
|
|
|
2022-05-07 10:12:35 -04:00
|
|
|
phmap_cc_test(NAME erase_if SRCS "tests/erase_if_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS})
|
2022-05-07 10:12:35 -04:00
|
|
|
|
2019-12-30 13:42:48 -05:00
|
|
|
## --------------- btree -----------------------------------------------
|
|
|
|
|
phmap_cc_test(NAME btree SRCS "tests/btree_test.cc"
|
2022-09-30 22:36:59 -04:00
|
|
|
DEPS ${PHMAP_GTEST_LIBS})
|
2019-08-18 22:50:47 +08:00
|
|
|
|
|
|
|
|
|
2019-03-23 10:33:16 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (PHMAP_BUILD_EXAMPLES)
|
2019-04-18 21:59:12 -04:00
|
|
|
if(NOT MSVC)
|
2023-06-25 14:48:00 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wno-unused")
|
|
|
|
|
if (NOT CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wno-gnu-zero-variadic-macro-arguments")
|
|
|
|
|
endif()
|
2019-12-31 14:21:24 -05:00
|
|
|
else()
|
2021-11-08 19:54:12 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /Zc:__cplusplus")
|
2019-04-18 21:59:12 -04:00
|
|
|
endif()
|
|
|
|
|
|
2019-04-07 21:44:55 -04:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
2019-06-15 19:50:43 -04:00
|
|
|
add_executable(ex_allmaps examples/allmaps.cc phmap.natvis)
|
|
|
|
|
add_executable(ex_basic examples/basic.cc phmap.natvis)
|
|
|
|
|
add_executable(ex_bench examples/bench.cc phmap.natvis)
|
|
|
|
|
add_executable(ex_emplace examples/emplace.cc phmap.natvis)
|
2022-06-20 19:54:26 -04:00
|
|
|
if (MSVC)
|
|
|
|
|
add_executable(ex_lazy_emplace_l examples/lazy_emplace_l.cc phmap.natvis)
|
|
|
|
|
endif()
|
2019-09-08 11:12:12 -04:00
|
|
|
add_executable(ex_serialize examples/serialize.cc phmap.natvis)
|
2023-06-11 10:02:00 -04:00
|
|
|
#target_include_directories(ex_serialize PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../cereal/include>)
|
2019-06-15 19:50:43 -04:00
|
|
|
add_executable(ex_hash_std examples/hash_std.cc phmap.natvis)
|
|
|
|
|
add_executable(ex_hash_value examples/hash_value.cc phmap.natvis)
|
2022-07-19 20:32:09 -04:00
|
|
|
add_executable(ex_hash examples/hash.cc phmap.natvis)
|
2019-06-15 19:50:43 -04:00
|
|
|
add_executable(ex_two_files examples/f1.cc examples/f2.cc phmap.natvis)
|
|
|
|
|
add_executable(ex_insert_bench examples/insert_bench.cc phmap.natvis)
|
|
|
|
|
add_executable(ex_knucleotide examples/knucleotide.cc phmap.natvis)
|
2019-08-13 22:42:37 +08:00
|
|
|
add_executable(ex_dump_load examples/dump_load.cc phmap.natvis)
|
2019-12-30 13:42:48 -05:00
|
|
|
add_executable(ex_btree examples/btree.cc phmap.natvis)
|
2023-06-25 21:36:38 -04:00
|
|
|
add_executable(ex_hash_bench examples/hash_bench.cc phmap.natvis)
|
2020-07-26 17:35:55 -04:00
|
|
|
add_executable(ex_matt examples/matt.cc phmap.natvis)
|
2023-04-09 18:48:26 -04:00
|
|
|
add_executable(ex_mt_word_counter examples/mt_word_counter.cc phmap.natvis)
|
2019-08-13 22:42:37 +08:00
|
|
|
|
2019-04-07 21:44:55 -04:00
|
|
|
target_link_libraries(ex_knucleotide Threads::Threads)
|
2019-04-11 19:02:35 -04:00
|
|
|
target_link_libraries(ex_bench Threads::Threads)
|
2019-03-23 10:33:16 -04:00
|
|
|
endif()
|
|
|
|
|
|