summaryrefslogtreecommitdiffstats
path: root/fluent-bit/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'fluent-bit/cmake')
-rw-r--r--fluent-bit/cmake/FindJournald.cmake49
-rw-r--r--fluent-bit/cmake/FindLibEdit.cmake72
-rw-r--r--fluent-bit/cmake/FindMonkey.cmake20
-rw-r--r--fluent-bit/cmake/armadillo-iot.cmake13
-rw-r--r--fluent-bit/cmake/headers.cmake65
-rw-r--r--fluent-bit/cmake/homebrew.cmake38
-rw-r--r--fluent-bit/cmake/libraries.cmake26
-rw-r--r--fluent-bit/cmake/luajit.cmake4
-rw-r--r--fluent-bit/cmake/macos-setup.cmake31
-rw-r--r--fluent-bit/cmake/macros.cmake15
-rw-r--r--fluent-bit/cmake/platform_feature_checks.cmake8
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/.gitignore3
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/CMakeLists.txt51
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/LICENSE22
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/README.md73
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/VERSION3
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/cmake/FindASan.cmake62
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/cmake/FindMSan.cmake60
-rwxr-xr-xfluent-bit/cmake/sanitizers-cmake/cmake/FindSanitizers.cmake91
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/cmake/FindTSan.cmake68
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/cmake/FindUBSan.cmake49
-rwxr-xr-xfluent-bit/cmake/sanitizers-cmake/cmake/asan-wrapper55
-rwxr-xr-xfluent-bit/cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake178
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/tests/CMakeLists.txt67
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/tests/asan_test.cpp40
-rw-r--r--fluent-bit/cmake/sanitizers-cmake/tests/shortest.ext.test.cpp40
-rw-r--r--fluent-bit/cmake/version.rc.in43
-rw-r--r--fluent-bit/cmake/windows-setup.cmake137
28 files changed, 1383 insertions, 0 deletions
diff --git a/fluent-bit/cmake/FindJournald.cmake b/fluent-bit/cmake/FindJournald.cmake
new file mode 100644
index 000000000..9e6657a29
--- /dev/null
+++ b/fluent-bit/cmake/FindJournald.cmake
@@ -0,0 +1,49 @@
+# - Try to find Journald library.
+# Once done this will define
+#
+# JOURNALD_FOUND - system has Journald
+# JOURNALD_INCLUDE_DIR - the Journald include directory
+# JOURNALD_LIBRARIES - Link these to use Journald
+# JOURNALD_DEFINITIONS - Compiler switches required for using Journald
+# SYSTEMD_UNITDIR - The systemd units' directory
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+# Copyright (c) 2015 David Edmundson
+#
+
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig)
+pkg_check_modules(PC_JOURNALD QUIET systemd)
+pkg_get_variable(PC_SYSTEMD_UNITDIR systemd "systemdsystemunitdir")
+
+set(SYSTEMD_UNITDIR ${PC_SYSTEMD_UNITDIR})
+set(JOURNALD_FOUND ${PC_JOURNALD_FOUND})
+set(JOURNALD_DEFINITIONS ${PC_JOURNALD_CFLAGS_OTHER})
+
+find_path(JOURNALD_INCLUDE_DIR NAMES systemd/sd-journal.h
+ PATHS
+ ${PC_JOURNALD_INCLUDEDIR}
+ ${PC_JOURNALD_INCLUDE_DIRS}
+)
+
+find_library(JOURNALD_LIBRARY NAMES systemd
+ PATHS
+ ${PC_JOURNALD_LIBDIR}
+ ${PC_JOURNALD_LIBRARY_DIRS}
+)
+
+set(JOURNALD_LIBRARIES ${JOURNALD_LIBRARY})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Journald DEFAULT_MSG JOURNALD_LIBRARY JOURNALD_INCLUDE_DIR)
+
+include(FeatureSummary)
+set_package_properties(Journald PROPERTIES URL https://github.com/systemd
+ DESCRIPTION "Systemd logging daemon")
+
+# show the JOURNALD_INCLUDE_DIR and JOURNALD_LIBRARY variables only in the advanced view
+mark_as_advanced(JOURNALD_INCLUDE_DIR JOURNALD_LIBRARY)
diff --git a/fluent-bit/cmake/FindLibEdit.cmake b/fluent-bit/cmake/FindLibEdit.cmake
new file mode 100644
index 000000000..ea8bdfd80
--- /dev/null
+++ b/fluent-bit/cmake/FindLibEdit.cmake
@@ -0,0 +1,72 @@
+# FindLibEdit
+# -----------
+#
+# Find libedit library and headers
+#
+# The module defines the following variables:
+#
+# ::
+#
+# libedit_FOUND - true if libedit was found
+# libedit_INCLUDE_DIRS - include search path
+# libedit_LIBRARIES - libraries to link
+# libedit_VERSION - version number
+
+# This cmake file is based on LLVM Project one's.
+#
+# Copyright (c) 2018-2022 LLVM Project
+#
+
+if(libedit_INCLUDE_DIRS AND libedit_LIBRARIES)
+ set(libedit_FOUND TRUE)
+else()
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(PC_LIBEDIT QUIET libedit)
+
+ find_path(libedit_INCLUDE_DIRS
+ NAMES
+ histedit.h
+ HINTS
+ ${PC_LIBEDIT_INCLUDEDIR}
+ ${PC_LIBEDIT_INCLUDE_DIRS}
+ ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+ find_library(libedit_LIBRARIES
+ NAMES
+ edit libedit
+ HINTS
+ ${PC_LIBEDIT_LIBDIR}
+ ${PC_LIBEDIT_LIBRARY_DIRS}
+ ${CMAKE_INSTALL_FULL_LIBDIR})
+
+ if(libedit_INCLUDE_DIRS AND EXISTS "${libedit_INCLUDE_DIRS}/histedit.h")
+ file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
+ libedit_major_version_str
+ REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+")
+ string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1"
+ LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}")
+
+ file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
+ libedit_minor_version_str
+ REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+")
+ string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1"
+ LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}")
+
+ set(libedit_VERSION_STRING "${libedit_major_version}.${libedit_minor_version}")
+ endif()
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibEdit
+ REQUIRED_VARS
+ libedit_INCLUDE_DIRS
+ libedit_LIBRARIES
+ VERSION_VAR
+ libedit_VERSION_STRING)
+ mark_as_advanced(libedit_INCLUDE_DIRS libedit_LIBRARIES)
+endif()
+
+if (libedit_INCLUDE_DIRS AND libedit_LIBRARIES AND NOT TARGET LibEdit::LibEdit)
+ add_library(LibEdit::LibEdit UNKNOWN IMPORTED)
+ set_target_properties(LibEdit::LibEdit PROPERTIES
+ IMPORTED_LOCATION ${libedit_LIBRARIES}
+ INTERFACE_INCLUDE_DIRECTORIES ${libedit_INCLUDE_DIRS})
+endif()
diff --git a/fluent-bit/cmake/FindMonkey.cmake b/fluent-bit/cmake/FindMonkey.cmake
new file mode 100644
index 000000000..483f51aac
--- /dev/null
+++ b/fluent-bit/cmake/FindMonkey.cmake
@@ -0,0 +1,20 @@
+# Try to find Monkey HTTP Server core/library
+# ===========================================
+#
+# http://monkey-project.com
+#
+# Definitions:
+#
+# - MONKEY_FOUND : source code found
+# - MONKEY_INCLUDE_DIR: root include directory
+
+unset(MONKEY_INCLUDE_DIR CACHE)
+find_path(MONKEY_INCLUDE_DIR
+ NAMES monkey/mk_core.h monkey/mk_lib.h
+ PATHS ${PROJECT_SOURCE_DIR}/lib/monkey/include
+ CMAKE_FIND_ROOT_PATH_BOTH
+ )
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Monkey DEFAULT_MSG MONKEY_INCLUDE_DIR)
+include(FeatureSummary)
diff --git a/fluent-bit/cmake/armadillo-iot.cmake b/fluent-bit/cmake/armadillo-iot.cmake
new file mode 100644
index 000000000..26d9c91fb
--- /dev/null
+++ b/fluent-bit/cmake/armadillo-iot.cmake
@@ -0,0 +1,13 @@
+SET(HOST arm-linux)
+
+SET(CROSS_PREFIX ${HOST}-)
+SET(CROSS_TOOLCHAIN_PATH /home/travis/build/fluent/fluent-bit/ksz9692/${HOST})
+
+SET(CMAKE_SYSTEM_NAME Linux)
+SET(CMAKE_C_COMPILER ${CROSS_PREFIX}gcc)
+SET(CMAKE_CXX_COMPILER ${CROSS_PREFIX}g++)
+
+SET(CMAKE_FIND_ROOT_PATH ${CROSS_TOOLCHAIN_PATH})
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/fluent-bit/cmake/headers.cmake b/fluent-bit/cmake/headers.cmake
new file mode 100644
index 000000000..3e814066c
--- /dev/null
+++ b/fluent-bit/cmake/headers.cmake
@@ -0,0 +1,65 @@
+if(NOT FLB_PATH_ROOT_SOURCE)
+ set(FLB_PATH_ROOT_SOURCE ${FLB_ROOT})
+endif()
+
+include_directories(
+ ${FLB_PATH_ROOT_SOURCE}/include/
+ ${FLB_PATH_ROOT_SOURCE}/lib/
+
+ # fluent-otel-proto
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_FLUENT_OTEL}/include/
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_FLUENT_OTEL}/proto_c/
+
+ # CFL
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CFL}/include
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CFL}/lib/xxhash
+
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CO}
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RBTREE}
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MSGPACK}/include
+
+ # Chunk I/O generate headers also in the binary path
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CHUNKIO}/include
+ ${CMAKE_CURRENT_BINARY_DIR}/lib/chunkio/include
+
+ # LuaJIT
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}/src
+ ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake
+
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include/monkey
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MBEDTLS}/include
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_SQLITE}
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MPACK}/src
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MINIZ}/
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_ONIGMO}
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_SNAPPY}
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CMETRICS}/include
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CTRACES}/include
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CARES}/include
+ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RING_BUFFER}/lwrb/src/include
+
+ ${CMAKE_CURRENT_BINARY_DIR}/${FLB_PATH_LIB_CARES}
+ ${CMAKE_CURRENT_BINARY_DIR}/${FLB_PATH_LIB_JANSSON}/include
+ ${CMAKE_CURRENT_BINARY_DIR}/lib/cmetrics
+ ${CMAKE_CURRENT_BINARY_DIR}/include
+
+ ${CMAKE_CURRENT_BINARY_DIR}/lib/monkey/include/
+ ${CMAKE_CURRENT_BINARY_DIR}/lib/monkey/include/monkey/
+ )
+
+if(FLB_IN_KAFKA OR FLB_OUT_KAFKA)
+ include_directories(${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RDKAFKA}/src/)
+endif()
+
+if(FLB_UTF8_ENCODER)
+ include_directories(${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_TUTF8E}/include)
+endif()
+
+# On Windows, the core uses libevent
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ include_directories(
+ lib/monkey/mk_core/deps/libevent/include
+ ${PROJECT_BINARY_DIR}/lib/monkey/mk_core/deps/libevent/include
+ )
+endif()
diff --git a/fluent-bit/cmake/homebrew.cmake b/fluent-bit/cmake/homebrew.cmake
new file mode 100644
index 000000000..e2b32e1a9
--- /dev/null
+++ b/fluent-bit/cmake/homebrew.cmake
@@ -0,0 +1,38 @@
+# Search homebrewed keg-only versions of Bison and Flex on macOS.
+execute_process(
+ COMMAND brew --prefix bison
+ RESULT_VARIABLE HOMEBREW_BISON
+ OUTPUT_VARIABLE HOMEBREW_BISON_PREFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+if (HOMEBREW_BISON EQUAL 0 AND EXISTS "${HOMEBREW_BISON_PREFIX}")
+ message(STATUS "Using bison keg installed by Homebrew at ${HOMEBREW_BISON_PREFIX}")
+ set(BISON_EXECUTABLE "${HOMEBREW_BISON_PREFIX}/bin/bison")
+endif()
+
+execute_process(
+ COMMAND brew --prefix flex
+ RESULT_VARIABLE HOMEBREW_FLEX
+ OUTPUT_VARIABLE HOMEBREW_FLEX_PREFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+if (HOMEBREW_FLEX EQUAL 0 AND EXISTS "${HOMEBREW_FLEX_PREFIX}")
+ message(STATUS "Using flex keg installed by Homebrew at ${HOMEBREW_FLEX_PREFIX}")
+ set(FLEX_EXECUTABLE "${HOMEBREW_FLEX_PREFIX}/bin/flex")
+endif()
+
+if (OPENSSL_ROOT_DIR)
+ message(STATUS "Using openssl specified by cmake option: ${OPENSSL_ROOT_DIR}")
+else()
+ # Also, searching homebrewed OpenSSL automatically.
+ execute_process(
+ COMMAND brew --prefix openssl
+ RESULT_VARIABLE HOMEBREW_OPENSSL
+ OUTPUT_VARIABLE HOMEBREW_OPENSSL_PREFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if (HOMEBREW_OPENSSL EQUAL 0 AND EXISTS "${HOMEBREW_OPENSSL_PREFIX}")
+ message(STATUS "Using openssl keg installed by Homebrew at ${HOMEBREW_OPENSSL_PREFIX}")
+ set(OPENSSL_ROOT_DIR "${HOMEBREW_OPENSSL_PREFIX}")
+ endif()
+endif()
diff --git a/fluent-bit/cmake/libraries.cmake b/fluent-bit/cmake/libraries.cmake
new file mode 100644
index 000000000..832d2da6e
--- /dev/null
+++ b/fluent-bit/cmake/libraries.cmake
@@ -0,0 +1,26 @@
+# List of bundled libraries
+set(FLB_PATH_LIB_CFL "lib/cfl")
+set(FLB_PATH_LIB_FLUENT_OTEL "lib/fluent-otel-proto")
+set(FLB_PATH_LIB_CMETRICS "lib/cmetrics")
+set(FLB_PATH_LIB_CTRACES "lib/ctraces")
+
+set(FLB_PATH_LIB_CO "lib/flb_libco")
+set(FLB_PATH_LIB_RBTREE "lib/rbtree")
+set(FLB_PATH_LIB_MSGPACK "lib/msgpack-c")
+set(FLB_PATH_LIB_AVRO "lib/avro")
+set(FLB_PATH_LIB_CHUNKIO "lib/chunkio")
+set(FLB_PATH_LIB_LUAJIT "lib/luajit-3065c9")
+set(FLB_PATH_LIB_MONKEY "lib/monkey")
+set(FLB_PATH_LIB_JSMN "lib/jsmn")
+set(FLB_PATH_LIB_MBEDTLS "lib/mbedtls-2.28.0")
+set(FLB_PATH_LIB_SQLITE "lib/sqlite-amalgamation-3390300")
+set(FLB_PATH_LIB_JANSSON "lib/jansson-e23f558")
+set(FLB_PATH_LIB_ONIGMO "lib/onigmo")
+set(FLB_PATH_LIB_MPACK "lib/mpack-amalgamation-1.1")
+set(FLB_PATH_LIB_MINIZ "lib/miniz")
+set(FLB_PATH_LIB_TUTF8E "lib/tutf8e")
+set(FLB_PATH_LIB_CARES "lib/c-ares-1.19.1")
+set(FLB_PATH_LIB_SNAPPY "lib/snappy-fef67ac")
+set(FLB_PATH_LIB_RDKAFKA "lib/librdkafka-2.1.0")
+set(FLB_PATH_LIB_RING_BUFFER "lib/lwrb")
+set(FLB_PATH_LIB_WASM_MICRO_RUNTIME "lib/wasm-micro-runtime-WAMR-1.2.2")
diff --git a/fluent-bit/cmake/luajit.cmake b/fluent-bit/cmake/luajit.cmake
new file mode 100644
index 000000000..b6774eb44
--- /dev/null
+++ b/fluent-bit/cmake/luajit.cmake
@@ -0,0 +1,4 @@
+# luajit cmake
+option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" ON)
+set(LUAJIT_DIR ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT})
+add_subdirectory("lib/luajit-cmake")
diff --git a/fluent-bit/cmake/macos-setup.cmake b/fluent-bit/cmake/macos-setup.cmake
new file mode 100644
index 000000000..58681f572
--- /dev/null
+++ b/fluent-bit/cmake/macos-setup.cmake
@@ -0,0 +1,31 @@
+execute_process(
+ COMMAND brew --prefix
+ RESULT_VARIABLE HOMEBREW
+ OUTPUT_VARIABLE HOMEBREW_PREFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef-prefix=TARGET_OS_ ")
+
+if (HOMEBREW EQUAL 0 AND EXISTS "${HOMEBREW_PREFIX}")
+ message(STATUS "Found Homebrew at ${HOMEBREW_PREFIX}")
+ include(cmake/homebrew.cmake)
+endif()
+
+# Create rootcert on macOS
+set(MACOS_ROOT_CERT ${CMAKE_CURRENT_BINARY_DIR}/certs/rootcert.pem)
+execute_process(
+ COMMAND security find-certificate -a -p /Library/Keychains/System.keychain
+ RESULT_VARIABLE SECURITY_SYSTEM_RESULT
+ OUTPUT_VARIABLE SECURITY_SYSTEM_CERTS
+ ) # Don't strip trailing a white space and newline in the end of exported certificate.
+file(WRITE ${MACOS_ROOT_CERT} ${SECURITY_SYSTEM_CERTS})
+
+execute_process(
+ COMMAND security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain
+ RESULT_VARIABLE SECURITY_ROOT_RESULT
+ OUTPUT_VARIABLE SECURITY_ROOT_CERTS
+ ) # Don't strip trailing a white space and newline in the end of exported certificate.
+file(APPEND ${MACOS_ROOT_CERT} ${SECURITY_ROOT_CERTS})
+
+install(FILES ${MACOS_ROOT_CERT} COMPONENT binary DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/certs)
diff --git a/fluent-bit/cmake/macros.cmake b/fluent-bit/cmake/macros.cmake
new file mode 100644
index 000000000..4b5029756
--- /dev/null
+++ b/fluent-bit/cmake/macros.cmake
@@ -0,0 +1,15 @@
+# Macro to set definitions
+macro(FLB_DEFINITION var)
+ add_definitions(-D${var})
+ set(FLB_BUILD_FLAGS "${FLB_BUILD_FLAGS}#ifndef ${var}\n#define ${var}\n#endif\n")
+ set(FLB_INFO_FLAGS "${FLB_INFO_FLAGS} ${var}")
+endmacro()
+
+macro(FLB_DEFINITION_VAL var val)
+ add_definitions(-D${var}=${val})
+ set(FLB_BUILD_FLAGS "${FLB_BUILD_FLAGS}#ifndef ${var}\n#define ${var} \"${val}\"\n#endif\n")
+endmacro()
+
+macro(FLB_OPTION option value)
+ set(${option} ${value} CACHE INTERNAL "" FORCE)
+endmacro()
diff --git a/fluent-bit/cmake/platform_feature_checks.cmake b/fluent-bit/cmake/platform_feature_checks.cmake
new file mode 100644
index 000000000..c209631cc
--- /dev/null
+++ b/fluent-bit/cmake/platform_feature_checks.cmake
@@ -0,0 +1,8 @@
+# Feature tests for various platform and compiler capabilities,
+# system headers, etc.
+
+include(CheckIncludeFile)
+CHECK_INCLUDE_FILE("sys/wait.h" FLB_HAVE_SYS_WAIT_H)
+if (FLB_HAVE_SYS_WAIT_H)
+ FLB_DEFINITION(FLB_HAVE_SYS_WAIT_H)
+endif()
diff --git a/fluent-bit/cmake/sanitizers-cmake/.gitignore b/fluent-bit/cmake/sanitizers-cmake/.gitignore
new file mode 100644
index 000000000..c4a70a619
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/.gitignore
@@ -0,0 +1,3 @@
+# out-of-source build top-level folders.
+build/
+_build/
diff --git a/fluent-bit/cmake/sanitizers-cmake/CMakeLists.txt b/fluent-bit/cmake/sanitizers-cmake/CMakeLists.txt
new file mode 100644
index 000000000..a19285255
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/CMakeLists.txt
@@ -0,0 +1,51 @@
+# This file is part of CMake-sanitizers.
+#
+# 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.
+#
+#
+# Copyright (c)
+# 2013-2015 Matt Arsenault
+# 2015 RWTH Aachen University, Federal Republic of Germany
+#
+
+
+#
+# project information
+#
+
+# minimum required cmake version
+cmake_minimum_required(VERSION 2.8.12)
+
+# project name
+project("CMake-sanitizers")
+
+
+
+#
+# cmake configuration
+#
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
+
+
+
+#
+# add tests
+#
+enable_testing()
+add_subdirectory(tests)
diff --git a/fluent-bit/cmake/sanitizers-cmake/LICENSE b/fluent-bit/cmake/sanitizers-cmake/LICENSE
new file mode 100644
index 000000000..2520efdc0
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c)
+ 2013 Matthew Arsenault
+ 2015-2016 RWTH Aachen University, Federal Republic of Germany
+
+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.
diff --git a/fluent-bit/cmake/sanitizers-cmake/README.md b/fluent-bit/cmake/sanitizers-cmake/README.md
new file mode 100644
index 000000000..b4ca621c3
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/README.md
@@ -0,0 +1,73 @@
+# sanitizers-cmake
+
+ [![](https://img.shields.io/github/issues-raw/arsenm/sanitizers-cmake.svg?style=flat-square)](https://github.com/arsenm/sanitizers-cmake/issues)
+[![MIT](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
+
+CMake module to enable sanitizers for binary targets.
+
+
+## Include into your project
+
+To use [FindSanitizers.cmake](cmake/FindSanitizers.cmake), simply add this repository as git submodule into your own repository
+```Shell
+mkdir externals
+git submodule add git@github.com:arsenm/sanitizers-cmake.git externals/sanitizers-cmake
+```
+and adding ```externals/sanitizers-cmake/cmake``` to your ```CMAKE_MODULE_PATH```
+```CMake
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
+```
+
+If you don't use git or dislike submodules you can copy the files in [cmake directory](cmake) into your repository. *Be careful and keep updates in mind!*
+
+Now you can simply run ```find_package``` in your CMake files:
+```CMake
+find_package(Sanitizers)
+```
+
+
+## Usage
+
+You can enable the sanitizers with ``SANITIZE_ADDRESS``, ``SANITIZE_MEMORY``, ``SANITIZE_THREAD`` or ``SANITIZE_UNDEFINED`` options in your CMake configuration. You can do this by passing e.g. ``-DSANITIZE_ADDRESS=On`` on your command line or with your graphical interface.
+
+If sanitizers are supported by your compiler, the specified targets will be build with sanitizer support. If your compiler has no sanitizing capabilities (I asume intel compiler doesn't) you'll get a warning but CMake will continue processing and sanitizing will simply just be ignored.
+
+#### Compiler issues
+
+Different compilers may be using different implementations for sanitizers. If you'll try to sanitize targets with C and Fortran code but don't use gcc & gfortran but clang & gfortran, this will cause linking problems. To avoid this, such problems will be detected and sanitizing will be disabled for these targets.
+
+Even C only targets may cause problems in certain situations. Some problems have been seen with AddressSanitizer for preloading or dynamic linking. In such cases you may try the ``SANITIZE_LINK_STATIC`` to link sanitizers for gcc static.
+
+
+
+## Build targets with sanitizer support
+
+To enable sanitizer support you simply have to add ``add_sanitizers(<TARGET>)`` after defining your target. To provide a sanitizer blacklist file you can use the ``sanitizer_add_blacklist_file(<FILE>)`` function:
+```CMake
+find_package(Sanitizers)
+
+sanitizer_add_blacklist_file("blacklist.txt")
+
+add_executable(some_exe foo.c bar.c)
+add_sanitizers(some_exe)
+
+add_library(some_lib foo.c bar.c)
+add_sanitizers(some_lib)
+```
+
+## Run your application
+
+The sanitizers check your program, while it's running. In some situations (e.g. LD_PRELOAD your target) it might be required to preload the used AddressSanitizer library first. In this case you may use the ``asan-wrapper`` script defined in ``ASan_WRAPPER`` variable to execute your application with ``${ASan_WRAPPER} myexe arg1 ...``.
+
+
+## Contribute
+
+Anyone is welcome to contribute. Simply fork this repository, make your changes **in an own branch** and create a pull-request for your change. Please do only one change per pull-request.
+
+You found a bug? Please fill out an [issue](https://github.com/arsenm/sanitizers-cmake/issues) and include any data to reproduce the bug.
+
+
+#### Contributors
+
+* [Matt Arsenault](https://github.com/arsenm)
+* [Alexander Haase](https://github.com/alehaa)
diff --git a/fluent-bit/cmake/sanitizers-cmake/VERSION b/fluent-bit/cmake/sanitizers-cmake/VERSION
new file mode 100644
index 000000000..9ddbe16c9
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/VERSION
@@ -0,0 +1,3 @@
+git c3dc841af4dbf44669e65b82cb68a575864326bd - Apr 27, 2023
+
+
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/FindASan.cmake b/fluent-bit/cmake/sanitizers-cmake/cmake/FindASan.cmake
new file mode 100644
index 000000000..4548e46a8
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/FindASan.cmake
@@ -0,0 +1,62 @@
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+option(SANITIZE_ADDRESS "Enable AddressSanitizer for sanitized targets." Off)
+
+set(FLAG_CANDIDATES
+ # MSVC uses
+ "/fsanitize=address"
+
+ # Clang 3.2+ use this version. The no-omit-frame-pointer option is optional.
+ "-g -fsanitize=address -fno-omit-frame-pointer"
+ "-g -fsanitize=address"
+
+ # Older deprecated flag for ASan
+ "-g -faddress-sanitizer"
+)
+
+
+if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY))
+ message(FATAL_ERROR "AddressSanitizer is not compatible with "
+ "ThreadSanitizer or MemorySanitizer.")
+endif ()
+
+
+include(sanitize-helpers)
+
+if (SANITIZE_ADDRESS)
+ sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer"
+ "ASan")
+
+ find_program(ASan_WRAPPER "asan-wrapper" PATHS ${CMAKE_MODULE_PATH})
+ mark_as_advanced(ASan_WRAPPER)
+endif ()
+
+function (add_sanitize_address TARGET)
+ if (NOT SANITIZE_ADDRESS)
+ return()
+ endif ()
+
+ sanitizer_add_flags(${TARGET} "AddressSanitizer" "ASan")
+endfunction ()
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/FindMSan.cmake b/fluent-bit/cmake/sanitizers-cmake/cmake/FindMSan.cmake
new file mode 100644
index 000000000..d744c34be
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/FindMSan.cmake
@@ -0,0 +1,60 @@
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+option(SANITIZE_MEMORY "Enable MemorySanitizer for sanitized targets." Off)
+
+set(FLAG_CANDIDATES
+ # MSVC uses
+ "/fsanitize=memory"
+ # GNU/Clang
+ "-g -fsanitize=memory"
+)
+
+
+include(sanitize-helpers)
+
+if (SANITIZE_MEMORY)
+ if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
+ "MemorySanitizer is supported for Linux systems only.")
+ set(SANITIZE_MEMORY Off CACHE BOOL
+ "Enable MemorySanitizer for sanitized targets." FORCE)
+ elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
+ message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
+ "MemorySanitizer is supported for 64bit systems only.")
+ set(SANITIZE_MEMORY Off CACHE BOOL
+ "Enable MemorySanitizer for sanitized targets." FORCE)
+ else ()
+ sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer"
+ "MSan")
+ endif ()
+endif ()
+
+function (add_sanitize_memory TARGET)
+ if (NOT SANITIZE_MEMORY)
+ return()
+ endif ()
+
+ sanitizer_add_flags(${TARGET} "MemorySanitizer" "MSan")
+endfunction ()
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/FindSanitizers.cmake b/fluent-bit/cmake/sanitizers-cmake/cmake/FindSanitizers.cmake
new file mode 100755
index 000000000..d9b438c0f
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/FindSanitizers.cmake
@@ -0,0 +1,91 @@
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+# If any of the used compiler is a GNU compiler, add a second option to static
+# link against the sanitizers.
+option(SANITIZE_LINK_STATIC "Try to link static against sanitizers." Off)
+
+# Highlight this module has been loaded.
+set(Sanitizers_FOUND TRUE)
+
+set(FIND_QUIETLY_FLAG "")
+if (DEFINED Sanitizers_FIND_QUIETLY)
+ set(FIND_QUIETLY_FLAG "QUIET")
+endif ()
+
+find_package(ASan ${FIND_QUIETLY_FLAG})
+find_package(TSan ${FIND_QUIETLY_FLAG})
+find_package(MSan ${FIND_QUIETLY_FLAG})
+find_package(UBSan ${FIND_QUIETLY_FLAG})
+
+function(sanitizer_add_blacklist_file FILE)
+ if(NOT IS_ABSOLUTE ${FILE})
+ set(FILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}")
+ endif()
+ get_filename_component(FILE "${FILE}" REALPATH)
+
+ sanitizer_check_compiler_flags("-fsanitize-blacklist=${FILE}"
+ "SanitizerBlacklist" "SanBlist")
+endfunction()
+
+function(add_sanitizers)
+ # If no sanitizer is enabled, return immediately.
+ if (NOT (SANITIZE_ADDRESS OR SANITIZE_MEMORY OR SANITIZE_THREAD OR
+ SANITIZE_UNDEFINED))
+ return()
+ endif ()
+
+ foreach (TARGET ${ARGV})
+ # Check if this target will be compiled by exactly one compiler. Other-
+ # wise sanitizers can't be used and a warning should be printed once.
+ get_target_property(TARGET_TYPE ${TARGET} TYPE)
+ if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+ message(WARNING "Can't use any sanitizers for target ${TARGET}, "
+ "because it is an interface library and cannot be "
+ "compiled directly.")
+ return()
+ endif ()
+ sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
+ list(LENGTH TARGET_COMPILER NUM_COMPILERS)
+ if (NUM_COMPILERS GREATER 1)
+ message(WARNING "Can't use any sanitizers for target ${TARGET}, "
+ "because it will be compiled by incompatible compilers. "
+ "Target will be compiled without sanitizers.")
+ return()
+
+ elseif (NUM_COMPILERS EQUAL 0)
+ # If the target is compiled by no known compiler, give a warning.
+ message(WARNING "Sanitizers for target ${TARGET} may not be"
+ " usable, because it uses no or an unknown compiler. "
+ "This is a false warning for targets using only "
+ "object lib(s) as input.")
+ endif ()
+
+ # Add sanitizers for target.
+ add_sanitize_address(${TARGET})
+ add_sanitize_thread(${TARGET})
+ add_sanitize_memory(${TARGET})
+ add_sanitize_undefined(${TARGET})
+ endforeach ()
+endfunction(add_sanitizers)
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/FindTSan.cmake b/fluent-bit/cmake/sanitizers-cmake/cmake/FindTSan.cmake
new file mode 100644
index 000000000..efb2e9525
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/FindTSan.cmake
@@ -0,0 +1,68 @@
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+option(SANITIZE_THREAD "Enable ThreadSanitizer for sanitized targets." Off)
+
+set(FLAG_CANDIDATES
+ # MSVC uses
+ "/fsanitize=thread"
+ # GNU/Clang
+ "-g -fsanitize=thread"
+)
+
+
+# ThreadSanitizer is not compatible with MemorySanitizer.
+if (SANITIZE_THREAD AND SANITIZE_MEMORY)
+ message(FATAL_ERROR "ThreadSanitizer is not compatible with "
+ "MemorySanitizer.")
+endif ()
+
+
+include(sanitize-helpers)
+
+if (SANITIZE_THREAD)
+ if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND
+ NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+ message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
+ "ThreadSanitizer is supported for Linux systems and macOS only.")
+ set(SANITIZE_THREAD Off CACHE BOOL
+ "Enable ThreadSanitizer for sanitized targets." FORCE)
+ elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
+ message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
+ "ThreadSanitizer is supported for 64bit systems only.")
+ set(SANITIZE_THREAD Off CACHE BOOL
+ "Enable ThreadSanitizer for sanitized targets." FORCE)
+ else ()
+ sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer"
+ "TSan")
+ endif ()
+endif ()
+
+function (add_sanitize_thread TARGET)
+ if (NOT SANITIZE_THREAD)
+ return()
+ endif ()
+
+ sanitizer_add_flags(${TARGET} "ThreadSanitizer" "TSan")
+endfunction ()
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/FindUBSan.cmake b/fluent-bit/cmake/sanitizers-cmake/cmake/FindUBSan.cmake
new file mode 100644
index 000000000..4354c2e4d
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/FindUBSan.cmake
@@ -0,0 +1,49 @@
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+option(SANITIZE_UNDEFINED
+ "Enable UndefinedBehaviorSanitizer for sanitized targets." Off)
+
+set(FLAG_CANDIDATES
+ # MSVC uses
+ "/fsanitize=undefined"
+ # GNU/Clang
+ "-g -fsanitize=undefined"
+)
+
+
+include(sanitize-helpers)
+
+if (SANITIZE_UNDEFINED)
+ sanitizer_check_compiler_flags("${FLAG_CANDIDATES}"
+ "UndefinedBehaviorSanitizer" "UBSan")
+endif ()
+
+function (add_sanitize_undefined TARGET)
+ if (NOT SANITIZE_UNDEFINED)
+ return()
+ endif ()
+
+ sanitizer_add_flags(${TARGET} "UndefinedBehaviorSanitizer" "UBSan")
+endfunction ()
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/asan-wrapper b/fluent-bit/cmake/sanitizers-cmake/cmake/asan-wrapper
new file mode 100755
index 000000000..5d5410337
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/asan-wrapper
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+# This script is a wrapper for AddressSanitizer. In some special cases you need
+# to preload AddressSanitizer to avoid error messages - e.g. if you're
+# preloading another library to your application. At the moment this script will
+# only do something, if we're running on a Linux platform. OSX might not be
+# affected.
+
+
+# Exit immediately, if platform is not Linux.
+if [ "$(uname)" != "Linux" ]
+then
+ exec $@
+fi
+
+
+# Get the used libasan of the application ($1). If a libasan was found, it will
+# be prepended to LD_PRELOAD.
+libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1)
+if [ -n "$libasan" ]
+then
+ if [ -n "$LD_PRELOAD" ]
+ then
+ export LD_PRELOAD="$libasan:$LD_PRELOAD"
+ else
+ export LD_PRELOAD="$libasan"
+ fi
+fi
+
+# Execute the application.
+exec $@
diff --git a/fluent-bit/cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake b/fluent-bit/cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake
new file mode 100755
index 000000000..efc325ce3
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake
@@ -0,0 +1,178 @@
+# The MIT License (MIT)
+#
+# Copyright (c)
+# 2013 Matthew Arsenault
+# 2015-2016 RWTH Aachen University, Federal Republic of Germany
+#
+# 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.
+
+# Helper function to get the language of a source file.
+function (sanitizer_lang_of_source FILE RETURN_VAR)
+ get_filename_component(LONGEST_EXT "${FILE}" EXT)
+ # If extension is empty return. This can happen for extensionless headers
+ if("${LONGEST_EXT}" STREQUAL "")
+ set(${RETURN_VAR} "" PARENT_SCOPE)
+ return()
+ endif()
+ # Get shortest extension as some files can have dot in their names
+ string(REGEX REPLACE "^.*(\\.[^.]+)$" "\\1" FILE_EXT ${LONGEST_EXT})
+ string(TOLOWER "${FILE_EXT}" FILE_EXT)
+ string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT)
+
+ get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
+ foreach (LANG ${ENABLED_LANGUAGES})
+ list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP)
+ if (NOT ${TEMP} EQUAL -1)
+ set(${RETURN_VAR} "${LANG}" PARENT_SCOPE)
+ return()
+ endif ()
+ endforeach()
+
+ set(${RETURN_VAR} "" PARENT_SCOPE)
+endfunction ()
+
+
+# Helper function to get compilers used by a target.
+function (sanitizer_target_compilers TARGET RETURN_VAR)
+ # Check if all sources for target use the same compiler. If a target uses
+ # e.g. C and Fortran mixed and uses different compilers (e.g. clang and
+ # gfortran) this can trigger huge problems, because different compilers may
+ # use different implementations for sanitizers.
+ set(BUFFER "")
+ get_target_property(TSOURCES ${TARGET} SOURCES)
+ foreach (FILE ${TSOURCES})
+ # If expression was found, FILE is a generator-expression for an object
+ # library. Object libraries will be ignored.
+ string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE})
+ if ("${_file}" STREQUAL "")
+ sanitizer_lang_of_source(${FILE} LANG)
+ if (LANG)
+ list(APPEND BUFFER ${CMAKE_${LANG}_COMPILER_ID})
+ endif ()
+ endif ()
+ endforeach ()
+
+ list(REMOVE_DUPLICATES BUFFER)
+ set(${RETURN_VAR} "${BUFFER}" PARENT_SCOPE)
+endfunction ()
+
+
+# Helper function to check compiler flags for language compiler.
+function (sanitizer_check_compiler_flag FLAG LANG VARIABLE)
+
+ if (${LANG} STREQUAL "C")
+ include(CheckCCompilerFlag)
+ check_c_compiler_flag("${FLAG}" ${VARIABLE})
+
+ elseif (${LANG} STREQUAL "CXX")
+ include(CheckCXXCompilerFlag)
+ check_cxx_compiler_flag("${FLAG}" ${VARIABLE})
+
+ elseif (${LANG} STREQUAL "Fortran")
+ # CheckFortranCompilerFlag was introduced in CMake 3.x. To be compatible
+ # with older Cmake versions, we will check if this module is present
+ # before we use it. Otherwise we will define Fortran coverage support as
+ # not available.
+ include(CheckFortranCompilerFlag OPTIONAL RESULT_VARIABLE INCLUDED)
+ if (INCLUDED)
+ check_fortran_compiler_flag("${FLAG}" ${VARIABLE})
+ elseif (NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VARIABLE}")
+ message(STATUS "Performing Test ${VARIABLE}"
+ " - Failed (Check not supported)")
+ endif ()
+ endif()
+
+endfunction ()
+
+
+# Helper function to test compiler flags.
+function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
+ set(CMAKE_REQUIRED_QUIET ${${PREFIX}_FIND_QUIETLY})
+
+ get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
+ foreach (LANG ${ENABLED_LANGUAGES})
+ # Sanitizer flags are not dependend on language, but the used compiler.
+ # So instead of searching flags foreach language, search flags foreach
+ # compiler used.
+ set(COMPILER ${CMAKE_${LANG}_COMPILER_ID})
+ if (COMPILER AND NOT DEFINED ${PREFIX}_${COMPILER}_FLAGS)
+ foreach (FLAG ${FLAG_CANDIDATES})
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Try ${COMPILER} ${NAME} flag = [${FLAG}]")
+ endif()
+
+ set(CMAKE_REQUIRED_FLAGS "${FLAG}")
+ unset(${PREFIX}_FLAG_DETECTED CACHE)
+ sanitizer_check_compiler_flag("${FLAG}" ${LANG}
+ ${PREFIX}_FLAG_DETECTED)
+
+ if (${PREFIX}_FLAG_DETECTED)
+ # If compiler is a GNU compiler, search for static flag, if
+ # SANITIZE_LINK_STATIC is enabled.
+ if (SANITIZE_LINK_STATIC AND (${COMPILER} STREQUAL "GNU"))
+ string(TOLOWER ${PREFIX} PREFIX_lower)
+ sanitizer_check_compiler_flag(
+ "-static-lib${PREFIX_lower}" ${LANG}
+ ${PREFIX}_STATIC_FLAG_DETECTED)
+
+ if (${PREFIX}_STATIC_FLAG_DETECTED)
+ set(FLAG "-static-lib${PREFIX_lower} ${FLAG}")
+ endif ()
+ endif ()
+
+ set(${PREFIX}_${COMPILER}_FLAGS "${FLAG}" CACHE STRING
+ "${NAME} flags for ${COMPILER} compiler.")
+ mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
+ break()
+ endif ()
+ endforeach ()
+
+ if (NOT ${PREFIX}_FLAG_DETECTED)
+ set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
+ "${NAME} flags for ${COMPILER} compiler.")
+ mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
+
+ message(WARNING "${NAME} is not available for ${COMPILER} "
+ "compiler. Targets using this compiler will be "
+ "compiled without ${NAME}.")
+ endif ()
+ endif ()
+ endforeach ()
+endfunction ()
+
+
+# Helper to assign sanitizer flags for TARGET.
+function (sanitizer_add_flags TARGET NAME PREFIX)
+ # Get list of compilers used by target and check, if sanitizer is available
+ # for this target. Other compiler checks like check for conflicting
+ # compilers will be done in add_sanitizers function.
+ sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
+ list(LENGTH TARGET_COMPILER NUM_COMPILERS)
+ if ("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL "")
+ return()
+ endif()
+
+ separate_arguments(flags_list UNIX_COMMAND "${${PREFIX}_${TARGET_COMPILER}_FLAGS} ${SanBlist_${TARGET_COMPILER}_FLAGS}")
+ target_compile_options(${TARGET} PUBLIC ${flags_list})
+
+ separate_arguments(flags_list UNIX_COMMAND "${${PREFIX}_${TARGET_COMPILER}_FLAGS}")
+ target_link_options(${TARGET} PUBLIC ${flags_list})
+
+endfunction ()
diff --git a/fluent-bit/cmake/sanitizers-cmake/tests/CMakeLists.txt b/fluent-bit/cmake/sanitizers-cmake/tests/CMakeLists.txt
new file mode 100644
index 000000000..8553e6326
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/tests/CMakeLists.txt
@@ -0,0 +1,67 @@
+# This file is part of CMake-sanitizers.
+#
+# 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.
+#
+#
+# Copyright (c)
+# 2013-2015 Matt Arsenault
+# 2015 RWTH Aachen University, Federal Republic of Germany
+#
+
+# Function to add testcases.
+function(add_testcase TESTNAME SOURCEFILES)
+ # remove ${TESTNAME} from ${ARGV} to use ${ARGV} as ${SOURCEFILES}
+ list(REMOVE_AT ARGV 0)
+
+ # add a new executable
+ add_executable(${TESTNAME} ${ARGV})
+
+ # add a testcase for executable
+ add_test(${TESTNAME} ${TESTNAME})
+endfunction(add_testcase)
+
+# Function to add testcases with asan enabled.
+function(add_sanitized_testcase TESTNAME SOURCEFILES)
+ add_testcase(${TESTNAME} ${SOURCEFILES})
+ add_sanitizers(${TESTNAME})
+endfunction(add_sanitized_testcase)
+
+
+
+set(SANITIZE_ADDRESS TRUE)
+
+#
+# search for sanitizers
+#
+find_package(Sanitizers)
+
+
+#
+# add testcases
+#
+add_sanitized_testcase("asan_test_cpp" asan_test.cpp)
+add_sanitized_testcase("shortest_ext_test_cpp" shortest.ext.test.cpp)
+
+set_tests_properties(
+ "asan_test_cpp"
+ "shortest_ext_test_cpp"
+PROPERTIES
+ WILL_FAIL TRUE
+)
+
diff --git a/fluent-bit/cmake/sanitizers-cmake/tests/asan_test.cpp b/fluent-bit/cmake/sanitizers-cmake/tests/asan_test.cpp
new file mode 100644
index 000000000..6c0a370c3
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/tests/asan_test.cpp
@@ -0,0 +1,40 @@
+/* This file is part of CMake-sanitizers.
+ *
+ * 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.
+ *
+ *
+ * Copyright (c)
+ * 2013-2015 Matt Arsenault
+ * 2015 RWTH Aachen University, Federal Republic of Germany
+ */
+
+
+int
+main(int argc, char **argv)
+{
+ // Allocate a new array and delete it.
+ int *array = new int[argc + 1];
+ array[argc] = 0;
+ delete[] array;
+
+ /* Access element of the deleted array. This will cause an memory error with
+ * address sanitizer.
+ */
+ return array[argc];
+}
diff --git a/fluent-bit/cmake/sanitizers-cmake/tests/shortest.ext.test.cpp b/fluent-bit/cmake/sanitizers-cmake/tests/shortest.ext.test.cpp
new file mode 100644
index 000000000..6c0a370c3
--- /dev/null
+++ b/fluent-bit/cmake/sanitizers-cmake/tests/shortest.ext.test.cpp
@@ -0,0 +1,40 @@
+/* This file is part of CMake-sanitizers.
+ *
+ * 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.
+ *
+ *
+ * Copyright (c)
+ * 2013-2015 Matt Arsenault
+ * 2015 RWTH Aachen University, Federal Republic of Germany
+ */
+
+
+int
+main(int argc, char **argv)
+{
+ // Allocate a new array and delete it.
+ int *array = new int[argc + 1];
+ array[argc] = 0;
+ delete[] array;
+
+ /* Access element of the deleted array. This will cause an memory error with
+ * address sanitizer.
+ */
+ return array[argc];
+}
diff --git a/fluent-bit/cmake/version.rc.in b/fluent-bit/cmake/version.rc.in
new file mode 100644
index 000000000..12c9b95a2
--- /dev/null
+++ b/fluent-bit/cmake/version.rc.in
@@ -0,0 +1,43 @@
+#include <windows.h>
+
+#define FLB_VER_FILEVERSION @FLB_VERSION_MAJOR@,@FLB_VERSION_MINOR@,@FLB_VERSION_PATCH@,0
+#define FLB_VER_FILEVERSION_STR "@FLB_VERSION_MAJOR@.@FLB_VERSION_MINOR@.@FLB_VERSION_PATCH@.0\0"
+
+#define FLB_VER_PRODUCTVERSION @FLB_VERSION_MAJOR@,@FLB_VERSION_MINOR@,@FLB_VERSION_PATCH@,0
+#define FLB_VER_PRODUCTVERSION_STR "@FLB_VERSION_MAJOR@.@FLB_VERSION_MINOR@.@FLB_VERSION_PATCH@.0\0"
+
+#ifndef DEBUG
+#define VER_DEBUG 0
+#else
+#define VER_DEBUG VS_FF_DEBUG
+#endif
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION FLB_VER_FILEVERSION
+ PRODUCTVERSION FLB_VER_PRODUCTVERSION
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS VER_DEBUG
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+BEGIN
+ BLOCK "VarFileInfo"
+ BEGIN
+ // English language (0x409) and the Windows Unicode codepage (1200)
+ VALUE "Translation", 0x409, 1200
+ END
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "Compiled with @CMAKE_C_COMPILER_ID@ @CMAKE_C_COMPILER_VERSION@\0"
+ VALUE "ProductVersion", FLB_VER_PRODUCTVERSION_STR
+ VALUE "FileVersion", FLB_VER_FILEVERSION_STR
+ VALUE "InternalName", "fluent-bit\0"
+ VALUE "ProductName", "Fluent Bit - Fast and Lightweight Logs and Metrics processor for Linux, BSD, OSX and Windows\0"
+ VALUE "CompanyName", "Calyptia Inc.\0"
+ VALUE "LegalCopyright", "Copyright (C) 2015-2018 Treasure Data Inc.\nCopyright (C) 2019-2021 The Fluent Bit Authors.\nAll rights reserved.\0"
+ VALUE "Licence", "Apache-2.0\0"
+ VALUE "Info", "https://docs.fluentbit.io/manual/0"
+ END
+ END
+END \ No newline at end of file
diff --git a/fluent-bit/cmake/windows-setup.cmake b/fluent-bit/cmake/windows-setup.cmake
new file mode 100644
index 000000000..fa67cb0d8
--- /dev/null
+++ b/fluent-bit/cmake/windows-setup.cmake
@@ -0,0 +1,137 @@
+# Custom build settings for Windows (MSVC)
+#
+# Not all plugins are supported on Windows yet. This file tweaks
+# the build flags so that we can compile fluent-bit on it.
+
+if(FLB_WINDOWS_DEFAULTS)
+ message(STATUS "Overriding setttings with windows-setup.cmake")
+ set(FLB_REGEX Yes)
+ set(FLB_BACKTRACE No)
+ # LuaJIT does not currently support Windows ARM64 architecture so we disable it for now.
+ # See also: https://github.com/LuaJIT/LuaJIT/issues/593
+ if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM64|AARCH64)")
+ set(FLB_LUAJIT No)
+ else()
+ set(FLB_LUAJIT Yes)
+ endif()
+ set(FLB_EXAMPLES Yes)
+ set(FLB_PARSER Yes)
+ set(FLB_TLS Yes)
+ set(FLB_AWS Yes)
+ set(FLB_HTTP_SERVER Yes)
+ set(FLB_METRICS Yes)
+ if (NOT FLB_LIBYAML_DIR)
+ set(FLB_CONFIG_YAML No)
+ endif ()
+ set(FLB_WASM No)
+ set(FLB_WAMRC No)
+
+ # INPUT plugins
+ # =============
+ set(FLB_IN_CPU No)
+ set(FLB_IN_DISK No)
+ set(FLB_IN_EXEC No)
+ set(FLB_IN_EXEC_WASI No)
+ set(FLB_IN_FORWARD Yes)
+ set(FLB_IN_HEALTH No)
+ set(FLB_IN_HTTP Yes)
+ set(FLB_IN_MEM No)
+ set(FLB_IN_KAFKA No)
+ set(FLB_IN_KMSG No)
+ set(FLB_IN_LIB Yes)
+ set(FLB_IN_RANDOM Yes)
+ set(FLB_IN_SERIAL No)
+ set(FLB_IN_STDIN No)
+ set(FLB_IN_SYSLOG Yes)
+ set(FLB_IN_TAIL Yes)
+ set(FLB_IN_TCP Yes)
+ set(FLB_IN_MQTT No)
+ set(FLB_IN_HEAD No)
+ set(FLB_IN_PROC No)
+ set(FLB_IN_SYSTEMD No)
+ set(FLB_IN_DUMMY Yes)
+ set(FLB_IN_NETIF No)
+ set(FLB_IN_WINLOG Yes)
+ set(FLB_IN_WINSTAT Yes)
+ set(FLB_IN_WINEVTLOG Yes)
+ set(FLB_IN_COLLECTD No)
+ set(FLB_IN_STATSD Yes)
+ set(FLB_IN_STORAGE_BACKLOG Yes)
+ set(FLB_IN_EMITTER Yes)
+ set(FLB_IN_PODMAN_METRICS No)
+ set(FLB_IN_ELASTICSEARCH Yes)
+ set(FLB_IN_SPLUNK Yes)
+
+ # OUTPUT plugins
+ # ==============
+ set(FLB_OUT_AZURE Yes)
+ set(FLB_OUT_AZURE_BLOB Yes)
+ set(FLB_OUT_AZURE_KUSTO Yes)
+ set(FLB_OUT_BIGQUERY No)
+ set(FLB_OUT_COUNTER Yes)
+ set(FLB_OUT_CHRONICLE Yes)
+ set(FLB_OUT_DATADOG Yes)
+ set(FLB_OUT_ES Yes)
+ set(FLB_OUT_EXIT No)
+ set(FLB_OUT_FORWARD Yes)
+ set(FLB_OUT_GELF Yes)
+ set(FLB_OUT_HTTP Yes)
+ set(FLB_OUT_INFLUXDB Yes)
+ set(FLB_OUT_NATS No)
+ set(FLB_OUT_PLOT No)
+ set(FLB_OUT_FILE Yes)
+ set(FLB_OUT_TD No)
+ set(FLB_OUT_RETRY No)
+ set(FLB_OUT_SPLUNK Yes)
+ set(FLB_OUT_STACKDRIVER Yes)
+ set(FLB_OUT_STDOUT Yes)
+ set(FLB_OUT_LIB Yes)
+ set(FLB_OUT_NULL Yes)
+ set(FLB_OUT_FLOWCOUNTER Yes)
+ set(FLB_OUT_KAFKA No)
+ set(FLB_OUT_KAFKA_REST No)
+ set(FLB_OUT_CLOUDWATCH_LOGS Yes)
+ set(FLB_OUT_S3 Yes)
+ set(FLB_OUT_KINESIS_FIREHOSE Yes)
+ set(FLB_OUT_KINESIS_STREAMS Yes)
+
+ # FILTER plugins
+ # ==============
+ set(FLB_FILTER_GREP Yes)
+ set(FLB_FILTER_MODIFY Yes)
+ set(FLB_FILTER_STDOUT Yes)
+ set(FLB_FILTER_PARSER Yes)
+ set(FLB_FILTER_KUBERNETES Yes)
+ set(FLB_FILTER_THROTTLE Yes)
+ set(FLB_FILTER_THROTTLE_SIZE Yes)
+ set(FLB_FILTER_NEST Yes)
+ set(FLB_FILTER_LUA Yes)
+ set(FLB_FILTER_RECORD_MODIFIER Yes)
+ set(FLB_FILTER_REWRITE_TAG Yes)
+ set(FLB_FILTER_GEOIP2 Yes)
+ set(FLB_FILTER_AWS Yes)
+ set(FLB_FILTER_ECS Yes)
+ set(FLB_FILTER_WASM No)
+endif()
+
+# Search bison and flex executables
+find_package(FLEX)
+find_package(BISON)
+
+if (NOT (${FLEX_FOUND} AND ${BISON_FOUND}))
+ message(STATUS "flex and bison not found. Disable stream_processor building.")
+ set(FLB_STREAM_PROCESSOR No)
+ set(FLB_RECORD_ACCESSOR No)
+endif()
+
+if (MSVC)
+ enable_language(RC)
+ # use English language (0x409) in resource compiler
+ set(rc_flags "/l0x409")
+ set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_flags} <DEFINES> /fo <OBJECT> <SOURCE>")
+endif()
+
+configure_file(
+${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
+${CMAKE_CURRENT_BINARY_DIR}/src/version.rc
+@ONLY)