Skip to content
Open

Ci #45

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
Language: Cpp
BasedOnStyle: Microsoft
ColumnLimit: 120
PointerAlignment: Left
BreakBeforeBraces: Attach
AlignAfterOpenBracket: true
NamespaceIndentation: All
BreakTemplateDeclarations: Yes
IndentCaseLabels: Yes
OneLineFormatOffRegex: '^// NOLINT'
...
157 changes: 157 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

---
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
ExcludeHeaderFilterRegex: '^.*/tinyxml2.*$'
FormatStyle: 'file'
UseColor: true
SystemHeaders: false

Checks: >
*bugprone*,
*performance*,
clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-optin.performance.Padding,
cppcoreguidelines-init-variables,
cppcoreguidelines-prefer-member-initializer,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-slicing,
google-explicit-constructor,
llvm-namespace-comment,
misc-definitions-in-headers,
misc-misplaced-const,
misc-non-copyable-objects,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-uniqueptr-reset-release,
misc-unused-parameters,
misc-include-cleaner,
modernize-avoid-bind,
modernize-loop-convert,
modernize-make-shared,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-use-auto,
modernize-use-bool-literals,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-using,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
readability-duplicate-include,
readability-else-after-return,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-qualified-auto,
readability-identifier-naming,
readability-identifier-length,
readability-named-parameter,
readability-redundant-casting,
readability-redundant-function-ptr-dereference,
readability-redundant-inline-specifier,
readability-redundant-member-init,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-simplify-subscript-expr,
readability-static-accessed-through-instance,
readability-string-compare,
readability-suspicious-call-argument,
readability-uniqueptr-delete-release,
-bugprone-chained-comparison,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-reserved-identifier,
-bugprone-unused-raii,
-performance-enum-size,
-performance-avoid-endl,
-performance-inefficient-string-concatenation,

CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.ParameterCase
value: camelBack
- key: readability-identifier-naming.MemberCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberCase
value: camelBack
- key: readability-identifier-naming.ProtectedMemberCase
value: camelBack
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstexprVariableCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstexprFunctionCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.GlobalConstantMemberCase
value: UPPER_CASE
- key: readability-identifier-naming.StaticConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.StaticVariableCase
value: camelBack
- key: readability-identifier-naming.MemberConstantCase
value: camelBack
- key: readability-identifier-naming.MemberConstantStaticCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstantMemberCase
value: camelBack
- key: readability-identifier-naming.PrivateConstantMemberCase
value: camelBack
- key: readability-identifier-naming.ProtectedConstantMemberCase
value: camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberSuffix
value: '_'
- key: readability-identifier-naming.PrivateConstantMemberSuffix
value: '_'
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: false
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
value: false
- key: readability-const-return-type.IgnoreMacros
value: false
- key: readability-identifier-length.MinimumVariableNameLength
value: 2
- key: readability-identifier-length.IgnoredVariableNames
value: '^(i|j|k|x|y|z|n|a|b)$'
- key: readability-identifier-length.MinimumParameterNameLength
value: 2
- key: readability-identifier-length.IgnoredParameterNames
value: '^(i|j|k|x|y|z|n|a|b)$'
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: 3
- key: readability-identifier-length.IgnoredLoopCounterNames
value: '^(i|j|k|n)$'
- key: readability-identifier-length.MinimumExceptionNameLength
value: 3
- key: readability-identifier-length.IgnoredExceptionVariableNames
value: '^(e|ex)$'
- key: misc-include-cleaner.MissingIncludes
value: false
20 changes: 20 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# cmake-format configuration file
# See https://github.com/cheshirekow/cmake_format for documentation

format:
line_width: 100
tab_size: 4
command_case: canonical
separate_ctrl_name_with_space: true
separate_fn_name_with_space: false
dangle_parens: true
dangle_align: prefix
min_prefix_chars: 4
max_prefix_chars: 10
require_valid_layout: false
enable_sort: true
autosort: true

markup:
enable_markup: false
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
types: [opened, synchronize, reopened]
branches: [ main, master ]
pull_request_target:
types: [opened, synchronize, reopened]
branches: [ main, master ]

jobs:
ci:
name: CI (${{ matrix.os }} - ${{ matrix.compiler }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
compiler: g++
- os: macos-latest
compiler: clang

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt-get update
sudo apt-get install -y build-essential cmake libgtest-dev g++ clang-format-21
pip install cmake-format

- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake googletest

- name: Build and Test
id: build-test
run: |
cmake --workflow release-test

- name: Clang-tidy
id: clang-tidy
if: matrix.os == 'ubuntu-latest'
run: |
cmake --workflow test

- name: Check formatting
id: check-format
if: always() && matrix.os == 'ubuntu-latest'
run: |
cmake --workflow check-format
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
build/
/install/
/docs/compiled/
/.cache/
110 changes: 70 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,96 @@
##
#
# Copyright (c) 2024-2025 Alexandr Svetlichnyi, Savva Savenkov, Artemii Novikov

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

cmake_minimum_required(VERSION 3.13)
project(COLA VERSION 0.3.2)

set(CMAKE_CXX_STANDARD 17)
project(
COLA
VERSION 0.3.2
LANGUAGES CXX
)

# Add internal dependency to build
add_subdirectory(tinyxml2)

add_library(COLA SHARED COLA.cc)

target_include_directories(COLA PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)
target_compile_features(COLA PUBLIC cxx_std_17)

target_link_libraries(COLA PRIVATE tinyxml2)
target_include_directories(
COLA PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>
)

set_target_properties(COLA PROPERTIES
PUBLIC_HEADER "COLA.hh;LorentzVector.hh"
VERSION "${COLA_VERSION}"
SOVERSION "${COLA_VERSION_MAJOR}")
target_link_libraries(COLA PRIVATE tinyxml2)

install(TARGETS COLA
EXPORT COLAExport
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
INCLUDES DESTINATION include)
set(COLA_CMAKE_CXX_CLANG_TIDY
""
CACHE STRING "variable will be passed to CMAKE_CXX_CLANG_TIDY of COLA target"
)

set_target_properties(
COLA
PROPERTIES PUBLIC_HEADER "COLA.hh;LorentzVector.hh"
VERSION "${COLA_VERSION}"
SOVERSION "${COLA_VERSION_MAJOR}"
CXX_CLANG_TIDY "${COLA_CMAKE_CXX_CLANG_TIDY}"
)

include(GNUInstallDirs)

install(
TARGETS COLA
EXPORT COLAExport
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

include(CMakePackageConfigHelpers)

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/data/COLAConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/COLAConfig.cmake"
INSTALL_DESTINATION lib/cmake/COLA)
"${PROJECT_SOURCE_DIR}/data/COLAConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/COLAConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/COLA
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/COLAConfigVersion.cmake
COMPATIBILITY AnyNewerVersion)
${CMAKE_CURRENT_BINARY_DIR}/COLAConfigVersion.cmake COMPATIBILITY AnyNewerVersion
)

install(EXPORT COLAExport
DESTINATION lib/cmake/COLA)
install(EXPORT COLAExport DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/COLA)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/COLAConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/COLAConfigVersion.cmake"
DESTINATION lib/cmake/COLA)

install(FILES "${PROJECT_SOURCE_DIR}/data/config.sh"
DESTINATION ${CMAKE_INSTALL_PREFIX})
"${CMAKE_CURRENT_BINARY_DIR}/COLAConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/COLA
)

install(FILES "${PROJECT_SOURCE_DIR}/data/config.sh" DESTINATION ${CMAKE_INSTALL_PREFIX})

install(
DIRECTORY cmake/
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/COLA/cmake
FILES_MATCHING
PATTERN "*.cmake"
)

enable_testing()
if (BUILD_TESTING)
add_subdirectory(tests)
endif ()

# Setup code quality tools (clang-format, cmake-format)
include(cmake/SetupCodeQuality.cmake)
Loading