Skip to content

Commit 2ab50ca

Browse files
initial commit
0 parents  commit 2ab50ca

17 files changed

+3712
-0
lines changed

.clang-format

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
BasedOnStyle: LLVM
2+
AccessModifierOffset: '-4'
3+
AlignAfterOpenBracket: Align
4+
AlignConsecutiveMacros: 'true'
5+
AlignConsecutiveAssignments: 'true'
6+
AlignConsecutiveDeclarations: 'true'
7+
AlignEscapedNewlines: Right
8+
AlignOperands: 'true'
9+
AlignTrailingComments: 'true'
10+
AllowAllArgumentsOnNextLine: 'true'
11+
AllowAllConstructorInitializersOnNextLine: 'true'
12+
AllowAllParametersOfDeclarationOnNextLine: 'true'
13+
AllowShortBlocksOnASingleLine: 'true'
14+
AllowShortCaseLabelsOnASingleLine: 'true'
15+
AllowShortFunctionsOnASingleLine: All
16+
AllowShortIfStatementsOnASingleLine: Always
17+
AllowShortLambdasOnASingleLine: All
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakTemplateDeclarations: 'Yes'
20+
BinPackArguments: 'false'
21+
BinPackParameters: 'false'
22+
BreakBeforeBinaryOperators: None
23+
BreakBeforeBraces: Custom
24+
BreakConstructorInitializers: BeforeColon
25+
BreakInheritanceList: BeforeColon
26+
ColumnLimit: '120'
27+
CompactNamespaces: 'false'
28+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
29+
ContinuationIndentWidth: '8'
30+
Cpp11BracedListStyle: 'true'
31+
IndentCaseLabels: 'true'
32+
IndentPPDirectives: AfterHash
33+
IndentWidth: '4'
34+
IndentWrappedFunctionNames: 'true'
35+
KeepEmptyLinesAtTheStartOfBlocks: 'false'
36+
Language: Cpp
37+
MaxEmptyLinesToKeep: '2'
38+
NamespaceIndentation: None
39+
PointerAlignment: Right
40+
SpaceBeforeCpp11BracedList: 'true'
41+
SpaceBeforeCtorInitializerColon: 'true'
42+
SpaceBeforeInheritanceColon: 'true'
43+
SpaceBeforeParens: ControlStatements
44+
SpaceBeforeRangeBasedForLoopColon: 'true'
45+
SpaceInEmptyParentheses: 'false'
46+
SpacesBeforeTrailingComments: '2'
47+
SpacesInAngles: 'false'
48+
SpacesInCStyleCastParentheses: 'false'
49+
Standard: Cpp11
50+
TabWidth: '4'
51+
UseTab: Never

.github/workflows/clang-format.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: clang-format Check
2+
on: [push, pull_request]
3+
jobs:
4+
formatting-check:
5+
name: Formatting Check
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
path:
10+
- 'src'
11+
- 'include'
12+
- 'test'
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Run clang-format style check for C/C++/Protobuf programs.
16+
uses: jidicula/clang-format-action@v4.8.0
17+
with:
18+
clang-format-version: '14'
19+
check-path: ${{ matrix.path }}
20+

.github/workflows/cmake.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CMake
2+
3+
on:
4+
[ push, pull_request ]
5+
6+
env:
7+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
8+
BUILD_TYPE: Release
9+
10+
jobs:
11+
build:
12+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
13+
# You can convert this to a matrix build if you need cross-platform coverage.
14+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Configure CMake
21+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
22+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
23+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
24+
25+
- name: Build
26+
# Build your program with the given configuration
27+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
28+
29+
- name: Test
30+
working-directory: ${{github.workspace}}/build
31+
# Execute tests defined by the CMake configuration.
32+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
33+
run: ctest -C ${{env.BUILD_TYPE}}
34+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docs_doxy
2+
cmake-build-*

CMakeLists.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#
2+
# Copyright (C) 2022 Nikolas Koesling <nikolas@koesling.info>.
3+
# This program is free software. You can redistribute it and/or modify it under the terms of the MIT License.
4+
#
5+
6+
cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
7+
8+
project(cxxitimer LANGUAGES CXX VERSION 0.0.0)
9+
set(CMAKE_CXX_STANDARD 17)
10+
11+
set(Target cxxitimer)
12+
13+
add_library(${Target})
14+
install(TARGETS ${Target})
15+
16+
add_subdirectory("src")
17+
add_subdirectory("include")
18+
target_include_directories(${Target} PUBLIC include)
19+
20+
include(warnings.cmake)
21+
include(define.cmake)
22+
23+
set_target_properties(${Target} PROPERTIES
24+
CXX_STANDARD ${CMAKE_CXX_STANDARD}
25+
CXX_STANDARD_REQUIRED ON
26+
CXX_EXTENSIONS OFF
27+
)
28+
29+
# Determine whether this is a standalone project or included by other projects
30+
set(STANDALONE_PROJECT OFF)
31+
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
32+
set(STANDALONE_PROJECT ON)
33+
endif()
34+
35+
if(STANDALONE_PROJECT)
36+
enable_warnings(${Target})
37+
else()
38+
disable_warnings(${Target})
39+
endif()
40+
41+
set_definitions(${Target})
42+
43+
44+
if(STANDALONE_PROJECT)
45+
# doxygen documentation (https://vicrucann.github.io/tutorials/quick-cmake-doxygen/)
46+
# check if Doxygen is installed
47+
find_package(Doxygen)
48+
if (DOXYGEN_FOUND)
49+
# set input and output files
50+
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
51+
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
52+
53+
if(EXISTS ${DOXYGEN_IN})
54+
# request to configure the file
55+
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
56+
message(STATUS "Doxygen configured")
57+
58+
# note the option ALL which allows to build the docs together with the application
59+
add_custom_target( doc_doxygen ALL
60+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
61+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
62+
COMMENT "Generating API documentation with Doxygen"
63+
VERBATIM )
64+
message(STATUS "Added target doc_doxygen")
65+
else()
66+
message(WARNING "doxygen documentation requested, but file ${DOXYGEN_IN} does not exist.")
67+
endif()
68+
else (DOXYGEN_FOUND)
69+
message(WARNING "Doxygen need to be installed and accessible to generate the doxygen documentation.")
70+
endif (DOXYGEN_FOUND)
71+
72+
# add clang format target
73+
set(CLANG_FORMAT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format)
74+
75+
if(EXISTS ${CLANG_FORMAT_FILE})
76+
set(CLANG_FORMAT_ENABLED ON)
77+
include(ClangFormat.cmake)
78+
target_clangformat_setup(${Target})
79+
message(STATUS "Added clang format target(s)")
80+
else()
81+
message(WARNING "Clang format enabled, but file ${CLANG_FORMAT_FILE} does not exist")
82+
endif()
83+
84+
# add test targets
85+
enable_testing()
86+
add_subdirectory(test)
87+
endif()

ClangFormat.cmake

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright Tomas Zeman 2019-2020.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
function(prefix_clangformat_setup prefix)
7+
if(NOT CLANGFORMAT_EXECUTABLE)
8+
set(CLANGFORMAT_EXECUTABLE clang-format)
9+
endif()
10+
11+
if(NOT EXISTS ${CLANGFORMAT_EXECUTABLE})
12+
find_program(clangformat_executable_tmp ${CLANGFORMAT_EXECUTABLE})
13+
if(clangformat_executable_tmp)
14+
set(CLANGFORMAT_EXECUTABLE ${clangformat_executable_tmp})
15+
unset(clangformat_executable_tmp)
16+
else()
17+
message(FATAL_ERROR "ClangFormat: ${CLANGFORMAT_EXECUTABLE} not found! Aborting")
18+
endif()
19+
endif()
20+
21+
foreach(clangformat_source ${ARGN})
22+
get_filename_component(clangformat_source ${clangformat_source} ABSOLUTE)
23+
list(APPEND clangformat_sources ${clangformat_source})
24+
endforeach()
25+
26+
add_custom_target(${prefix}_clangformat
27+
COMMAND
28+
${CLANGFORMAT_EXECUTABLE}
29+
-style=file
30+
-i
31+
${clangformat_sources}
32+
WORKING_DIRECTORY
33+
${CMAKE_SOURCE_DIR}
34+
COMMENT
35+
"Formatting ${prefix} with ${CLANGFORMAT_EXECUTABLE} ..."
36+
)
37+
38+
if(TARGET clangformat)
39+
add_dependencies(clangformat ${prefix}_clangformat)
40+
else()
41+
add_custom_target(clangformat DEPENDS ${prefix}_clangformat)
42+
endif()
43+
endfunction()
44+
45+
function(clangformat_setup)
46+
prefix_clangformat_setup(${PROJECT_NAME} ${ARGN})
47+
endfunction()
48+
49+
function(target_clangformat_setup target)
50+
get_target_property(target_sources ${target} SOURCES)
51+
prefix_clangformat_setup(${target} ${target_sources})
52+
endfunction()

0 commit comments

Comments
 (0)