fix cmake lists and move hashmap decl to hashmap.h

v1
Brett 2023-07-29 17:41:45 -04:00
parent 79900dbf1a
commit 147c46a1a4
6 changed files with 38 additions and 61 deletions

View File

@ -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)

View File

@ -17,27 +17,7 @@
#include "blt/std/filesystem.h"
#include "blt/std/logging.h"
#ifndef HASHMAP
#if defined __has_include && __has_include(<parallel_hashmap/phmap.h>)
#define HASHMAP HASHMAP
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap_fwd_decl.h>
template<typename K, typename V>
using HASHMAP = phmap::flat_hash_map<K, V>();
template<typename K>
using HASHSET = phmap::flat_hash_set<K>();
#else
#define HASHMAP HASHMAP
#include <unordered_map>
#include <unordered_set>
template<typename K, typename V>
using HASHMAP = std::unordered_map<K, V>();
template<typename K>
using HASHSET = std::unordered_set<K>();
#endif
#endif
#include <blt/std/hashmap.h>
namespace blt::nbt {

View File

@ -11,30 +11,7 @@
#include <string>
#include <initializer_list>
#include <optional>
#ifndef HASHMAP
#if defined __has_include && __has_include(<parallel_hashmap/phmap.h>)
#define HASHMAP HASHMAP
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap_fwd_decl.h>
template<typename K, typename V>
using HASHMAP = phmap::flat_hash_map<K, V>();
template<typename K>
using HASHSET = phmap::flat_hash_set<K>();
#else
#define HASHMAP HASHMAP
#include <unordered_map>
#include <unordered_set>
template<typename K, typename V>
using HASHMAP = std::unordered_map<K, V>();
template<typename K>
using HASHSET = std::unordered_set<K>();
#endif
#endif
#include <blt/std/hashmap.h>
namespace blt::parser {

View File

@ -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

30
include/blt/std/hashmap.h Executable file
View File

@ -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(<parallel_hashmap/phmap.h>)
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap_fwd_decl.h>
template<typename K, typename V>
using HASHMAP = phmap::flat_hash_map<K, V>;
template<typename K>
using HASHSET = phmap::flat_hash_set<K>;
#else
#include <unordered_map>
#include <unordered_set>
template<typename K, typename V>
using HASHMAP = std::unordered_map<K, V>;
template<typename K>
using HASHSET = std::unordered_set<K>;
#endif
#endif
#endif //BLT_HASH_MAP_H

View File

@ -7,7 +7,7 @@
#ifndef BLT_TESTS_HASHMAP_TEXTS_H
#define BLT_TESTS_HASHMAP_TEXTS_H
#include <blt/std/hash_map.h>
#include <blt/std/hashmap.h>
inline static int test_hashmaps(){