Skip to content

Commit a010218

Browse files
authored
Merge pull request #36 from BlackMATov/dev
Dev
2 parents 44691f0 + 6c5f8a8 commit a010218

29 files changed

+162
-57
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build/*
2+
install/*
23
.clangd/*
3-
.vscode/*
44
CMakeLists.txt.user

Diff for: .vscode/launch.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [{
4+
"name": "LLDB Debug",
5+
"type": "lldb",
6+
"request": "launch",
7+
"program": "${command:cmake.launchTargetPath}",
8+
"args": [],
9+
"cwd": "${workspaceFolder}"
10+
}]
11+
}

Diff for: .vscode/settings.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"[cpp]": {
3+
"files.encoding": "utf8",
4+
"files.insertFinalNewline": true,
5+
"files.trimFinalNewlines": true,
6+
"files.trimTrailingWhitespace": true
7+
},
8+
"[cmake]": {
9+
"files.encoding": "utf8",
10+
"files.insertFinalNewline": true,
11+
"files.trimFinalNewlines": true,
12+
"files.trimTrailingWhitespace": true
13+
},
14+
"[python]": {
15+
"files.encoding": "utf8",
16+
"files.insertFinalNewline": true,
17+
"files.trimFinalNewlines": true,
18+
"files.trimTrailingWhitespace": true
19+
},
20+
"clangd.arguments": [
21+
"--all-scopes-completion",
22+
"--background-index",
23+
"--clang-tidy",
24+
"--compile-commands-dir=${workspaceFolder}/.clangd",
25+
"--completion-style=detailed",
26+
"--header-insertion=never"
27+
],
28+
"cmake.copyCompileCommands": "${workspaceFolder}/.clangd/compile_commands.json"
29+
}

Diff for: CMakeLists.txt

+82-23
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,95 @@
1-
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
22

3-
if(NOT DEFINED PROJECT_NAME)
4-
set(BUILD_AS_STANDALONE ON)
5-
else()
6-
set(BUILD_AS_STANDALONE OFF)
7-
endif()
3+
project(flat.hpp
4+
VERSION "0.0.1"
5+
DESCRIPTION "Library of flat vector-like based associative containers"
6+
HOMEPAGE_URL "https://github.com/blackmatov/flat.hpp")
87

9-
project(flat.hpp)
8+
#
9+
# LIBRARY
10+
#
1011

1112
add_library(${PROJECT_NAME} INTERFACE)
12-
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
13-
target_include_directories(${PROJECT_NAME} INTERFACE headers)
13+
add_library(flat.hpp::flat.hpp ALIAS ${PROJECT_NAME})
14+
15+
target_compile_features(${PROJECT_NAME} INTERFACE
16+
cxx_std_17)
17+
18+
target_include_directories(${PROJECT_NAME} INTERFACE
19+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
20+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
1421

1522
#
16-
# BUILD_AS_STANDALONE
23+
# INSTALL
1724
#
1825

19-
if(NOT ${BUILD_AS_STANDALONE})
20-
return()
26+
if(PROJECT_IS_TOP_LEVEL)
27+
include(CMakePackageConfigHelpers)
28+
include(GNUInstallDirs)
29+
30+
set(FLAT_HPP_INSTALL_CONFIG_DIR
31+
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
32+
33+
set(FLAT_HPP_INSTALL_CONFIG_INPUT
34+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in")
35+
36+
set(FLAT_HPP_INSTALL_GENERATED_CONFIG_CMAKE
37+
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake")
38+
39+
set(FLAT_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE
40+
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake")
41+
42+
configure_package_config_file(
43+
"${FLAT_HPP_INSTALL_CONFIG_INPUT}"
44+
"${FLAT_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
45+
INSTALL_DESTINATION "${FLAT_HPP_INSTALL_CONFIG_DIR}"
46+
NO_SET_AND_CHECK_MACRO
47+
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
48+
49+
write_basic_package_version_file(
50+
"${FLAT_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
51+
VERSION ${PROJECT_VERSION}
52+
COMPATIBILITY AnyNewerVersion
53+
ARCH_INDEPENDENT)
54+
55+
install(
56+
TARGETS ${PROJECT_NAME}
57+
EXPORT ${PROJECT_NAME}-targets
58+
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
59+
60+
install(
61+
DIRECTORY headers/${PROJECT_NAME}
62+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
63+
64+
install(
65+
EXPORT ${PROJECT_NAME}-targets
66+
FILE ${PROJECT_NAME}-targets.cmake
67+
NAMESPACE ${PROJECT_NAME}::
68+
DESTINATION "${FLAT_HPP_INSTALL_CONFIG_DIR}")
69+
70+
install(
71+
FILES "${FLAT_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
72+
"${FLAT_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
73+
DESTINATION "${FLAT_HPP_INSTALL_CONFIG_DIR}")
2174
endif()
2275

23-
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
24-
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
76+
#
77+
# DEVELOPER
78+
#
2579

26-
enable_testing()
27-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
28-
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
29-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
80+
if(PROJECT_IS_TOP_LEVEL)
81+
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
82+
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
3083

31-
include(EnableASan)
32-
include(EnableGCov)
33-
include(EnableUBSan)
84+
enable_testing()
85+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
86+
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
87+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3488

35-
add_subdirectory(vendors)
36-
add_subdirectory(untests)
89+
include(EnableASan)
90+
include(EnableGCov)
91+
include(EnableUBSan)
92+
93+
add_subdirectory(vendors)
94+
add_subdirectory(untests)
95+
endif()

Diff for: LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
3+
Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Also, you can add the root repository directory to your [cmake](https://cmake.or
4141

4242
```cmake
4343
add_subdirectory(external/flat.hpp)
44-
target_link_libraries(your_project_target PUBLIC flat.hpp)
44+
target_link_libraries(your_project_target PUBLIC flat.hpp::flat.hpp)
4545
```
4646

4747
## API

Diff for: cmake/Config.cmake.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/flat.hpp-targets.cmake")

Diff for: cmake/EnableASan.cmake

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# https://clang.llvm.org/docs/AddressSanitizer.html
22

3-
add_library(enable_asan INTERFACE)
3+
add_library(${PROJECT_NAME}.enable_asan INTERFACE)
4+
add_library(${PROJECT_NAME}::enable_asan ALIAS ${PROJECT_NAME}.enable_asan)
45

5-
target_compile_options(enable_asan INTERFACE
6+
target_compile_options(${PROJECT_NAME}.enable_asan INTERFACE
67
-fsanitize=address
78
-fno-omit-frame-pointer
89
-fsanitize-address-use-after-scope
910
-fsanitize-address-use-after-return=always)
1011

11-
target_link_options(enable_asan INTERFACE
12+
target_link_options(${PROJECT_NAME}.enable_asan INTERFACE
1213
-fsanitize=address
1314
-fno-omit-frame-pointer
1415
-fsanitize-address-use-after-scope

Diff for: cmake/EnableGCov.cmake

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
22

3-
add_library(enable_gcov INTERFACE)
3+
add_library(${PROJECT_NAME}.enable_gcov INTERFACE)
4+
add_library(${PROJECT_NAME}::enable_gcov ALIAS ${PROJECT_NAME}.enable_gcov)
45

5-
target_compile_options(enable_gcov INTERFACE
6+
target_compile_options(${PROJECT_NAME}.enable_gcov INTERFACE
67
--coverage)
78

8-
target_link_options(enable_gcov INTERFACE
9+
target_link_options(${PROJECT_NAME}.enable_gcov INTERFACE
910
--coverage)

Diff for: cmake/EnableUBSan.cmake

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
22

3-
add_library(enable_ubsan INTERFACE)
3+
add_library(${PROJECT_NAME}.enable_ubsan INTERFACE)
4+
add_library(${PROJECT_NAME}::enable_ubsan ALIAS ${PROJECT_NAME}.enable_ubsan)
45

5-
target_compile_options(enable_ubsan INTERFACE
6+
target_compile_options(${PROJECT_NAME}.enable_ubsan INTERFACE
67
-fsanitize=undefined
78
-fno-omit-frame-pointer)
89

9-
target_link_options(enable_ubsan INTERFACE
10+
target_link_options(${PROJECT_NAME}.enable_ubsan INTERFACE
1011
-fsanitize=undefined
1112
-fno-omit-frame-pointer)

Diff for: headers/flat.hpp/detail/eq_compare.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/detail/is_allocator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/detail/is_sorted.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/detail/is_transparent.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/detail/iter_traits.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/detail/pair_compare.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/flat.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#include "flat_map.hpp"

Diff for: headers/flat.hpp/flat_fwd.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/flat_map.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/flat_multimap.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/flat_multiset.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: headers/flat.hpp/flat_set.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#pragma once

Diff for: untests/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
44
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
55

66
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
7-
target_link_libraries(${PROJECT_NAME} PRIVATE flat.hpp)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE flat.hpp::flat.hpp)
88

99
#
1010
# setup defines
@@ -23,14 +23,14 @@ setup_defines_for_target(${PROJECT_NAME})
2323
#
2424

2525
function(setup_libraries_for_target TARGET)
26-
target_link_libraries(${TARGET} PRIVATE doctest_with_main)
26+
target_link_libraries(${TARGET} PRIVATE doctest::doctest_with_main)
2727

2828
if(${BUILD_WITH_COVERAGE})
29-
target_link_libraries(${TARGET} PRIVATE enable_gcov)
29+
target_link_libraries(${TARGET} PRIVATE flat.hpp::enable_gcov)
3030
endif()
3131

3232
if(${BUILD_WITH_SANITIZERS})
33-
target_link_libraries(${TARGET} PRIVATE enable_asan enable_ubsan)
33+
target_link_libraries(${TARGET} PRIVATE flat.hpp::enable_asan flat.hpp::enable_ubsan)
3434
endif()
3535
endfunction()
3636

Diff for: untests/flat_detail_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#include <flat.hpp/flat.hpp>

Diff for: untests/flat_map_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#include <flat.hpp/flat_map.hpp>

Diff for: untests/flat_multimap_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* This file is part of the "https://github.com/blackmatov/flat.hpp"
33
* For conditions of distribution and use, see copyright notice in LICENSE.md
4-
* Copyright (C) 2019-2022, by Matvey Cherevko ([email protected])
4+
* Copyright (C) 2019-2023, by Matvey Cherevko ([email protected])
55
******************************************************************************/
66

77
#include <flat.hpp/flat_multimap.hpp>

0 commit comments

Comments
 (0)