From 147c46a1a460e329d9b56923c9afd6a1e7609a86 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 29 Jul 2023 17:41:45 -0400 Subject: [PATCH] fix cmake lists and move hashmap decl to hashmap.h --- CMakeLists.txt | 9 +++++---- include/blt/nbt/nbt.h | 22 +--------------------- include/blt/parse/argparse.h | 25 +------------------------ include/blt/std/hash_map.h | 11 ----------- include/blt/std/hashmap.h | 30 ++++++++++++++++++++++++++++++ src/tests/hashmap_tests.h | 2 +- 6 files changed, 38 insertions(+), 61 deletions(-) delete mode 100755 include/blt/std/hash_map.h create mode 100755 include/blt/std/hashmap.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 876168a..999afe2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,9 @@ else() set(PARSE_FILES "") endif() -if(EXISTS libraries/parallel-hashmap) - include_directories(libraries/parallel-hashmap) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) + message("Found Parallel Hashmaps") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) endif() #include zlib if the user has it. @@ -73,9 +74,9 @@ target_include_directories(BLT PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config/) if(${ZLIB_FOUND}) target_link_libraries(BLT PUBLIC ZLIB::ZLIB) endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/libraries/parallel-hashmap) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) message("Including phmap") - target_include_directories(BLT PUBLIC libraries/parallel-hashmap) + target_include_directories(BLT PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) endif() if(MSVC) diff --git a/include/blt/nbt/nbt.h b/include/blt/nbt/nbt.h index 813432d..f9b05a1 100755 --- a/include/blt/nbt/nbt.h +++ b/include/blt/nbt/nbt.h @@ -17,27 +17,7 @@ #include "blt/std/filesystem.h" #include "blt/std/logging.h" -#ifndef HASHMAP - #if defined __has_include && __has_include() - #define HASHMAP HASHMAP - #include - #include - template - using HASHMAP = phmap::flat_hash_map(); - template - using HASHSET = phmap::flat_hash_set(); - #else - #define HASHMAP HASHMAP - #include - #include - - template - using HASHMAP = std::unordered_map(); - - template - using HASHSET = std::unordered_set(); - #endif -#endif +#include namespace blt::nbt { diff --git a/include/blt/parse/argparse.h b/include/blt/parse/argparse.h index c49f4bb..11171e9 100644 --- a/include/blt/parse/argparse.h +++ b/include/blt/parse/argparse.h @@ -11,30 +11,7 @@ #include #include #include - -#ifndef HASHMAP - #if defined __has_include && __has_include() - #define HASHMAP HASHMAP - - #include - #include - -template -using HASHMAP = phmap::flat_hash_map(); -template -using HASHSET = phmap::flat_hash_set(); - #else - #define HASHMAP HASHMAP - #include - #include - -template -using HASHMAP = std::unordered_map(); - -template -using HASHSET = std::unordered_set(); - #endif -#endif +#include namespace blt::parser { diff --git a/include/blt/std/hash_map.h b/include/blt/std/hash_map.h deleted file mode 100755 index 6800e1c..0000000 --- a/include/blt/std/hash_map.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Created by Brett on 31/03/23. - * Licensed under GNU General Public License V3.0 - * See LICENSE file for license detail - */ - -#ifndef BLT_HASH_MAP_H -#define BLT_HASH_MAP_H - - -#endif //BLT_HASH_MAP_H diff --git a/include/blt/std/hashmap.h b/include/blt/std/hashmap.h new file mode 100755 index 0000000..0a1be11 --- /dev/null +++ b/include/blt/std/hashmap.h @@ -0,0 +1,30 @@ +/* + * Created by Brett on 31/03/23. + * Licensed under GNU General Public License V3.0 + * See LICENSE file for license detail + */ + +#ifndef BLT_HASH_MAP_H +#define BLT_HASH_MAP_H + +#ifndef HASHMAP + #if defined __has_include && __has_include() +#include + #include + template + using HASHMAP = phmap::flat_hash_map; + template + using HASHSET = phmap::flat_hash_set; + #else + #include + #include + +template +using HASHMAP = std::unordered_map; + +template +using HASHSET = std::unordered_set; + #endif +#endif + +#endif //BLT_HASH_MAP_H diff --git a/src/tests/hashmap_tests.h b/src/tests/hashmap_tests.h index 1a5157b..db7ef64 100755 --- a/src/tests/hashmap_tests.h +++ b/src/tests/hashmap_tests.h @@ -7,7 +7,7 @@ #ifndef BLT_TESTS_HASHMAP_TEXTS_H #define BLT_TESTS_HASHMAP_TEXTS_H -#include +#include inline static int test_hashmaps(){