diff --git a/CMakeLists.txt b/CMakeLists.txt index ffda16259..001f7db82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,8 @@ configure_file(golang/pkg/client/version.go.in ${PROJECT_SOURCE_DIR}/golang/pkg/ if(NOT DEFINED ENV{VERSION_ONLY}) -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_BINARY_DIR}) +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/cmake/FindCorrade.cmake b/cmake/FindCorrade.cmake deleted file mode 100644 index 6851f0a5a..000000000 --- a/cmake/FindCorrade.cmake +++ /dev/null @@ -1,633 +0,0 @@ -#.rst: -# Find Corrade -# ------------ -# -# Finds the Corrade library. Basic usage:: -# -# find_package(Corrade REQUIRED) -# -# This module tries to find the base Corrade library and then defines the -# following: -# -# Corrade_FOUND - Whether the base library was found -# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module -# -# This command will try to find only the base library, not the optional -# components, which are: -# -# Containers - Containers library -# Interconnect - Interconnect library -# Main - Main library -# PluginManager - PluginManager library -# TestSuite - TestSuite library -# Utility - Utility library -# rc - corrade-rc executable -# -# Example usage with specifying additional components is:: -# -# find_package(Corrade REQUIRED Utility TestSuite) -# -# For each component is then defined: -# -# Corrade_*_FOUND - Whether the component was found -# Corrade::* - Component imported target -# -# The package is found if either debug or release version of each library is -# found. If both debug and release libraries are found, proper version is -# chosen based on actual build configuration of the project (i.e. Debug build -# is linked to debug libraries, Release build to release libraries). -# -# Corrade conditionally defines ``CORRADE_IS_DEBUG_BUILD`` preprocessor -# variable in case build configuration is ``Debug`` (not Corrade itself, but -# build configuration of the project using it). Useful e.g. for selecting -# proper plugin directory. -# -# Corrade defines the following custom target properties: -# -# CORRADE_CXX_STANDARD - C++ standard to require when compiling given -# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains -# particular standard setting flag or if given target contains -# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17. -# INTERFACE_CORRADE_CXX_STANDARD - C++ standard to require when using given -# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains -# particular standard setting flag or if given target contains -# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17. -# CORRADE_USE_PEDANTIC_FLAGS - Enable additional compiler/linker flags. -# Boolean. -# -# These properties are inherited from directory properties, meaning that if you -# set them on directories, they get implicitly set on all targets in given -# directory (with a possibility to do target-specific overrides). All Corrade -# libraries have the :prop_tgt:`INTERFACE_CORRADE_CXX_STANDARD` property set to -# 11, meaning that you will always have at least C++11 enabled once you link to -# any Corrade library. -# -# Features of found Corrade library are exposed in these variables: -# -# CORRADE_MSVC_COMPATIBILITY - Defined if compiled with compatibility -# mode for MSVC 2019+ without the /permissive- flag set -# CORRADE_MSVC2017_COMPATIBILITY - Defined if compiled with compatibility -# mode for MSVC 2017 -# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility -# mode for MSVC 2015 -# CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated APIs -# included -# CORRADE_BUILD_STATIC - Defined if compiled as static libraries. -# Default are shared libraries. -# CORRADE_BUILD_STATIC_UNIQUE_GLOBALS - Defined if static libraries keep their -# globals unique even across different shared libraries. Enabled by default -# for static builds. -# CORRADE_BUILD_MULTITHREADED - Defined if compiled in a way that makes it -# possible to safely use certain Corrade features simultaneously in multiple -# threads -# CORRADE_BUILD_CPU_RUNTIME_DISPATCH - Defined if built with code paths -# optimized for multiple architectres with the best matching variant selected -# at runtime based on detected CPU features -# CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor -# (Linux, BSD, macOS) -# CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms -# CORRADE_TARGET_IOS - Defined if compiled for iOS (device or -# simulator) -# CORRADE_TARGET_IOS_SIMULATOR - Defined if compiled for iOS Simulator -# CORRADE_TARGET_WINDOWS - Defined if compiled for Windows -# CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT -# CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten -# CORRADE_TARGET_ANDROID - Defined if compiled for Android -# CORRADE_TARGET_GCC - Defined if compiling with GCC or GCC- -# compatible Clang -# CORRADE_TARGET_CLANG - Defined if compiling with Clang or any of its -# variants -# CORRADE_TARGET_APPLE_CLANG - Defined if compiling with Apple's Clang -# CORRADE_TARGET_CLANG_CL - Defined if compiling with Clang-CL (Clang -# with a MSVC frontend) -# CORRADE_TARGET_MSVC - Defined if compiling with MSVC or Clang with -# a MSVC frontend -# CORRADE_TARGET_MINGW - Defined if compiling under MinGW -# CORRADE_CPU_USE_IFUNC - Defined if GNU IFUNC is allowed to be used -# for runtime dispatch in the Cpu library -# CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT - Defined if PluginManager -# doesn't support dynamic plugin loading due to platform limitations -# CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targeting Xcode -# XCTest -# CORRADE_UTILITY_USE_ANSI_COLORS - Defined if ANSI escape sequences are used -# for colored output with Utility::Debug on Windows -# -# Additionally these variables are defined for internal usage: -# -# CORRADE_INCLUDE_DIR - Root include dir -# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found -# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if found -# CORRADE_*_EXECUTABLE - Location of given executable, if found -# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included -# automatically) -# CORRADE_TESTSUITE_XCTEST_RUNNER - Path to XCTestRunner.mm.in file -# CORRADE_TESTSUITE_ADB_RUNNER - Path to AdbRunner.sh file -# CORRADE_PEDANTIC_COMPILER_OPTIONS - List of pedantic compiler options used -# for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` enabled -# CORRADE_PEDANTIC_COMPILER_DEFINITIONS - List of pedantic compiler -# definitions used for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` -# enabled -# CORRADE_CXX{11,14,17,20}_STANDARD_FLAG - Compiler flag to use for targeting -# C++11, 14, 17 or 20 in cases where it's not possible to use -# :prop_tgt:`CORRADE_CXX_STANDARD`. Not defined if a standard switch is -# already present in :variable:`CMAKE_CXX_FLAGS`. -# -# Corrade provides these macros and functions: -# -# .. command:: corrade_add_test -# -# Add unit test using Corrade's TestSuite:: -# -# corrade_add_test( -# ... -# [LIBRARIES ...] -# [FILES ...] -# [ARGUMENTS ...]) -# -# Test name is also executable name. You can use ``LIBRARIES`` to specify -# libraries to link with instead of using :command:`target_link_libraries()`. -# The ``Corrade::TestSuite`` target is linked automatically to each test. Note -# that the :command:`enable_testing()` function must be called explicitly. -# Arguments passed after ``ARGUMENTS`` will be appended to the test -# command line. ``ARGUMENTS`` are supported everywhere except when -# ``CORRADE_TESTSUITE_TARGET_XCTEST`` is enabled. -# -# You can list files needed by the test in the ``FILES`` section. If given -# filename is relative, it is treated relatively to `CMAKE_CURRENT_SOURCE_DIR`. -# The files are added to the :prop_test:`REQUIRED_FILES` target property. On -# Emscripten they are bundled to the executable and available in the virtual -# filesystem root. On Android they are copied along the executable to the -# target. In case of Emscripten and Android, if the file is absolute or -# contains ``..``, only the leaf name is used. Alternatively you can have a -# filename formatted as ``@``, in which case the ```` is -# treated as local filesystem location and ```` as remote/virtual -# filesystem location. The remote location can't be absolute or contain ``..`` -# / ``@`` characters. -# -# Unless :variable:`CORRADE_TESTSUITE_TARGET_XCTEST` is set, test cases on iOS -# targets are created as bundles with bundle identifier set to CMake project -# name by default. Use the cache variable :variable:`CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX` -# to change it to something else. -# -# .. command:: corrade_add_resource -# -# Compile data resources into application binary:: -# -# corrade_add_resource( ) -# -# Depends on ``Corrade::rc``, which is part of Corrade utilities. This command -# generates resource data using given configuration file in current build -# directory. Argument name is name under which the resources can be explicitly -# loaded. Variable ```` contains compiled resource filename, which is -# then used for compiling library / executable. On CMake >= 3.1 the -# `resources.conf` file can contain UTF-8-encoded filenames. Example usage:: -# -# corrade_add_resource(app_resources resources.conf) -# add_executable(app source1 source2 ... ${app_resources}) -# -# .. command:: corrade_add_plugin -# -# Add dynamic plugin:: -# -# corrade_add_plugin( -# ";" -# ";" -# -# ...) -# -# The macro adds a preprocessor directive ``CORRADE_DYNAMIC_PLUGIN`` when -# compiling ````. Additional libraries can be linked in via -# :command:`target_link_libraries(plugin_name ...) `. -# On DLL platforms, the plugin DLLs and metadata files are put into -# ```` / ```` and the -# ``*.lib`` files into ```` / -# ````. On non-DLL platforms everything is put -# into ```` / ````. -# -# If the plugin interface disables plugin metadata files, the -# ```` can be set to ``""``, in which case no metadata file is -# copied anywhere. Otherwise the metadata file is copied and renamed to -# ````, retaining its original extension. -# -# corrade_add_plugin( -# -# -# -# ...) -# -# Unline the above version this puts everything into ```` on -# both DLL and non-DLL platforms. If ```` is set to -# :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for testing purposes), the files -# are copied directly, without the need to perform install step. Note that the -# files are actually put into configuration-based subdirectory, i.e. -# ``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}``. See documentation of -# :variable:`CMAKE_CFG_INTDIR` variable for more information. -# -# .. command:: corrade_add_static_plugin -# -# Add static plugin:: -# -# corrade_add_static_plugin( -# ";" -# -# ...) -# -# The macro adds a preprocessor directive ``CORRADE_STATIC_PLUGIN`` when -# compiling ````. Additional libraries can be linked in via -# :command:`target_link_libraries(plugin_name ...) `. -# The ```` is ignored and included just for compatibility -# with the :command:`corrade_add_plugin` command, everything is installed into -# ````. Note that plugins built in debug configuration -# (e.g. with :variable:`CMAKE_BUILD_TYPE` set to ``Debug``) have ``"-d"`` -# suffix to make it possible to have both debug and release plugins installed -# alongside each other. -# -# If the plugin interface disables plugin metadata files, the -# ```` can be set to ``""``, in which case no metadata file is -# used. Otherwise the metadata file is bundled and renamed to -# ````, retaining its original extension. -# -# corrade_add_static_plugin( -# -# -# ...) -# -# Equivalent to the above with ```` set to ````. -# If ```` is set to :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for -# testing purposes), no installation rules are added. -# -# .. command:: corrade_find_dlls_for_libs -# -# Find corresponding DLLs for library files:: -# -# corrade_find_dlls_for_libs( ...) -# -# Available only on Windows, for all ``*.lib`` files tries to find -# corresponding DLL file. Useful for bundling dependencies for e.g. WinRT -# packages. -# - -# -# This file is part of Corrade. -# -# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, -# 2017, 2018, 2019, 2020, 2021, 2022 -# Vladimír Vondruš -# -# 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 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 -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# - -# Root include dir -find_path(CORRADE_INCLUDE_DIR - NAMES Corrade/Corrade.h) -mark_as_advanced(CORRADE_INCLUDE_DIR) - -# Configuration file -find_file(_CORRADE_CONFIGURE_FILE configure.h - HINTS ${CORRADE_INCLUDE_DIR}/Corrade/) -mark_as_advanced(_CORRADE_CONFIGURE_FILE) - -# We need to open configure.h file from CORRADE_INCLUDE_DIR before we check for -# the components. Bail out with proper error message if it wasn't found. The -# complete check with all components is further below. -if(NOT CORRADE_INCLUDE_DIR) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Corrade - REQUIRED_VARS CORRADE_INCLUDE_DIR _CORRADE_CONFIGURE_FILE) -endif() - -# Read flags from configuration -file(READ ${_CORRADE_CONFIGURE_FILE} _corradeConfigure) -string(REGEX REPLACE ";" "\\\\;" _corradeConfigure "${_corradeConfigure}") -string(REGEX REPLACE "\n" ";" _corradeConfigure "${_corradeConfigure}") -set(_corradeFlags - MSVC2015_COMPATIBILITY - MSVC2017_COMPATIBILITY - MSVC_COMPATIBILITY - BUILD_DEPRECATED - BUILD_STATIC - BUILD_STATIC_UNIQUE_GLOBALS - BUILD_MULTITHREADED - BUILD_CPU_RUNTIME_DISPATCH - TARGET_UNIX - TARGET_APPLE - TARGET_IOS - TARGET_IOS_SIMULATOR - TARGET_WINDOWS - TARGET_WINDOWS_RT - TARGET_EMSCRIPTEN - TARGET_ANDROID - # TARGET_X86 etc, TARGET_32BIT, TARGET_BIG_ENDIAN and TARGET_LIBCXX etc. - # are not exposed to CMake as the meaning is unclear on platforms with - # multi-arch binaries or when mixing different STL implementations. - # TARGET_GCC etc are figured out via UseCorrade.cmake, as the compiler can - # be different when compiling the lib & when using it. - CPU_USE_IFUNC - PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT - TESTSUITE_TARGET_XCTEST - UTILITY_USE_ANSI_COLORS) -foreach(_corradeFlag ${_corradeFlags}) - list(FIND _corradeConfigure "#define CORRADE_${_corradeFlag}" _corrade_${_corradeFlag}) - if(NOT _corrade_${_corradeFlag} EQUAL -1) - set(CORRADE_${_corradeFlag} 1) - endif() -endforeach() - -# CMake module dir -find_path(_CORRADE_MODULE_DIR - NAMES UseCorrade.cmake CorradeLibSuffix.cmake - PATH_SUFFIXES share/cmake/Corrade lib/cmake) -mark_as_advanced(_CORRADE_MODULE_DIR) - -set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake) -set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake) - -# Component distinction (listing them explicitly to avoid mistakes with finding -# unknown components) -set(_CORRADE_LIBRARY_COMPONENTS - Containers Interconnect Main PluginManager TestSuite Utility) -set(_CORRADE_HEADER_ONLY_COMPONENTS Containers) -if(NOT CORRADE_TARGET_WINDOWS) - # CorradeMain is a real library only on windows, a dummy target elsewhere - list(APPEND _CORRADE_HEADER_ONLY_COMPONENTS Main) -endif() -set(_CORRADE_EXECUTABLE_COMPONENTS rc) -# Currently everything is enabled implicitly. Keep in sync with Corrade's root -# CMakeLists.txt. -set(_CORRADE_IMPLICITLY_ENABLED_COMPONENTS - Containers Interconnect Main PluginManager TestSuite Utility rc) - -# Inter-component dependencies -set(_CORRADE_Containers_DEPENDENCIES Utility) -set(_CORRADE_Interconnect_DEPENDENCIES Containers Utility) -set(_CORRADE_PluginManager_DEPENDENCIES Containers Utility rc) -set(_CORRADE_TestSuite_DEPENDENCIES Containers Utility Main) # see below -set(_CORRADE_Utility_DEPENDENCIES Containers rc) - -# Ensure that all inter-component dependencies are specified as well -foreach(_component ${Corrade_FIND_COMPONENTS}) - # Mark the dependencies as required if the component is also required - if(Corrade_FIND_REQUIRED_${_component}) - foreach(_dependency ${_CORRADE_${_component}_DEPENDENCIES}) - set(Corrade_FIND_REQUIRED_${_dependency} TRUE) - endforeach() - endif() - - list(APPEND _CORRADE_ADDITIONAL_COMPONENTS ${_CORRADE_${_component}_DEPENDENCIES}) -endforeach() - -# Main is linked only in corrade_add_test(), not to everything that depends on -# TestSuite, so remove it from the list again once we filled the above -# variables -set(_CORRADE_TestSuite_DEPENDENCIES Containers Utility) - -# Join the lists, remove duplicate components -set(_CORRADE_ORIGINAL_FIND_COMPONENTS ${Corrade_FIND_COMPONENTS}) -if(_CORRADE_ADDITIONAL_COMPONENTS) - list(INSERT Corrade_FIND_COMPONENTS 0 ${_CORRADE_ADDITIONAL_COMPONENTS}) -endif() -if(Corrade_FIND_COMPONENTS) - list(REMOVE_DUPLICATES Corrade_FIND_COMPONENTS) -endif() - -# Find all components -foreach(_component ${Corrade_FIND_COMPONENTS}) - string(TOUPPER ${_component} _COMPONENT) - - # Create imported target in case the library is found. If the project is - # added as subproject to CMake, the target already exists and all the - # required setup is already done from the build tree. - if(TARGET Corrade::${_component}) - set(Corrade_${_component}_FOUND TRUE) - else() - # Library (and not header-only) components - if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) - add_library(Corrade::${_component} UNKNOWN IMPORTED) - - # Try to find both debug and release version - find_library(CORRADE_${_COMPONENT}_LIBRARY_DEBUG Corrade${_component}-d) - find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component}) - mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG - CORRADE_${_COMPONENT}_LIBRARY_RELEASE) - - if(CORRADE_${_COMPONENT}_LIBRARY_RELEASE) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_property(TARGET Corrade::${_component} PROPERTY - IMPORTED_LOCATION_RELEASE ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE}) - endif() - - if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_property(TARGET Corrade::${_component} PROPERTY - IMPORTED_LOCATION_DEBUG ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG}) - endif() - endif() - - # Header-only library components - if(_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) - add_library(Corrade::${_component} INTERFACE IMPORTED) - endif() - - # Default include path names to look for for library / header-only - # components - if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX Corrade/${_component}) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) - endif() - - # Executable components - if(_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS) - add_executable(Corrade::${_component} IMPORTED) - - find_program(CORRADE_${_COMPONENT}_EXECUTABLE corrade-${_component}) - mark_as_advanced(CORRADE_${_COMPONENT}_EXECUTABLE) - - if(CORRADE_${_COMPONENT}_EXECUTABLE) - set_property(TARGET Corrade::${_component} PROPERTY - IMPORTED_LOCATION ${CORRADE_${_COMPONENT}_EXECUTABLE}) - endif() - endif() - - # No special setup for Containers library - - # Interconnect library - if(_component STREQUAL Interconnect) - # Disable /OPT:ICF on MSVC, which merges functions with identical - # contents and thus breaks signal comparison - if(CORRADE_TARGET_WINDOWS AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - if(CMAKE_VERSION VERSION_LESS 3.13) - set_property(TARGET Corrade::${_component} PROPERTY - INTERFACE_LINK_LIBRARIES "-OPT:NOICF,REF") - else() - set_property(TARGET Corrade::${_component} PROPERTY - INTERFACE_LINK_OPTIONS "/OPT:NOICF,REF") - endif() - endif() - - # Main library - elseif(_component STREQUAL Main) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX Corrade) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES Corrade.h) - - if(CORRADE_TARGET_WINDOWS) - if(NOT MINGW) - # Abusing INTERFACE_LINK_LIBRARIES because - # INTERFACE_LINK_OPTIONS is only since 3.13. They treat - # things with `-` in front as linker flags and fortunately - # I can use `-ENTRY` instead of `/ENTRY`. - # https://gitlab.kitware.com/cmake/cmake/issues/16543 - set_property(TARGET Corrade::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "-ENTRY:$<$>>:wmainCRTStartup>$<$>:wWinMainCRTStartup>") - else() - set_property(TARGET Corrade::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "-municode") - endif() - endif() - - # PluginManager library - elseif(_component STREQUAL PluginManager) - # -ldl is handled by Utility now - - # TestSuite library has some additional files - elseif(_component STREQUAL TestSuite) - # XCTest runner file - if(CORRADE_TESTSUITE_TARGET_XCTEST) - find_file(CORRADE_TESTSUITE_XCTEST_RUNNER XCTestRunner.mm.in - PATH_SUFFIXES share/corrade/TestSuite) - set(CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED CORRADE_TESTSUITE_XCTEST_RUNNER) - - # ADB runner file - elseif(CORRADE_TARGET_ANDROID) - find_file(CORRADE_TESTSUITE_ADB_RUNNER AdbRunner.sh - PATH_SUFFIXES share/corrade/TestSuite) - set(CORRADE_TESTSUITE_ADB_RUNNER_NEEDED CORRADE_TESTSUITE_ADB_RUNNER) - - # Emscripten runner file - elseif(CORRADE_TARGET_EMSCRIPTEN) - find_file(CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER EmscriptenRunner.html.in - PATH_SUFFIXES share/corrade/TestSuite) - set(CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER_NEEDED CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER) - endif() - - # Utility library (contains all setup that is used by others) - elseif(_component STREQUAL Utility) - # Top-level include directory - set_property(TARGET Corrade::${_component} APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES ${CORRADE_INCLUDE_DIR}) - - # Require (at least) C++11 for users - set_property(TARGET Corrade::${_component} PROPERTY - INTERFACE_CORRADE_CXX_STANDARD 11) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - COMPATIBLE_INTERFACE_NUMBER_MAX CORRADE_CXX_STANDARD) - - # Path::libraryLocation() needs this - if(CORRADE_TARGET_UNIX) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) - endif() - # AndroidLogStreamBuffer class needs to be linked to log library - if(CORRADE_TARGET_ANDROID) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "log") - endif() - endif() - - # Find library includes - if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS) - find_path(_CORRADE_${_COMPONENT}_INCLUDE_DIR - NAMES ${_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES} - HINTS ${CORRADE_INCLUDE_DIR}/${_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) - mark_as_advanced(_CORRADE_${_COMPONENT}_INCLUDE_DIR) - endif() - - # Add inter-library dependencies - if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS OR _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) - foreach(_dependency ${_CORRADE_${_component}_DEPENDENCIES}) - if(_dependency IN_LIST _CORRADE_LIBRARY_COMPONENTS OR _dependency IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES Corrade::${_dependency}) - endif() - endforeach() - endif() - - # Decide if the component was found - if((_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS OR CORRADE_${_COMPONENT}_LIBRARY_RELEASE OR CORRADE_${_COMPONENT}_LIBRARY_DEBUG)) OR (_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS AND CORRADE_${_COMPONENT}_EXECUTABLE)) - set(Corrade_${_component}_FOUND TRUE) - else() - set(Corrade_${_component}_FOUND FALSE) - endif() - endif() -endforeach() - -# For CMake 3.16+ with REASON_FAILURE_MESSAGE, provide additional potentially -# useful info about the failed components. -if(NOT CMAKE_VERSION VERSION_LESS 3.16) - set(_CORRADE_REASON_FAILURE_MESSAGE ) - # Go only through the originally specified find_package() components, not - # the dependencies added by us afterwards - foreach(_component ${_CORRADE_ORIGINAL_FIND_COMPONENTS}) - if(Corrade_${_component}_FOUND) - continue() - endif() - - # If it's not known at all, tell the user -- it might be a new library - # and an old Find module, or something platform-specific. - if(NOT _component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS) - list(APPEND _CORRADE_REASON_FAILURE_MESSAGE "${_component} is not a known component on this platform.") - # Otherwise, if it's not among implicitly built components, hint that - # the user may need to enable it. - # TODO: currently, the _FOUND variable doesn't reflect if dependencies - # were found. When it will, this needs to be updated to avoid - # misleading messages. - elseif(NOT _component IN_LIST _CORRADE_IMPLICITLY_ENABLED_COMPONENTS) - string(TOUPPER ${_component} _COMPONENT) - list(APPEND _CORRADE_REASON_FAILURE_MESSAGE "${_component} is not built by default. Make sure you enabled CORRADE_WITH_${_COMPONENT} when building Corrade.") - # Otherwise we have no idea. Better be silent than to print something - # misleading. - else() - endif() - endforeach() - - string(REPLACE ";" " " _CORRADE_REASON_FAILURE_MESSAGE "${_CORRADE_REASON_FAILURE_MESSAGE}") - set(_CORRADE_REASON_FAILURE_MESSAGE REASON_FAILURE_MESSAGE "${_CORRADE_REASON_FAILURE_MESSAGE}") -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Corrade REQUIRED_VARS - CORRADE_INCLUDE_DIR - _CORRADE_MODULE_DIR - _CORRADE_CONFIGURE_FILE - ${CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED} - ${CORRADE_TESTSUITE_ADB_RUNNER_NEEDED} - ${CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER_NEEDED} - HANDLE_COMPONENTS - ${_CORRADE_REASON_FAILURE_MESSAGE}) - -# Finalize the finding process -include(${CORRADE_USE_MODULE}) - -set(CORRADE_INCLUDE_INSTALL_DIR include/Corrade) - -if(CORRADE_BUILD_DEPRECATED AND CORRADE_INCLUDE_INSTALL_PREFIX AND NOT CORRADE_INCLUDE_INSTALL_PREFIX STREQUAL ".") - message(DEPRECATION "CORRADE_INCLUDE_INSTALL_PREFIX is obsolete as its primary use was for old Android NDK versions. Please switch to the NDK r19+ layout instead of using this variable and recreate your build directory to get rid of this warning.") - set(CORRADE_INCLUDE_INSTALL_DIR ${CORRADE_INCLUDE_INSTALL_PREFIX}/${CORRADE_INCLUDE_INSTALL_DIR}) -endif() \ No newline at end of file diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 0edeab933..6a52cb3af 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -2,32 +2,33 @@ # SPDX-License-Identifier: Apache-2.0 # -# The dependency on opentelemetry-proto can be provided different ways. -# By order of decreasing priority, options are: +# The dependency on opentelemetry-proto can be provided different ways. By order +# of decreasing priority, options are: # # 1 - Use a provided package # # This is useful to build opentelemetry-cpp as part of a super project. # -# The super project provides the path to the opentelemetry-proto -# source code using variable ${OTELCPP_PROTO_PATH} +# The super project provides the path to the opentelemetry-proto source code +# using variable ${OTELCPP_PROTO_PATH} # # 2 - Search for a opentelemetry-proto git submodule # -# When git submodule is used, -# the opentelemetry-proto code is located in: +# When git submodule is used, the opentelemetry-proto code is located in: # third_party/opentelemetry-proto # # 3 - Download opentelemetry-proto from github # -# Code from the required version is used, -# unless a specific release tag is provided -# in variable ${opentelemetry-proto} +# Code from the required version is used, unless a specific release tag is +# provided in variable ${opentelemetry-proto} # if(OTELCPP_PROTO_PATH) - if(NOT EXISTS "${OTELCPP_PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") - message(FATAL_ERROR "OTELCPP_PROTO_PATH does not point to a opentelemetry-proto repository") + if(NOT EXISTS + "${OTELCPP_PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") + message( + FATAL_ERROR + "OTELCPP_PROTO_PATH does not point to a opentelemetry-proto repository") endif() message(STATUS "opentelemetry-proto dependency satisfied by: external path") set(PROTO_PATH ${OTELCPP_PROTO_PATH}) @@ -35,12 +36,14 @@ if(OTELCPP_PROTO_PATH) else() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git) message(STATUS "opentelemetry-proto dependency satisfied by: git submodule") - set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto") + set(PROTO_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto") set(needs_proto_download FALSE) else() - message(STATUS "opentelemetry-proto dependency satisfied by: github download") + message( + STATUS "opentelemetry-proto dependency satisfied by: github download") if("${opentelemetry-proto}" STREQUAL "") - set(opentelemetry-proto "v0.19.0") + set(opentelemetry-proto "v1.0.0") endif() include(ExternalProject) ExternalProject_Add( @@ -62,8 +65,6 @@ else() endif() endif() -include(${PROJECT_SOURCE_DIR}/cmake/proto-options-patch.cmake) - set(COMMON_PROTO "${PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") set(RESOURCE_PROTO "${PROTO_PATH}/opentelemetry/proto/resource/v1/resource.proto") @@ -166,91 +167,129 @@ if(WITH_OTLP_GRPC) message(STATUS "gRPC_CPP_PLUGIN_EXECUTABLE=${gRPC_CPP_PLUGIN_EXECUTABLE}") endif() -if(WITH_OTLP_GRPC) - add_custom_command( - OUTPUT ${COMMON_PB_H_FILE} - ${COMMON_PB_CPP_FILE} - ${RESOURCE_PB_H_FILE} - ${RESOURCE_PB_CPP_FILE} - ${TRACE_PB_H_FILE} - ${TRACE_PB_CPP_FILE} - ${LOGS_PB_H_FILE} - ${LOGS_PB_CPP_FILE} - ${METRICS_PB_H_FILE} - ${METRICS_PB_CPP_FILE} - ${TRACE_SERVICE_PB_H_FILE} - ${TRACE_SERVICE_PB_CPP_FILE} - ${TRACE_SERVICE_GRPC_PB_H_FILE} - ${TRACE_SERVICE_GRPC_PB_CPP_FILE} - ${LOGS_SERVICE_PB_H_FILE} - ${LOGS_SERVICE_PB_CPP_FILE} - ${LOGS_SERVICE_GRPC_PB_H_FILE} - ${LOGS_SERVICE_GRPC_PB_CPP_FILE} - ${METRICS_SERVICE_PB_H_FILE} - ${METRICS_SERVICE_PB_CPP_FILE} - ${METRICS_SERVICE_GRPC_PB_H_FILE} - ${METRICS_SERVICE_GRPC_PB_CPP_FILE} - COMMAND - ${PROTOBUF_PROTOC_EXECUTABLE} ARGS "--experimental_allow_proto3_optional" - "--proto_path=${PROTO_PATH}" ${PROTOBUF_INCLUDE_FLAGS} - "--cpp_out=${GENERATED_PROTOBUF_PATH}" - "--grpc_out=generate_mock_code=true:${GENERATED_PROTOBUF_PATH}" - --plugin=protoc-gen-grpc="${gRPC_CPP_PLUGIN_EXECUTABLE}" ${COMMON_PROTO} - ${RESOURCE_PROTO} ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} - ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} ${METRICS_SERVICE_PROTO}) -else() - add_custom_command( - OUTPUT ${COMMON_PB_H_FILE} - ${COMMON_PB_CPP_FILE} - ${RESOURCE_PB_H_FILE} - ${RESOURCE_PB_CPP_FILE} - ${TRACE_PB_H_FILE} - ${TRACE_PB_CPP_FILE} - ${LOGS_PB_H_FILE} - ${LOGS_PB_CPP_FILE} - ${METRICS_PB_H_FILE} - ${METRICS_PB_CPP_FILE} - ${TRACE_SERVICE_PB_H_FILE} - ${TRACE_SERVICE_PB_CPP_FILE} - ${LOGS_SERVICE_PB_H_FILE} - ${LOGS_SERVICE_PB_CPP_FILE} - ${METRICS_SERVICE_PB_H_FILE} - ${METRICS_SERVICE_PB_CPP_FILE} - COMMAND - ${PROTOBUF_PROTOC_EXECUTABLE} ARGS "--experimental_allow_proto3_optional" - "--proto_path=${PROTO_PATH}" ${PROTOBUF_INCLUDE_FLAGS} - "--cpp_out=${GENERATED_PROTOBUF_PATH}" ${COMMON_PROTO} ${RESOURCE_PROTO} - ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} - ${LOGS_SERVICE_PROTO} ${METRICS_SERVICE_PROTO}) +set(PROTOBUF_COMMON_FLAGS "--proto_path=${PROTO_PATH}" + "--cpp_out=${GENERATED_PROTOBUF_PATH}") +# --experimental_allow_proto3_optional is available from 3.13 and be stable and +# enabled by default from 3.16 +if(Protobuf_VERSION AND Protobuf_VERSION VERSION_LESS "3.16") + list(APPEND PROTOBUF_COMMON_FLAGS "--experimental_allow_proto3_optional") +elseif(PROTOBUF_VERSION AND PROTOBUF_VERSION VERSION_LESS "3.16") + list(APPEND PROTOBUF_COMMON_FLAGS "--experimental_allow_proto3_optional") endif() -include_directories("${GENERATED_PROTOBUF_PATH}") - -if(WITH_OTLP_GRPC) - add_library( - opentelemetry_proto STATIC +set(PROTOBUF_GENERATED_FILES + ${COMMON_PB_H_FILE} ${COMMON_PB_CPP_FILE} + ${RESOURCE_PB_H_FILE} ${RESOURCE_PB_CPP_FILE} + ${TRACE_PB_H_FILE} ${TRACE_PB_CPP_FILE} + ${LOGS_PB_H_FILE} ${LOGS_PB_CPP_FILE} + ${METRICS_PB_H_FILE} ${METRICS_PB_CPP_FILE} + ${TRACE_SERVICE_PB_H_FILE} ${TRACE_SERVICE_PB_CPP_FILE} - ${TRACE_SERVICE_GRPC_PB_CPP_FILE} + ${LOGS_SERVICE_PB_H_FILE} ${LOGS_SERVICE_PB_CPP_FILE} + ${METRICS_SERVICE_PB_H_FILE} + ${METRICS_SERVICE_PB_CPP_FILE}) + +if(WITH_OTLP_GRPC) + list(APPEND PROTOBUF_COMMON_FLAGS + "--grpc_out=generate_mock_code=true:${GENERATED_PROTOBUF_PATH}" + --plugin=protoc-gen-grpc="${gRPC_CPP_PLUGIN_EXECUTABLE}") + + list( + APPEND + PROTOBUF_GENERATED_FILES + ${TRACE_SERVICE_GRPC_PB_H_FILE} + ${TRACE_SERVICE_GRPC_PB_CPP_FILE} + ${LOGS_SERVICE_GRPC_PB_H_FILE} ${LOGS_SERVICE_GRPC_PB_CPP_FILE} - ${METRICS_SERVICE_PB_CPP_FILE} + ${METRICS_SERVICE_GRPC_PB_H_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE}) +endif() + +set(PROTOBUF_RUN_PROTOC_COMMAND "\"${PROTOBUF_PROTOC_EXECUTABLE}\"") +foreach( + PROTOBUF_RUN_PROTOC_ARG + ${PROTOBUF_COMMON_FLAGS} + ${PROTOBUF_INCLUDE_FLAGS} + ${COMMON_PROTO} + ${RESOURCE_PROTO} + ${TRACE_PROTO} + ${LOGS_PROTO} + ${METRICS_PROTO} + ${TRACE_SERVICE_PROTO} + ${LOGS_SERVICE_PROTO} + ${METRICS_SERVICE_PROTO}) + set(PROTOBUF_RUN_PROTOC_COMMAND + "${PROTOBUF_RUN_PROTOC_COMMAND} \"${PROTOBUF_RUN_PROTOC_ARG}\"") +endforeach() + +add_custom_command( + OUTPUT ${PROTOBUF_GENERATED_FILES} + COMMAND + ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTOBUF_COMMON_FLAGS} + ${PROTOBUF_INCLUDE_FLAGS} ${COMMON_PROTO} ${RESOURCE_PROTO} ${TRACE_PROTO} + ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} + ${METRICS_SERVICE_PROTO} + COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}") + +include_directories("${GENERATED_PROTOBUF_PATH}") + +unset(OTELCPP_PROTO_TARGET_OPTIONS) +if(CMAKE_SYSTEM_NAME MATCHES "Windows|MinGW|WindowsStore") + list(APPEND OTELCPP_PROTO_TARGET_OPTIONS STATIC) +elseif(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) + list(APPEND OTELCPP_PROTO_TARGET_OPTIONS SHARED) else() + list(APPEND OTELCPP_PROTO_TARGET_OPTIONS STATIC) +endif() + +set(OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto) +add_library( + opentelemetry_proto + ${OTELCPP_PROTO_TARGET_OPTIONS} + ${COMMON_PB_CPP_FILE} + ${RESOURCE_PB_CPP_FILE} + ${TRACE_PB_CPP_FILE} + ${LOGS_PB_CPP_FILE} + ${METRICS_PB_CPP_FILE} + ${TRACE_SERVICE_PB_CPP_FILE} + ${LOGS_SERVICE_PB_CPP_FILE} + ${METRICS_SERVICE_PB_CPP_FILE}) + +if(WITH_ABSEIL) + target_link_libraries(opentelemetry_proto PUBLIC absl::bad_variant_access) +endif() + +if(WITH_OTLP_GRPC) add_library( - opentelemetry_proto STATIC - ${COMMON_PB_CPP_FILE} - ${RESOURCE_PB_CPP_FILE} - ${TRACE_PB_CPP_FILE} - ${LOGS_PB_CPP_FILE} - ${METRICS_PB_CPP_FILE} - ${TRACE_SERVICE_PB_CPP_FILE} - ${LOGS_SERVICE_PB_CPP_FILE} - ${METRICS_SERVICE_PB_CPP_FILE}) + opentelemetry_proto_grpc + ${OTELCPP_PROTO_TARGET_OPTIONS} ${TRACE_SERVICE_GRPC_PB_CPP_FILE} + ${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE}) + + list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc) + target_link_libraries(opentelemetry_proto_grpc + PUBLIC opentelemetry_proto) + + get_target_property(grpc_lib_type gRPC::grpc++ TYPE) + if (grpc_lib_type STREQUAL "SHARED_LIBRARY") + target_link_libraries(opentelemetry_proto_grpc + PUBLIC gRPC::grpc++) + endif() + set_target_properties(opentelemetry_proto_grpc PROPERTIES EXPORT_NAME + proto_grpc) + patch_protobuf_targets(opentelemetry_proto_grpc) + get_target_property(GRPC_INCLUDE_DIRECTORY gRPC::grpc++ + INTERFACE_INCLUDE_DIRECTORIES) + if(GRPC_INCLUDE_DIRECTORY) + target_include_directories( + opentelemetry_proto_grpc + PUBLIC "$") + endif() endif() if(needs_proto_download) @@ -259,27 +298,41 @@ endif() set_target_properties(opentelemetry_proto PROPERTIES EXPORT_NAME proto) patch_protobuf_targets(opentelemetry_proto) -install( - TARGETS opentelemetry_proto - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS ${OPENTELEMETRY_PROTO_TARGETS} + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install( - DIRECTORY ${GENERATED_PROTOBUF_PATH}/opentelemetry - DESTINATION include - FILES_MATCHING - PATTERN "*.h") + install( + DIRECTORY ${GENERATED_PROTOBUF_PATH}/opentelemetry + DESTINATION include + FILES_MATCHING + PATTERN "*.h") +endif() if(TARGET protobuf::libprotobuf) target_link_libraries(opentelemetry_proto PUBLIC ${CONAN_LIBS_PROTOBUF}) else() # cmake 3.8 or lower target_include_directories(opentelemetry_proto PUBLIC ${Protobuf_INCLUDE_DIRS}) - target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES}) + target_link_libraries(opentelemetry_proto PUBLIC ${Protobuf_LIBRARIES}) endif() -if(BUILD_SHARED_LIBS) - set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) +if(WITH_OTLP_GRPC) + if(WITH_ABSEIL) + find_package(absl CONFIG) + if(TARGET absl::synchronization) + target_link_libraries(opentelemetry_proto_grpc + PRIVATE absl::synchronization) + endif() + endif() endif() + +if(BUILD_SHARED_LIBS) + foreach(proto_target ${OPENTELEMETRY_PROTO_TARGETS}) + set_property(TARGET ${proto_target} PROPERTY POSITION_INDEPENDENT_CODE ON) + endforeach() +endif() \ No newline at end of file diff --git a/cmake/proto-options-patch.cmake b/cmake/opentelemetry-tools.cmake similarity index 96% rename from cmake/proto-options-patch.cmake rename to cmake/opentelemetry-tools.cmake index ed294ea79..84ce8be91 100644 --- a/cmake/proto-options-patch.cmake +++ b/cmake/opentelemetry-tools.cmake @@ -11,7 +11,7 @@ endmacro() if(NOT PATCH_PROTOBUF_SOURCES_OPTIONS_SET) if(MSVC) unset(PATCH_PROTOBUF_SOURCES_OPTIONS CACHE) - set(PATCH_PROTOBUF_SOURCES_OPTIONS /wd4244 /wd4251 /wd4267 /wd4309) + set(PATCH_PROTOBUF_SOURCES_OPTIONS /wd4244 /wd4251 /wd4267 /wd4309 /wd4668 /wd4946 /wd6001 /wd6244 /wd6246) if(MSVC_VERSION GREATER_EQUAL 1922) # see @@ -31,7 +31,7 @@ if(NOT PATCH_PROTOBUF_SOURCES_OPTIONS_SET) unset(PATCH_PROTOBUF_SOURCES_OPTIONS CACHE) include(CheckCXXCompilerFlag) check_append_cxx_compiler_flag( - PATCH_PROTOBUF_SOURCES_OPTIONS -Wno-type-limits + PATCH_PROTOBUF_SOURCES_OPTIONS -Wno-type-limits -Wno-missing-declarations -Wno-deprecated-declarations -Wno-unused-parameter) endif() set(PATCH_PROTOBUF_SOURCES_OPTIONS_SET TRUE) diff --git a/conanfile.txt b/conanfile.txt index 8342cf370..ea7f4413a 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,30 +1,32 @@ [requires] -benchmark/1.7.0 -catch2/2.13.9 +benchmark/1.8.3 +catch2/2.13.10 corrade/2020.06 -cpp-httplib/0.11.2 +cpp-httplib/0.14.0 docopt.cpp/0.6.3 -fmt/8.1.1 fast-cpp-csv-parser/cci.20211104 json-schema-validator/2.2.0 libmaxminddb/1.7.1 nlohmann_json/3.11.2 openssl/1.1.1k -opentelemetry-proto/0.19.0 +opentelemetry-proto/1.0.0 pcapplusplus/22.11 -protobuf/3.19.2 -sigslot/1.2.1 -spdlog/1.11.0 +protobuf/3.21.12 +sigslot/1.2.2 +spdlog/1.12.0 uvw/2.12.1 -libpcap/1.10.1 -yaml-cpp/0.7.0 +libpcap/1.10.4 +yaml-cpp/0.8.0 robin-hood-hashing/3.11.5 -zlib/1.2.12 crashpad/cci.20220219 +zlib/[>=1.2.10 <1.3] -[build_requires] +[tool_requires] corrade/2020.06 -protobuf/3.19.2 +protobuf/3.21.12 [options] pcapplusplus:immediate_mode=True + +[generators] +cmake_find_package \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6d8be32f..ee1c8fc54 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,13 @@ message(STATUS "visor-core") -find_package(Corrade REQUIRED PluginManager) - set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON) +#generate cpp code from opentelemetry-proto find_package(Protobuf REQUIRED) set(OTELCPP_PROTO_PATH ${CONAN_OPENTELEMETRY-PROTO_ROOT}/res) +set(BUILD_SHARED_LIBS FALSE) +include(opentelemetry-tools) include(opentelemetry-proto) add_library(visor-core diff --git a/src/GeoDB.cpp b/src/GeoDB.cpp index 9b3f0b2fc..a6e70a49f 100644 --- a/src/GeoDB.cpp +++ b/src/GeoDB.cpp @@ -4,6 +4,7 @@ #include "GeoDB.h" #include +#include #include namespace visor::geo { @@ -112,7 +113,7 @@ City MaxmindDB::getGeoLoc(const struct sockaddr_in6 *sa6) const std::string ip_address; if (_lru_geo_cache) { - ip_address = fmt::format("{}", sa6->sin6_addr.s6_addr); + ip_address = fmt::format("{}", fmt::join(sa6->sin6_addr.s6_addr, "")); std::shared_lock lock(_cache_mutex); if (auto geoloc = _lru_geo_cache->getValue(ip_address); geoloc.has_value()) { return geoloc.value(); @@ -304,7 +305,7 @@ std::string MaxmindDB::getASNString(const struct sockaddr_in6 *sa6) const std::string ip_address; if (_lru_asn_cache) { - ip_address = fmt::format("{}", sa6->sin6_addr.s6_addr); + ip_address = fmt::format("{}", fmt::join(sa6->sin6_addr.s6_addr, "")); std::shared_lock lock(_cache_mutex); if (auto asn = _lru_asn_cache->getValue(ip_address); asn.has_value()) { return asn.value(); diff --git a/src/GeoDB.h b/src/GeoDB.h index 672f3dc67..f8b1ccbdf 100644 --- a/src/GeoDB.h +++ b/src/GeoDB.h @@ -8,7 +8,6 @@ #pragma GCC diagnostic ignored "-Wpedantic" #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif -#include #include #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/src/Taps.cpp b/src/Taps.cpp index 2d61bee38..55153128d 100644 --- a/src/Taps.cpp +++ b/src/Taps.cpp @@ -183,15 +183,15 @@ bool Tap::tags_match_selector_yaml(const YAML::Node &tag_yaml, bool all) } const auto it_module = it->begin(); + const auto &key = it_module->first.as(); if (!it_module->first.IsScalar()) { - throw TapException(fmt::format("tag key '{}' have be scalar", it_module->first)); + throw TapException(fmt::format("tag key '{}' have be scalar", key)); } if (!it_module->second.IsScalar()) { - throw TapException(fmt::format("tag key '{}' must have scalar value", it_module->first)); + throw TapException(fmt::format("tag key '{}' must have scalar value", key)); } - auto key = it_module->first.as(); if (!_tags->config_exists(key)) { if (all) { return false; diff --git a/src/handlers/dns/v1/DnsStreamHandler.h b/src/handlers/dns/v1/DnsStreamHandler.h index 4e2aa522b..da5d7ed56 100644 --- a/src/handlers/dns/v1/DnsStreamHandler.h +++ b/src/handlers/dns/v1/DnsStreamHandler.h @@ -11,7 +11,7 @@ #include "StreamHandler.h" #include "TransactionManager.h" #include "dns.h" -#include "dnstap.pb.h" +#include "pb/dnstap.pb.h" #include #include #include diff --git a/src/handlers/dns/v2/DnsStreamHandler.h b/src/handlers/dns/v2/DnsStreamHandler.h index c0e6374cb..45a0cb3cd 100644 --- a/src/handlers/dns/v2/DnsStreamHandler.h +++ b/src/handlers/dns/v2/DnsStreamHandler.h @@ -11,7 +11,7 @@ #include "StreamHandler.h" #include "TransactionManager.h" #include "dns.h" -#include "dnstap.pb.h" +#include "pb/dnstap.pb.h" #include #include #include diff --git a/src/inputs/dnstap/CMakeLists.txt b/src/inputs/dnstap/CMakeLists.txt index 717fda680..ae5b86ce4 100644 --- a/src/inputs/dnstap/CMakeLists.txt +++ b/src/inputs/dnstap/CMakeLists.txt @@ -2,7 +2,6 @@ message(STATUS "Input Module: Dnstap") set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON) -find_package(Protobuf REQUIRED) protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS pb/dnstap.proto) corrade_add_static_plugin(VisorInputDnstap ${CMAKE_CURRENT_BINARY_DIR} diff --git a/src/inputs/dnstap/DnstapInputStream.cpp b/src/inputs/dnstap/DnstapInputStream.cpp index 2a10a0d5a..645319b27 100644 --- a/src/inputs/dnstap/DnstapInputStream.cpp +++ b/src/inputs/dnstap/DnstapInputStream.cpp @@ -75,7 +75,7 @@ void DnstapInputStream::_read_frame_stream_file() break; } else { // Abnormal end - _logger->warn("fstrm_reader_read() data stream ended abnormally: {}", result); + _logger->warn("fstrm_reader_read() data stream ended abnormally: {}", static_cast(result)); break; } } @@ -363,13 +363,13 @@ void DnstapInputStream::_create_frame_stream_unix_socket() }); // client read EOF client->on([this](const uvw::EndEvent &, uvw::PipeHandle &c_sock) { - _logger->info("[{}]: dnstap client EOF {}", _name, c_sock.fd()); + _logger->info("[{}]: dnstap client EOF {}", _name, c_sock.sock()); c_sock.stop(); c_sock.close(); }); _unix_server_h->accept(*client); - _logger->info("[{}]: dnstap client connected {}", _name, client->fd()); + _logger->info("[{}]: dnstap client connected {}", _name, client->sock()); _unix_sessions[client->fd()] = std::make_unique>(client, CONTENT_TYPE, on_data_frame); client->read(); }); diff --git a/src/inputs/dnstap/DnstapInputStream.h b/src/inputs/dnstap/DnstapInputStream.h index 857a6b906..c094c57f2 100644 --- a/src/inputs/dnstap/DnstapInputStream.h +++ b/src/inputs/dnstap/DnstapInputStream.h @@ -11,7 +11,7 @@ #include "UnixFrameSession.h" #endif #include "InputStream.h" -#include "dnstap.pb.h" +#include "pb/dnstap.pb.h" #include "utils.h" #ifdef __GNUC__ #pragma GCC diagnostic push