feat add spdlog
Some checks failed
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Failing after 29s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Failing after 16s
sm-rpc / build (Debug, host.gcc) (push) Failing after 11s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Failing after 12s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Failing after 11s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Failing after 11s
sm-rpc / build (Release, host.gcc) (push) Failing after 12s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Failing after 16s

This commit is contained in:
tqcq
2025-08-22 18:22:57 +08:00
parent 3d395b45f0
commit c68893bace
2331 changed files with 1306786 additions and 103 deletions

View File

@@ -0,0 +1,37 @@
# Inspired by CheckAtomic.cmake from LLVM project:
# https://github.com/llvm/llvm-project/blob/master/llvm/cmake/modules/CheckAtomic.cmake
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
include(CheckCXXSourceCompiles)
include(CheckLibraryExists)
function(check_working_cxx_atomics varname)
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<std::uint64_t> x(0);
int main() {
std::uint64_t i = x.load(std::memory_order_relaxed);
return static_cast<int>(i);
}
" ${varname})
endfunction()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
# First check if atomics work without the library.
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
# If not, check if the library exists, and atomics work with it.
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMIC)
if(HAVE_CXX_LIBATOMIC)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
if(NOT HAVE_CXX_ATOMICS_WITH_LIB)
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
endif()
else()
message(FATAL_ERROR "Host compiler appears to require libatomic for 64-bit operations, but cannot find it.")
endif()
endif()
endif()

View File

@@ -0,0 +1,9 @@
find_program(Telegraf_EXECUTABLE NAMES telegraf)
mark_as_advanced(Telegraf_EXECUTABLE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Telegraf
FOUND_VAR Telegraf_FOUND
REQUIRED_VARS
Telegraf_EXECUTABLE
)

View File

@@ -0,0 +1,73 @@
get_filename_component(_IMPORT_PREFIX "${PROJECT_SOURCE_DIR}/3rdparty/civetweb/" ABSOLUTE)
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
set_and_check(CIVETWEB_INCLUDE_DIR ${_IMPORT_PREFIX}/include)
set(CIVETWEB_INCLUDE_DIRS "${CIVETWEB_INCLUDE_DIR}")
add_library(civetweb OBJECT
${_IMPORT_PREFIX}/include/CivetServer.h
${_IMPORT_PREFIX}/include/civetweb.h
${_IMPORT_PREFIX}/src/CivetServer.cpp
${_IMPORT_PREFIX}/src/civetweb.c
${_IMPORT_PREFIX}/src/handle_form.inl
${_IMPORT_PREFIX}/src/md5.inl
)
set_property(TARGET civetweb PROPERTY PUBLIC_HEADER
${_IMPORT_PREFIX}/include/CivetServer.h
${_IMPORT_PREFIX}/include/civetweb.h
)
target_compile_definitions(civetweb
PRIVATE
CIVETWEB_API=
USE_IPV6
NDEBUG
NO_CGI
NO_CACHING
NO_FILES
SOCKET_TIMEOUT_QUANTUM=200
)
target_compile_options(civetweb
PRIVATE
$<$<CXX_COMPILER_ID:AppleClang>:-w>
$<$<CXX_COMPILER_ID:GNU>:-w>
)
target_include_directories(civetweb
PRIVATE
${CIVETWEB_INCLUDE_DIRS}
)
if(THIRDPARTY_CIVETWEB_WITH_SSL)
include(CMakeFindDependencyMacro)
find_dependency(OpenSSL)
if(OPENSSL_VERSION VERSION_GREATER_EQUAL 1.1)
target_compile_definitions(civetweb PRIVATE OPENSSL_API_1_1)
endif()
target_compile_definitions(civetweb PRIVATE NO_SSL_DL)
target_link_libraries(civetweb PUBLIC OpenSSL::SSL)
else()
target_compile_definitions(civetweb PRIVATE NO_SSL)
endif()
if(BUILD_SHARED_LIBS)
set_target_properties(civetweb PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
endif()
set_target_properties(civetweb PROPERTIES
C_INCLUDE_WHAT_YOU_USE ""
CXX_INCLUDE_WHAT_YOU_USE ""
)

View File

@@ -0,0 +1,29 @@
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../3rdparty/googletest/" ABSOLUTE)
find_package(Threads QUIET)
add_library(gmock_main STATIC EXCLUDE_FROM_ALL
${_IMPORT_PREFIX}/googletest/src/gtest-all.cc
${_IMPORT_PREFIX}/googlemock/src/gmock-all.cc
${_IMPORT_PREFIX}/googlemock/src/gmock_main.cc
)
target_include_directories(gmock_main SYSTEM
PUBLIC
${_IMPORT_PREFIX}/googletest/include
${_IMPORT_PREFIX}/googlemock/include
PRIVATE
${_IMPORT_PREFIX}/googletest
${_IMPORT_PREFIX}/googlemock
)
target_link_libraries(gmock_main
PRIVATE
Threads::Threads
)
add_library(GTest::gmock_main ALIAS gmock_main)
set_target_properties(gmock_main PROPERTIES
C_INCLUDE_WHAT_YOU_USE ""
CXX_INCLUDE_WHAT_YOU_USE ""
)

View File

@@ -0,0 +1,6 @@
[
{ include: [ "@<gmock/.*>", private, "<gmock/gmock.h>", public ] },
{ include: [ "@<gtest/.*>", private, "<gtest/gtest.h>", public ] },
{ include: [ "@<bits/chrono.h>", private, "<chrono>", public ]},
{ include: [ "@<bits/this_thread_sleep.h>", private, "<thread>", public ]}
]

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(prometheus-cpp-import)
find_package(prometheus-cpp CONFIG REQUIRED)
if(NOT DEFINED prometheus-cpp_VERSION)
message(FATAL_ERROR "prometheus-cpp_VERSION is not defined")
endif()
if(PROMETHEUS_CPP_ENABLE_PUSH)
add_executable(sample-client sample_client.cc)
target_link_libraries(sample-client PRIVATE prometheus-cpp::push $<$<BOOL:${WIN32}>:Ws2_32>)
endif()
if(PROMETHEUS_CPP_ENABLE_PULL)
add_executable(sample-server sample_server.cc)
target_link_libraries(sample-server PRIVATE prometheus-cpp::pull)
endif()

View File

@@ -0,0 +1 @@
../../push/tests/integration/sample_client.cc

View File

@@ -0,0 +1 @@
../../pull/tests/integration/sample_server.cc

View File

@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(prometheus-cpp-import)
set(CMAKE_CXX_STANDARD 11)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PROMETHEUS_CPP_CORE REQUIRED prometheus-cpp-core)
pkg_check_modules(PROMETHEUS_CPP_PUSH IMPORTED_TARGET prometheus-cpp-push)
pkg_check_modules(PROMETHEUS_CPP_PULL IMPORTED_TARGET prometheus-cpp-pull)
if(PROMETHEUS_CPP_PUSH_FOUND)
add_executable(sample-client sample_client.cc)
target_link_libraries(sample-client PRIVATE PkgConfig::PROMETHEUS_CPP_PUSH $<$<BOOL:${WIN32}>:Ws2_32>)
endif()
if(PROMETHEUS_CPP_PULL_FOUND)
add_executable(sample-server sample_server.cc)
target_link_libraries(sample-server PRIVATE PkgConfig::PROMETHEUS_CPP_PULL)
endif()

View File

@@ -0,0 +1 @@
../../push/tests/integration/sample_client.cc

View File

@@ -0,0 +1 @@
../../pull/tests/integration/sample_server.cc

View File

@@ -0,0 +1,34 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
set_and_check(prometheus-cpp_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set(PROMETHEUS_CPP_ENABLE_PULL @ENABLE_PULL@)
set(PROMETHEUS_CPP_ENABLE_PUSH @ENABLE_PUSH@)
set(PROMETHEUS_CPP_USE_COMPRESSION @ENABLE_COMPRESSION@)
set(PROMETHEUS_CPP_USE_THIRDPARTY_LIBRARIES @USE_THIRDPARTY_LIBRARIES@)
set(PROMETHEUS_CPP_THIRDPARTY_CIVETWEB_WITH_SSL @THIRDPARTY_CIVETWEB_WITH_SSL@)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_dependency(Threads)
unset(CMAKE_THREAD_PREFER_PTHREAD)
if(PROMETHEUS_CPP_ENABLE_PULL)
if(PROMETHEUS_CPP_USE_THIRDPARTY_LIBRARIES)
if(PROMETHEUS_CPP_THIRDPARTY_CIVETWEB_WITH_SSL)
find_dependency(OpenSSL)
endif()
else()
find_dependency(civetweb)
endif()
endif()
if(PROMETHEUS_CPP_ENABLE_PULL AND PROMETHEUS_CPP_USE_COMPRESSION)
find_dependency(ZLIB)
endif()
if(PROMETHEUS_CPP_ENABLE_PUSH)
find_dependency(CURL)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/prometheus-cpp-targets.cmake")

View File

@@ -0,0 +1,14 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@PROMETHEUS_CPP_PKGCONFIG_INCLUDEDIR@
libdir=@PROMETHEUS_CPP_PKGCONFIG_LIBDIR@
Name: @PROJECT_NAME@-core
Description: @PROJECT_DESCRIPTION@
URL: @PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Requires:
Requires.private: @PKGCONFIG_REQUIRES@
Cflags: -I${includedir}
Libs: -L${libdir} -l@PROJECT_NAME@-core
Libs.private: @CMAKE_THREAD_LIBS_INIT@ @PKGCONFIG_LIBS@

View File

@@ -0,0 +1,14 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@PROMETHEUS_CPP_PKGCONFIG_INCLUDEDIR@
libdir=@PROMETHEUS_CPP_PKGCONFIG_LIBDIR@
Name: @PROJECT_NAME@-pull
Description: @PROJECT_DESCRIPTION@
URL: @PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Requires: @PROJECT_NAME@-core
Requires.private: @PKGCONFIG_REQUIRES@
Cflags: -I${includedir}
Libs: -L${libdir} -l@PROJECT_NAME@-pull
Libs.private: @CMAKE_THREAD_LIBS_INIT@ @PKGCONFIG_LIBS@

View File

@@ -0,0 +1,14 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@PROMETHEUS_CPP_PKGCONFIG_INCLUDEDIR@
libdir=@PROMETHEUS_CPP_PKGCONFIG_LIBDIR@
Name: @PROJECT_NAME@-push
Description: @PROJECT_DESCRIPTION@
URL: @PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Requires: @PROJECT_NAME@-core @PKGCONFIG_REQUIRES@
Requires.private:
Cflags: -I${includedir}
Libs: -L${libdir} -l@PROJECT_NAME@-push
Libs.private: @CMAKE_THREAD_LIBS_INIT@ @PKGCONFIG_LIBS@