<commit_before>include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

function(setupBuildFlags)
  add_library(cxx_settings INTERFACE)
  add_library(c_settings INTERFACE)

  target_compile_features(cxx_settings INTERFACE cxx_std_14)
  target_compile_features(c_settings INTERFACE c_std_11)

  if(DEFINED PLATFORM_POSIX)

    set(posix_common_compile_options
      -Qunused-arguments
      -Wno-shadow-field
      -Wall
      -Wextra
      -Wno-unused-local-typedef
      -Wno-deprecated-register
      -Wno-unknown-warning-option
      -Wstrict-aliasing
      -Wno-missing-field-initializers
      -Wchar-subscripts
      -Wpointer-arith
      -Wformat
      -Wformat-security
      -Werror=format-security
      -Wuseless-cast
      -Wno-zero-length-array
      -Wno-unused-parameter
      -Wno-gnu-case-range
      -fpermissive
      -fstack-protector-all
      -fdata-sections
      -ffunction-sections
      -fvisibility=hidden
      -fvisibility-inlines-hidden
      -fno-limit-debug-info
      -pipe
      -pedantic
    )

    if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
      list(APPEND posix_common_compile_options INTERFACE -Oz)
    endif()

    set(osquery_posix_common_defines
      POSIX=1
      OSQUERY_POSIX=1
    )

    set(posix_cxx_compile_options
      -Wno-c++11-extensions
      -Woverloaded-virtual
      -Wnon-virtual-dtor
      -Weffc++
      -stdlib=libc++
    )

    set(posix_cxx_link_options
      -stdlib=libc++
    )

    set(posix_cxx_libraries
      c++
      c++abi
    )

    set(posix_c_compile_options
      -Wno-c99-extensions
    )

    target_compile_options(cxx_settings INTERFACE
      ${posix_common_compile_options}
      ${posix_cxx_compile_options}
    )
    target_link_options(cxx_settings INTERFACE
      ${posix_common_link_options}
      ${posix_cxx_link_options}
    )
    target_link_libraries(cxx_settings INTERFACE
      ${posix_cxx_libraries}
    )

    target_compile_options(c_settings INTERFACE
      ${posix_common_compile_options}
      ${posix_c_compile_options}
    )

    list(APPEND osquery_defines ${osquery_posix_common_defines})


    if(DEFINED PLATFORM_LINUX)
      set(osquery_linux_common_defines
        LINUX=1
        OSQUERY_LINUX=1
        OSQUERY_BUILD_DISTRO=centos7
        OSQUERY_BUILD_PLATFORM=linux
      )

      set(linux_cxx_link_options
        --no-undefined
      )

      list(APPEND osquery_defines ${osquery_linux_common_defines})
      target_link_options(cxx_settings INTERFACE
        ${linux_cxx_link_options}
      )
    elseif(DEFINED PLATFORM_MACOS)
      set(macos_cxx_compile_options
        -x objective-c++
        -fobjc-arc
        -Wabi-tag
      )

      set(macos_cxx_link_options
        "SHELL:-framework AppKit"
        "SHELL:-framework Foundation"
        "SHELL:-framework CoreServices"<commit_msg>Link binaries with Full RELRO on Linux (#5748)<commit_after>include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

function(setupBuildFlags)
  add_library(cxx_settings INTERFACE)
  add_library(c_settings INTERFACE)

  target_compile_features(cxx_settings INTERFACE cxx_std_14)
  target_compile_features(c_settings INTERFACE c_std_11)

  if(DEFINED PLATFORM_POSIX)

    set(posix_common_compile_options
      -Qunused-arguments
      -Wno-shadow-field
      -Wall
      -Wextra
      -Wno-unused-local-typedef
      -Wno-deprecated-register
      -Wno-unknown-warning-option
      -Wstrict-aliasing
      -Wno-missing-field-initializers
      -Wchar-subscripts
      -Wpointer-arith
      -Wformat
      -Wformat-security
      -Werror=format-security
      -Wuseless-cast
      -Wno-zero-length-array
      -Wno-unused-parameter
      -Wno-gnu-case-range
      -fpermissive
      -fstack-protector-all
      -fdata-sections
      -ffunction-sections
      -fvisibility=hidden
      -fvisibility-inlines-hidden
      -fno-limit-debug-info
      -pipe
      -pedantic
    )

    if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
      list(APPEND posix_common_compile_options INTERFACE -Oz)
    endif()

    set(osquery_posix_common_defines
      POSIX=1
      OSQUERY_POSIX=1
    )

    set(posix_cxx_compile_options
      -Wno-c++11-extensions
      -Woverloaded-virtual
      -Wnon-virtual-dtor
      -Weffc++
      -stdlib=libc++
    )

    set(posix_cxx_link_options
      -stdlib=libc++
    )

    set(posix_cxx_libraries
      c++
      c++abi
    )

    set(posix_c_compile_options
      -Wno-c99-extensions
    )

    target_compile_options(cxx_settings INTERFACE
      ${posix_common_compile_options}
      ${posix_cxx_compile_options}
    )
    target_link_options(cxx_settings INTERFACE
      ${posix_common_link_options}
      ${posix_cxx_link_options}
    )
    target_link_libraries(cxx_settings INTERFACE
      ${posix_cxx_libraries}
    )

    target_compile_options(c_settings INTERFACE
      ${posix_common_compile_options}
      ${posix_c_compile_options}
    )

    list(APPEND osquery_defines ${osquery_posix_common_defines})


    if(DEFINED PLATFORM_LINUX)
      set(osquery_linux_common_defines
        LINUX=1
        OSQUERY_LINUX=1
        OSQUERY_BUILD_DISTRO=centos7
        OSQUERY_BUILD_PLATFORM=linux
      )

      set(osquery_linux_common_link_options
        -Wl,-z,relro,-z,now
      )

      set(linux_cxx_link_options
        --no-undefined
      )

      list(APPEND osquery_defines ${osquery_linux_common_defines})
      target_link_options(cxx_settings INTERFACE
        ${osquery_linux_common_link_options}
        ${linux_cxx_link_options}
      )
      target_link_options(c_settings INTERFACE
        ${osquery_linux_common_link_options}
      )
    elseif(DEFINED PLATFORM_MACOS)
      set(macos_cxx_compile_options
        -x objective-c++
        -fobjc-arc
        -Wabi-tag
      )

      set(macos_cxx_link_options
        "SHELL:-framework AppKit"
        "SHELL:-framework Foundation"
        "SHELL:-framework CoreServices"
{'fraction_non_alphanumeric': 0.07889877455094846, 'fraction_numerical': 0.005036091992613732, 'mean_word_length': 2.6552147239263806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2833581', 'n_tokens_mistral': 2166, 'n_tokens_neox': 2065, 'n_words': 246}