Merge pull request #36 from BlackMATov/dev

Dev
This commit is contained in:
2023-01-05 09:15:37 +07:00
committed by GitHub
29 changed files with 162 additions and 57 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
build/*
install/*
.clangd/*
.vscode/*
CMakeLists.txt.user

11
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [{
"name": "LLDB Debug",
"type": "lldb",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"cwd": "${workspaceFolder}"
}]
}

29
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"[cpp]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"[cmake]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"[python]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"clangd.arguments": [
"--all-scopes-completion",
"--background-index",
"--clang-tidy",
"--compile-commands-dir=${workspaceFolder}/.clangd",
"--completion-style=detailed",
"--header-insertion=never"
],
"cmake.copyCompileCommands": "${workspaceFolder}/.clangd/compile_commands.json"
}

View File

@@ -1,36 +1,95 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
if(NOT DEFINED PROJECT_NAME)
set(BUILD_AS_STANDALONE ON)
else()
set(BUILD_AS_STANDALONE OFF)
endif()
project(flat.hpp
VERSION "0.0.1"
DESCRIPTION "Library of flat vector-like based associative containers"
HOMEPAGE_URL "https://github.com/blackmatov/flat.hpp")
project(flat.hpp)
#
# LIBRARY
#
add_library(${PROJECT_NAME} INTERFACE)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
target_include_directories(${PROJECT_NAME} INTERFACE headers)
add_library(flat.hpp::flat.hpp ALIAS ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} INTERFACE
cxx_std_17)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
#
# BUILD_AS_STANDALONE
# INSTALL
#
if(NOT ${BUILD_AS_STANDALONE})
return()
if(PROJECT_IS_TOP_LEVEL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(FLAT_HPP_INSTALL_CONFIG_DIR
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(FLAT_HPP_INSTALL_CONFIG_INPUT
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in")
set(FLAT_HPP_INSTALL_GENERATED_CONFIG_CMAKE
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake")
set(FLAT_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake")
configure_package_config_file(
"${FLAT_HPP_INSTALL_CONFIG_INPUT}"
"${FLAT_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
INSTALL_DESTINATION "${FLAT_HPP_INSTALL_CONFIG_DIR}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${FLAT_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
DIRECTORY headers/${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION "${FLAT_HPP_INSTALL_CONFIG_DIR}")
install(
FILES "${FLAT_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
"${FLAT_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
DESTINATION "${FLAT_HPP_INSTALL_CONFIG_DIR}")
endif()
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
#
# DEVELOPER
#
enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(PROJECT_IS_TOP_LEVEL)
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
include(EnableASan)
include(EnableGCov)
include(EnableUBSan)
enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
add_subdirectory(vendors)
add_subdirectory(untests)
include(EnableASan)
include(EnableGCov)
include(EnableUBSan)
add_subdirectory(vendors)
add_subdirectory(untests)
endif()

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -41,7 +41,7 @@ Also, you can add the root repository directory to your [cmake](https://cmake.or
```cmake
add_subdirectory(external/flat.hpp)
target_link_libraries(your_project_target PUBLIC flat.hpp)
target_link_libraries(your_project_target PUBLIC flat.hpp::flat.hpp)
```
## API

3
cmake/Config.cmake.in Normal file
View File

@@ -0,0 +1,3 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/flat.hpp-targets.cmake")

View File

@@ -1,14 +1,15 @@
# https://clang.llvm.org/docs/AddressSanitizer.html
add_library(enable_asan INTERFACE)
add_library(${PROJECT_NAME}.enable_asan INTERFACE)
add_library(${PROJECT_NAME}::enable_asan ALIAS ${PROJECT_NAME}.enable_asan)
target_compile_options(enable_asan INTERFACE
target_compile_options(${PROJECT_NAME}.enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope
-fsanitize-address-use-after-return=always)
target_link_options(enable_asan INTERFACE
target_link_options(${PROJECT_NAME}.enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope

View File

@@ -1,9 +1,10 @@
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
add_library(enable_gcov INTERFACE)
add_library(${PROJECT_NAME}.enable_gcov INTERFACE)
add_library(${PROJECT_NAME}::enable_gcov ALIAS ${PROJECT_NAME}.enable_gcov)
target_compile_options(enable_gcov INTERFACE
target_compile_options(${PROJECT_NAME}.enable_gcov INTERFACE
--coverage)
target_link_options(enable_gcov INTERFACE
target_link_options(${PROJECT_NAME}.enable_gcov INTERFACE
--coverage)

View File

@@ -1,11 +1,12 @@
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
add_library(enable_ubsan INTERFACE)
add_library(${PROJECT_NAME}.enable_ubsan INTERFACE)
add_library(${PROJECT_NAME}::enable_ubsan ALIAS ${PROJECT_NAME}.enable_ubsan)
target_compile_options(enable_ubsan INTERFACE
target_compile_options(${PROJECT_NAME}.enable_ubsan INTERFACE
-fsanitize=undefined
-fno-omit-frame-pointer)
target_link_options(enable_ubsan INTERFACE
target_link_options(${PROJECT_NAME}.enable_ubsan INTERFACE
-fsanitize=undefined
-fno-omit-frame-pointer)

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "flat_map.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -4,7 +4,7 @@ file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE flat.hpp)
target_link_libraries(${PROJECT_NAME} PRIVATE flat.hpp::flat.hpp)
#
# setup defines
@@ -23,14 +23,14 @@ setup_defines_for_target(${PROJECT_NAME})
#
function(setup_libraries_for_target TARGET)
target_link_libraries(${TARGET} PRIVATE doctest_with_main)
target_link_libraries(${TARGET} PRIVATE doctest::doctest_with_main)
if(${BUILD_WITH_COVERAGE})
target_link_libraries(${TARGET} PRIVATE enable_gcov)
target_link_libraries(${TARGET} PRIVATE flat.hpp::enable_gcov)
endif()
if(${BUILD_WITH_SANITIZERS})
target_link_libraries(${TARGET} PRIVATE enable_asan enable_ubsan)
target_link_libraries(${TARGET} PRIVATE flat.hpp::enable_asan flat.hpp::enable_ubsan)
endif()
endfunction()

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat.hpp>

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_map.hpp>

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_multimap.hpp>

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_multiset.hpp>

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_set.hpp>

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <doctest/doctest.h>