Skip to content

Commit

Permalink
chore: infra
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Nov 7, 2024
1 parent 7ff4b01 commit e1399a2
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 9 deletions.
15 changes: 14 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
---
Checks: 'bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,hicpp-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-modernize-use-trailing-return-type,-bugprone-easily-swappable-parameters,-readability-identifier-length,-readability-named-parameter,-hicpp-special-member-functions,-hicpp-use-equals-default,-hicpp-move-const-arg,-hicpp-named-parameter,-hicpp-vararg,-misc-include-cleaner,-cppcoreguidelines-pro-type-union-access,-misc-non-private-member-variables-in-classes,-*-avoid-do-while'
Checks: <
bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,hicpp-*,misc-*,modernize-*,performance-*,portability-*,readability-*,

-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-pro-type-union-access,
-misc-include-cleaner,
-modernize-use-trailing-return-type,
-readability-identifier-length,-readability-named-parameter,

-bugprone-narrowing-conversions,
-cert-arr39-c,-cert-con36-c,-cert-con54-cpp,-cert-ctr56-cpp,-cert-dcl03-c,-cert-dcl16-c,-cert-dcl37-c,-cert-dcl51-cpp,-cert-dcl54-cpp,-cert-dcl59-cpp,-cert-err09-cpp,-cert-err61-cpp,-cert-exp42-c,-cert-fio38-c,-cert-flp37-c,-cert-int09-c,-cert-msc24-c,-cert-msc30-c,-cert-msc32-c,-cert-msc33-c,-cert-msc54-cpp,-cert-oop11-cpp,-cert-oop54-cpp,-cert-pos44-c,-cert-pos47-c,-cert-sig30-c,-cert-str34-c,
-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-c-copy-assignment-signature,-cppcoreguidelines-explicit-virtual-functions,-cppcoreguidelines-macro-to-enum,-cppcoreguidelines-noexcept-destructor,-cppcoreguidelines-noexcept-move-operations,-cppcoreguidelines-noexcept-swap,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-use-default-member-init,
-hicpp-avoid-c-arrays,-hicpp-avoid-goto,-hicpp-braces-around-statements,-hicpp-deprecated-headers,-hicpp-explicit-conversions,-hicpp-function-size,-hicpp-invalid-access-moved,-hicpp-member-init,-hicpp-move-const-arg,-hicpp-named-parameter,-hicpp-new-delete-operators,-hicpp-no-array-decay,-hicpp-no-malloc,-hicpp-noexcept-move,-hicpp-special-member-functions,-hicpp-static-assert,-hicpp-undelegated-constructor,-hicpp-uppercase-literal-suffix,-hicpp-use-auto,-hicpp-use-emplace,-hicpp-use-equals-default,-hicpp-use-equals-delete,-hicpp-use-noexcept,-hicpp-use-nullptr,-hicpp-use-override,-hicpp-vararg

FormatStyle: none
HeaderFilterRegex: '.*'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.cache/
/.vscode/
/build/
/build*/
25 changes: 19 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
option(WITH_TESTING "Whether to enable tests" ON)
option(INSTALL_SYSLOG_EXPORTER "Whether to install the syslog exporter" ON)

include(FetchContent)

# Logs signal became stable in v1.11.0, see https://github.com/open-telemetry/opentelemetry-cpp/pull/2229, https://github.com/open-telemetry/opentelemetry-cpp/blob/v1.11.0/CHANGELOG.md
find_package(opentelemetry-cpp CONFIG REQUIRED)
if(opentelemetry-cpp_VERSION VERSION_LESS 1.11.0)
Expand All @@ -25,13 +27,24 @@ add_subdirectory(src)
if(WITH_TESTING)
include(FindGTest)
find_package(GTest CONFIG COMPONENTS gtest gmock)
if(TARGET GTest::gtest AND TARGET GTest::gmock)
include(CTest)
enable_testing()
add_subdirectory(test)
else()
message(WARNING "GTest not found, tests will not be built")
if(NOT TARGET GTest::gtest OR NOT TARGET GTest::gmock)
message(STATUS "Google Test not found, fetching it from GitHub")
# renovate: datasource=github-tags depName=google/googletest
set(GTEST_VERSION "v1.15.2")
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG "${GTEST_VERSION}"
GIT_SHALLOW ON
)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()

include(CTest)
enable_testing()
add_subdirectory(test)
endif()

find_program(CLANG_FORMAT NAMES clang-format)
Expand Down
127 changes: 127 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"hidden": true,
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
"WITH_TESTING": "ON"
}
},
{
"name": "base-vcpkg",
"hidden": true,
"inherits": "base",
"toolchainFile": "${fileDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "default",
"description": "Default build",
"inherits": "base",
"hidden": false,
"binaryDir": "${sourceDir}/build"
},
{
"name": "debug",
"description": "Debug build",
"inherits": "base",
"hidden": false
},
{
"name": "release",
"description": "Release build",
"inherits": "base",
"hidden": false,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "debug-vcpkg",
"description": "Debug + vcpkg",
"inherits": "base-vcpkg",
"hidden": false
}
],
"buildPresets": [
{
"name": "base",
"hidden": true,
"verbose": true
},
{
"name": "default",
"description": "Default build",
"inherits": "base",
"hidden": false,
"configurePreset": "default"
},
{
"name": "debug",
"description": "Debug build",
"inherits": "base",
"hidden": false,
"configurePreset": "debug"
},
{
"name": "release",
"description": "Release build",
"inherits": "base",
"hidden": false,
"configurePreset": "release"
},
{
"name": "debug-vcpkg",
"description": "Debug + vcpkg",
"inherits": "base",
"hidden": false,
"configurePreset": "debug-vcpkg"
}
],
"testPresets": [
{
"name": "base",
"hidden": true,
"output": {
"outputOnFailure": true,
"quiet": false
}
},
{
"name": "default",
"description": "Default build",
"inherits": "base",
"hidden": false,
"configurePreset": "default"
},
{
"name": "debug",
"description": "Debug build",
"inherits": "base",
"hidden": false,
"configurePreset": "debug"
},
{
"name": "release",
"description": "Release build",
"inherits": "base",
"hidden": false,
"configurePreset": "release"
},
{
"name": "debug-vcpkg",
"description": "Debug + vcpkg",
"inherits": "base",
"hidden": false,
"configurePreset": "debug-vcpkg"
}
]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN \
cd opentelemetry-cpp && \
cmake \
-B build \
-DWITH_DEPRECATED_SDK_FACTORY=OFF -DWITH_NO_DEPRECATED_CODE=ON -DWITH_OTLP_HTTP=OFF \
-DWITH_NO_DEPRECATED_CODE=ON -DWITH_OTLP_HTTP=OFF \
-DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DWITH_FUNC_TESTS=OFF -DWITH_EXAMPLES=OFF && \
cmake --build build -j "$(nproc)" && \
cmake --install build
Expand Down

0 comments on commit e1399a2

Please sign in to comment.