Skip to content

Commit

Permalink
initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Bać committed Mar 1, 2024
1 parent fabde09 commit c212290
Show file tree
Hide file tree
Showing 15 changed files with 949 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
BreakAfterAttributes: Always
BracedInitializerIndentWidth: 2
BraceWrapping:
SplitEmptyNamespace: false
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterExternBlock: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: true
SplitEmptyFunction: false
SplitEmptyRecord: true
BitFieldColonSpacing: Both
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Whitesmiths
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: Always
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentAccessModifiers: false
IndentCaseBlocks: true
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: true
InsertBraces: false
InsertNewlineAtEOF: true
InsertTrailingCommas: None
KeepEmptyLinesAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
LineEnding: DeriveLF
NamespaceIndentation: Inner
PPIndentWidth: 0
PackConstructorInitializers: CurrentLine
PointerAlignment: Middle
QualifierAlignment: Right
ReferenceAlignment: Middle
ReflowComments: true
RemoveBracesLLVM: true
RemoveParentheses: MultipleParentheses
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 1
SortIncludes: Never
SortUsingDeclarations: Lexicographic
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Both
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: true
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 2
UseTab: Never
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignConsecutiveDeclarations:
Enabled: false
AlignConsecutiveMacros:
Enabled: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
Kind: Always
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
AlignAfterOpenBracket: BlockIndent
WhitespaceSensitiveMacros:
- PRAGMA_CLANG_WARNING_OFF
- PRAGMA_CLANG_WARNING_PUSH_OFF
- PRAGMA_GCC_WARNING_PUSH_OFF
- PRAGMA_GCC_WARNING_OFF
27 changes: 27 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,bugprone-*,readability-identifier-naming,misc-const-correctness,cert-dcl21-cpp,cert-dcl50-cpp,cert-err34-c,cert-err52-cpp,cert-err58-cpp,cert-err60-cpp,cert-flp30-cpp,cert-mem57-cpp,cert-msc50-cpp,cert-msc51-cpp,cert-oop57-cpp,cert-oop58-cpp,misc-new-delete-overloads,misc-no-recursion,misc-non-copyable-objects,misc-unused-using-decls,misc-uniqueptr-reset-release,misc-unconventional-assign-operator,misc-throw-by-value-catch-by-reference,misc-static-assert,misc-redundant-expression,performance-*,readability-use-anyofallof,readability-string-compare,readability-static-accessed-through-instance,readability-simplify-subscript-expr,readability-simplify-boolean-expr,readability-redundant-*,readability-qualified-auto,readability-non-const-parameter,readability-misplaced-array-index,readability-make-member-function-const,readability-isolate-declaration,readability-inconsistent-declaration-parameter-name,readability-implicit-bool-conversion,readability-function-size,readability-else-after-return,readability-deleted-default,readability-delete-null-pointer,readability-convert-member-functions-to-static,readability-container-size-empty,readability-const-return-type,readability-avoid-const-params-in-decls,modernize-use-nodiscard'
CheckOptions:
# General Naming Convention: lower_case
- key: readability-identifier-naming.NamespaceCase
value: 'lower_case'
- key: readability-identifier-naming.ClassCase
value: 'lower_case'
- key: readability-identifier-naming.StructCase
value: 'lower_case'
- key: readability-identifier-naming.FunctionCase
value: 'lower_case'
- key: readability-identifier-naming.VariableCase
value: 'lower_case'
- key: readability-identifier-naming.PublicMemberCase
value: 'lower_case'
- key: readability-identifier-naming.PrivateMemberCase
value: 'lower_case_'
- key: readability-identifier-naming.ProtectedMemberCase
value: 'lower_case_'
- key: readability-identifier-naming.ConstantCase
value: 'lower_case'
# Member variables should end with '_'
- key: readability-identifier-naming.MemberSuffix
value: '_'
# Macros should be UPPER_CASE
- key: readability-identifier-naming.MacroDefinitionCase
value: 'UPPER_CASE'
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: C++ CI

on: [push, pull_request]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build gcc g++ libboost-all-dev
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -G "Ninja"
- name: Build
run: cmake --build ${{github.workspace}}/build
- name: Test
run: ctest --preset Test
57 changes: 57 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.21) # Use the latest CMake version you have confirmed supports all features you need, 3.21 as a placeholder
project(simple_enum VERSION 0.0.1 LANGUAGES CXX)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(cmake/CPM.cmake)
#----------------------------------------------------------------
# boost-ext/ut
#----------------------------------------------------------------
CPMAddPackage(
ut
GITHUB_REPOSITORY boost-ext/ut
GIT_TAG v2.0.1
)
find_package(ut REQUIRED)
# target_precompile_headers( ut INTERFACE "${ut_SOURCE_DIR}/include/boost/ut.hpp" )
CPMAddPackage(
NAME magic_enum
GITHUB_REPOSITORY Neargye/magic_enum
GIT_TAG v0.9.5
)
find_package(magic_enum REQUIRED)

CPMAddPackage(
Name reflect
GITHUB_REPOSITORY boost-ext/reflect
GIT_TAG main
)
add_library(reflect INTERFACE)
target_include_directories(reflect SYSTEM INTERFACE ${reflect_SOURCE_DIR})
target_compile_definitions(reflect INTERFACE REFLECT_DISABLE_STATIC_ASSERT_TESTS)
add_library(reflect::reflect ALIAS reflect)
# target_precompile_headers( reflect INTERFACE "${reflect_SOURCE_DIR}/reflect" )
find_package(reflect REQUIRED)

# Header-only library target
add_library(simple_enum INTERFACE)
add_library(simple_enum::simple_enum ALIAS simple_enum )
target_include_directories(simple_enum INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

# Enable testing and add the tests directory
enable_testing()
add_subdirectory(tests)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
add_subdirectory(time_trace)
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} --list-presets
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${CMAKE_COMMAND} --workflow --list-presets
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
83 changes: 83 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "cfg-clang",
"generator": "Ninja",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "clnag-debug",
"description": "Configure for debug build",
"inherits": [ "cfg-clang" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release-time-trace",
"description": "Configure for release build",
"inherits": [ "cfg-clang" ],
"binaryDir": "${sourceDir}/build/release-time-trace",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS": "-ftime-trace -fno-omit-frame-pointer"
}
},
{
"name": "ReleaseWithDeb",
"description": "Configure for release build with Debian package generation",
"inherits": [ "cfg-clang" ],
"binaryDir": "${sourceDir}/build/release-with-deb",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CPACK_GENERATOR": "DEB"
}
},
{
"name": "ReleaseTestAsan",
"description": "Configure for release build with address sanitizer",
"inherits": [ "cfg-clang" ],
"binaryDir": "${sourceDir}/build/release-test-asan",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-fsanitize=address"
}
}
],
"buildPresets": [
{
"name": "clnag-debug",
"configurePreset": "clnag-debug"
},
{
"name": "release-time-trace",
"configurePreset": "release-time-trace"
},
{
"name": "ReleaseWithDeb",
"configurePreset": "ReleaseWithDeb"
},
{
"name": "ReleaseTestAsan",
"configurePreset": "ReleaseTestAsan"
}
],
"testPresets": [
{
"name": "Test",
"configurePreset": "ReleaseTestAsan",
"output": {
"outputOnFailure": true
}
}
]
}
19 changes: 19 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(CPM_DOWNLOAD_VERSION 0.35.1)

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif()

include(${CPM_DOWNLOAD_LOCATION})

1 change: 1 addition & 0 deletions include/simple_enum/develcode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit c212290

Please sign in to comment.