Skip to content

Commit 439339c

Browse files
committed
Merge branch 'pvt-dev'
1 parent b7b2ee4 commit 439339c

File tree

233 files changed

+15705
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+15705
-1
lines changed

.clang-format

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
BasedOnStyle: WebKit
2+
ColumnLimit: 80
3+
AlwaysBreakTemplateDeclarations: Yes
4+
Cpp11BracedListStyle: true
5+
SpaceBeforeCpp11BracedList: false
6+
FixNamespaceComments: true
7+
AlignConsecutiveAssignments: Consecutive
8+
AlignOperands: AlignAfterOperator
9+
AlignTrailingComments: true

.clang-tidy

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Checks: >
2+
-*,
3+
bugprone-*,
4+
clang-analyzer-*,
5+
cppcoreguidelines-*,
6+
hicpp-*,
7+
modernize-*,
8+
performance-*,
9+
portability-*,
10+
readability-*,
11+
-readability-function-cognitive-complexity,
12+
-readability-identifier-length,
13+
-readability-isolate-declaration,
14+
-*-uppercase-literal-suffix,
15+
-*-avoid-do-while,
16+
-*-branch-clone,
17+
-*-magic-numbers,
18+
-*-macro-usage,
19+
-*-macro-parentheses,
20+
ExtraArgs: - -std=c++17
21+
HeaderFilterRegex: ".*(AutoDiff).*$"

.github/workflows/ci.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CI Builds
2+
3+
on:
4+
push:
5+
paths:
6+
- 'include/**'
7+
- 'tests/**'
8+
- 'CMakeLists.txt'
9+
- 'CMakePresets.json'
10+
- '**conanfile.py'
11+
- '.github/workflows/ci.yml'
12+
pull_request:
13+
14+
jobs:
15+
build_and_test:
16+
runs-on: ${{matrix.os}}
17+
strategy:
18+
matrix:
19+
20+
cpp_compiler: [g++, clang++, cl]
21+
build_type: [Debug]
22+
23+
include:
24+
25+
# GCC
26+
- os: ubuntu-latest
27+
cpp_compiler: g++
28+
build_type: Debug
29+
build_dir: build/Debug
30+
config_preset: tests-ninja-linux-debug
31+
32+
# Clang
33+
- os: ubuntu-latest
34+
cpp_compiler: clang++
35+
build_type: Debug
36+
build_dir: build/Debug
37+
config_preset: tests-ninja-linux-debug
38+
39+
# MSVC
40+
- os: windows-latest
41+
cpp_compiler: cl
42+
build_dir: build
43+
config_preset: tests-msvc2022
44+
45+
defaults:
46+
run:
47+
working-directory: ${{github.workspace}}
48+
49+
steps:
50+
51+
- uses: actions/checkout@v4
52+
with:
53+
ref: main
54+
55+
- name: Install CMake and Ninja
56+
uses: lukka/get-cmake@latest
57+
58+
- name: Install Conan
59+
uses: turtlebrowser/get-conan@main
60+
61+
- name: Configure Conan
62+
run: conan profile detect --force
63+
64+
- name: Install dependencies
65+
run: >
66+
conan install
67+
--build=missing
68+
--settings build_type=${{matrix.build_type}}
69+
--settings compiler.cppstd=17
70+
${{github.workspace}}
71+
72+
- name: Configure CMake
73+
run: >
74+
cmake
75+
-S ${{github.workspace}}
76+
-DCMAKE_CXX_COMPILER=${{matrix.cpp_compiler}}
77+
-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/${{matrix.build_dir}}/generators/conan_toolchain.cmake
78+
--preset=${{matrix.config_preset}}
79+
80+
- name: Build
81+
if: matrix.os == 'ubuntu-latest'
82+
run: cmake --build ${{matrix.build_dir}}
83+
84+
- name: Build (Windows)
85+
if: matrix.os == 'windows-latest'
86+
run: >
87+
cmake
88+
--build ${{matrix.build_dir}}
89+
--config ${{matrix.build_type}}
90+
--parallel %NUMBER_OF_PROCESSORS%
91+
shell: cmd
92+
93+
- name: Test
94+
run: >
95+
ctest
96+
--test-dir ${{matrix.build_dir}}
97+
--build-config ${{matrix.build_type}}
98+
--output-on-failure

.github/workflows/coverage.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Code Coverage
2+
3+
on:
4+
push:
5+
paths:
6+
- 'include/**'
7+
- 'tests/**'
8+
- 'CMakeLists.txt'
9+
- 'CMakePresets.json'
10+
- '**conanfile.py'
11+
- '.github/workflows/coverage.yml'
12+
pull_request:
13+
14+
jobs:
15+
coverage:
16+
runs-on: ubuntu-latest
17+
18+
defaults:
19+
run:
20+
working-directory: ${{github.workspace}}
21+
22+
steps:
23+
24+
- uses: actions/checkout@v4
25+
with:
26+
ref: main
27+
28+
- name: Install gcovr
29+
run: pip install gcovr
30+
31+
- name: Install CMake and Ninja
32+
uses: lukka/get-cmake@latest
33+
34+
- name: Install Conan
35+
uses: turtlebrowser/get-conan@main
36+
37+
- name: Configure Conan
38+
run: conan profile detect --force
39+
40+
- name: Install dependencies
41+
run: >
42+
conan install
43+
--build=missing
44+
--settings build_type=Debug
45+
--settings compiler.cppstd=17
46+
${{github.workspace}}
47+
48+
- name: Configure CMake
49+
run: >
50+
cmake
51+
-DCMAKE_CXX_COMPILER=g++
52+
-DCMAKE_TOOLCHAIN_FILE=build/Debug/generators/conan_toolchain.cmake
53+
--preset=coverage-gcov
54+
55+
- name: Build
56+
run: cmake --build build/Debug
57+
58+
- name: Test
59+
run: ctest --test-dir build/Debug
60+
61+
# Compute line coverage
62+
- name: Generate coverage report
63+
id: coverage
64+
run: >
65+
gcovr
66+
--root ${{github.workspace}}
67+
--filter include/
68+
--exclude-throw-branches
69+
--exclude-unreachable-branches
70+
--lcov coverage.lcov
71+
--print-summary
72+
shell: bash
73+
74+
# TODO Coveralls integration

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Project exclude paths
2+
/.vscode
3+
build
4+
generated
5+
CMakeUserPresets.json

CMake/AutoDiffConfig.cmake.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/AutoDiffTargets.cmake")
4+
check_required_components(AutoDiff)

CMake/strip.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# https://blog.insane.engineer/post/cmake_strip_binaries/
2+
3+
function(utils_strip TARGET)
4+
add_custom_command(
5+
TARGET "${TARGET}" POST_BUILD
6+
DEPENDS "${TARGET}"
7+
COMMAND $<$<CONFIG:release>:${CMAKE_STRIP}>
8+
ARGS --strip-all $<TARGET_FILE:${TARGET}>
9+
)
10+
endfunction()

CMakeLists.txt

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(AutoDiff
4+
VERSION 0.4.0
5+
LANGUAGES CXX
6+
DESCRIPTION ""
7+
)
8+
9+
# PROJECT_IS_TOP_LEVEL is introduced in v3.21
10+
if (CMAKE_VERSION VERSION_LESS 3.21)
11+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
12+
set(PROJECT_IS_TOP_LEVEL TRUE)
13+
else ()
14+
set(PROJECT_IS_TOP_LEVEL FALSE)
15+
endif ()
16+
endif ()
17+
18+
add_library(AutoDiff INTERFACE)
19+
add_library(AutoDiff::AutoDiff ALIAS AutoDiff)
20+
target_include_directories(
21+
AutoDiff INTERFACE
22+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
23+
$<INSTALL_INTERFACE:include>
24+
)
25+
target_compile_features(AutoDiff INTERFACE cxx_std_17)
26+
27+
if (${PROJECT_IS_TOP_LEVEL})
28+
29+
include(CTest)
30+
if (BUILD_TESTING)
31+
add_subdirectory(tests)
32+
endif ()
33+
34+
option(AUTODIFF_BUILD_EXAMPLES "Build example projects" OFF)
35+
if (AUTODIFF_BUILD_EXAMPLES)
36+
add_subdirectory(examples)
37+
endif ()
38+
39+
option(AUTODIFF_BUILD_BENCHMARKS "Build benchmarks" OFF)
40+
if (AUTODIFF_BUILD_BENCHMARKS)
41+
add_subdirectory(benchmarks)
42+
endif ()
43+
44+
include(GNUInstallDirs)
45+
46+
set(AUTODIFF_CMAKE_CONFIG_DESTINATION lib/cmake/AutoDiff)
47+
48+
include(CMakePackageConfigHelpers)
49+
configure_package_config_file(
50+
"${CMAKE_CURRENT_LIST_DIR}/CMake/AutoDiffConfig.cmake.in"
51+
"${CMAKE_CURRENT_BINARY_DIR}/AutoDiffConfig.cmake"
52+
INSTALL_DESTINATION "${AUTODIFF_CMAKE_CONFIG_DESTINATION}"
53+
)
54+
write_basic_package_version_file(
55+
"${CMAKE_CURRENT_BINARY_DIR}/AutoDiffConfigVersion.cmake"
56+
VERSION ${CMAKE_PROJECT_VERSION}
57+
COMPATIBILITY SameMajorVersion
58+
)
59+
install(
60+
FILES
61+
"${CMAKE_CURRENT_BINARY_DIR}/AutoDiffConfig.cmake"
62+
"${CMAKE_CURRENT_BINARY_DIR}/AutoDiffConfigVersion.cmake"
63+
DESTINATION
64+
"${AUTODIFF_CMAKE_CONFIG_DESTINATION}"
65+
)
66+
67+
install(
68+
TARGETS AutoDiff EXPORT AutoDiffTargets
69+
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
70+
)
71+
export(EXPORT AutoDiffTargets
72+
FILE
73+
"${CMAKE_CURRENT_BINARY_DIR}/AutoDiffTargets.cmake"
74+
NAMESPACE
75+
AutoDiff::
76+
)
77+
install(EXPORT AutoDiffTargets
78+
FILE
79+
AutoDiffTargets.cmake
80+
NAMESPACE
81+
AutoDiff::
82+
DESTINATION
83+
"${AUTODIFF_CMAKE_CONFIG_DESTINATION}"
84+
)
85+
86+
install(DIRECTORY include/AutoDiff
87+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
88+
)
89+
90+
endif ()

0 commit comments

Comments
 (0)