mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-06-04 19:58:41 +02:00
8f8173feb6
To improve codebase quality and reduce human error, this PR introduces the pre-commit framework. This ensures that all code adheres to project standards before it is even committed, maintaining a consistent style and catching common mistakes early. Key Changes: - Code Formatting: Automated C++ formatting using clang-format (based on the project's .clang-format file). - Syntax Validation: Basic checks for file integrity and syntax. - Spell Check: Automated scanning for typos in source code and comments. - CMake Formatting: Standardization of CMakeLists.txt and .cmake configuration files. - GitHub Workflow: Added a CI action that validates every Pull Request against the pre-commit configuration to ensure compliance. The configuration includes a [ci] block to handle automated fixes within the PR. Currently, this is disabled. If we want the CI to automatically commit formatting fixes back to the PR branch, this can be toggled to true in .pre-commit-config.yaml. ```yaml ci: autofix_commit_msg: [pre-commit] auto fixes from pre-commit hooks autofix_prs: false autoupdate_schedule: monthly ``` The last large commit with the fit functions, for example, was not formatted according to the clang-format rules. This PR would allow to avoid similar mistakes in the future. Python fomat with `ruff` for tests and sanitiser for `.ipynb` notebooks can be added as well.
41 lines
1.3 KiB
CMake
41 lines
1.3 KiB
CMake
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
benchmark
|
|
GIT_REPOSITORY https://github.com/google/benchmark.git
|
|
GIT_TAG v1.8.3 # Change to the latest version if needed
|
|
)
|
|
|
|
# Ensure Google Benchmark is built correctly
|
|
set(BENCHMARK_ENABLE_TESTING
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
|
|
FetchContent_MakeAvailable(benchmark)
|
|
|
|
add_executable(benchmarks)
|
|
|
|
target_sources(
|
|
benchmarks PRIVATE ndarray_benchmark.cpp calculateeta_benchmark.cpp
|
|
reduce_benchmark.cpp)
|
|
|
|
# Link Google Benchmark and other necessary libraries
|
|
target_link_libraries(benchmarks PRIVATE benchmark::benchmark aare_core
|
|
aare_compiler_flags)
|
|
|
|
# Set output properties
|
|
set_target_properties(
|
|
benchmarks PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
OUTPUT_NAME run_benchmarks)
|
|
|
|
add_executable(fit_benchmark fit_benchmark.cpp)
|
|
target_link_libraries(fit_benchmark PRIVATE benchmark::benchmark aare_core
|
|
aare_compiler_flags)
|
|
target_include_directories(
|
|
fit_benchmark SYSTEM
|
|
PRIVATE $<TARGET_PROPERTY:Minuit2::Minuit2,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
set_target_properties(fit_benchmark PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_BINARY_DIR})
|