@@ -68,6 +68,7 @@ option(FLB_SYSTEM_STRPTIME "Use strptime in system libc" Yes)
6868option (FLB_STATIC_CONF "Build binary using static configuration" )
6969option (FLB_STREAM_PROCESSOR "Enable Stream Processor" Yes )
7070option (FLB_CORO_STACK_SIZE "Set coroutine stack size" )
71+ option (FLB_ICONV "Enable iconv string decoding" No )
7172
7273# Metrics: Experimental Feature, disabled by default on 0.12 series
7374# but enabled in the upcoming 0.13 release. Note that development
@@ -153,6 +154,7 @@ if(FLB_ALL)
153154 # Global
154155 set (FLB_DEBUG 1)
155156 set (FLB_TLS 1)
157+ set (FLB_ICONV 1)
156158
157159 # Input plugins
158160 set (FLB_IN_CPU 1)
@@ -182,6 +184,7 @@ if(FLB_ALL)
182184 set (FLB_OUT_STDOUT 1)
183185 set (FLB_OUT_LIB 1)
184186 set (FLB_OUT_FLOWCOUNTER 1)
187+
185188endif ()
186189
187190if (FLB_DEV)
@@ -577,6 +580,67 @@ if(FLB_INOTIFY)
577580 endif ()
578581endif ()
579582
583+ # iconv
584+ if (FLB_ICONV)
585+
586+ if (CMAKE_VERSION VERSION_LESS 3.11.0)
587+ message ("cmake older than 3.11.0 .. no FindIconv module... testing here" )
588+ if (NOT DEFINED Iconv_IS_BUILT_IN)
589+ if (DEFINED Iconv_INCLUDE_DIR AND NOT DEFINED Iconv_LIBRARY)
590+ check_c_source_compiles(
591+ "
592+ #include <stddef.h>
593+ #include <iconv.h>
594+ int main() {
595+ char *a, *b;
596+ size_t i, j;
597+ iconv_t ic;
598+ ic = iconv_open(\" to\" , \" from\" );
599+ iconv(ic, &a, &i, &b, &j);
600+ iconv_close(ic);
601+ }
602+ " Iconv_IS_BUILT_IN)
603+ endif ()
604+ endif ()
605+ if (NOT Iconv_IS_BUILT_IN)
606+ if (DEFINED Iconv_INCLUDE_DIR AND NOT DEFINED Iconv_LIBRARIES)
607+ set (CMAKE_REQUIRED_LIBRARIES "iconv" )
608+ check_c_source_compiles(
609+ "
610+ #include <stddef.h>
611+ #include <iconv.h>
612+ int main() {
613+ char *a, *b;
614+ size_t i, j;
615+ iconv_t ic;
616+ ic = iconv_open(\" to\" , \" from\" );
617+ iconv(ic, &a, &i, &b, &j);
618+ iconv_close(ic);
619+ }
620+ " Iconv_FOUND)
621+ if (Iconv_FOUND)
622+ set (Iconv_LIBRARIES "iconv" )
623+ endif ()
624+ endif ()
625+ endif ()
626+
627+ else ()
628+ include (FindIconv)
629+ endif ()
630+
631+ if (Iconv_IS_BUILT_IN)
632+ message ("Iconv_IS_BUILT_IN builtin is defined" )
633+ FLB_DEFINITION(FLB_HAVE_ICONV)
634+ elseif (Iconv_LIBRARIES)
635+ message ("Iconv_LIBRARIES defined '${Iconv_LIBRARIES} '" )
636+ FLB_DEFINITION(FLB_HAVE_ICONV)
637+ else ()
638+ message ("FLB_ICONV defined iconv not given" )
639+ set (FLB_ICONV NO )
640+ endif ()
641+
642+ endif ()
643+
580644configure_file (
581645 "${PROJECT_SOURCE_DIR} /include/fluent-bit/flb_info.h.in"
582646 "${PROJECT_SOURCE_DIR} /include/fluent-bit/flb_info.h"
0 commit comments