<commit_before>
macro(OSIROSE_CONFIGURE_FILE_AUTOTOOLS_COMPAT)
  set(configure_input "${ARGV1} generated from ${ARGV0} by CMake.")
  configure_file(${ARGV})
endmacro(OSIROSE_CONFIGURE_FILE_AUTOTOOLS_COMPAT)

function(CREATE_VERSION_FILE)
  # Create a version file using git data
  if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
    execute_process(
      COMMAND git rev-parse --abbrev-ref HEAD
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
      OUTPUT_VARIABLE GIT_BRANCH
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )

    execute_process(
      COMMAND git log -1 --format=%h
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
      OUTPUT_VARIABLE GIT_COMMIT_HASH
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )
  else()
    set(GIT_BRANCH "")
    set(GIT_COMMIT_HASH "")
  endif()
  # --------------------------

  #start version file
  message(STATUS "Generating version.h")
  configure_file(
    ${CMAKE_SOURCE_DIR}/cmake/version.h.in
    ${CMAKE_GEN_SRC_DIR}/version.h
  )
  #end version file
endfunction()

function(OVERWRITE_COMPILER_SETTINGS)
# --------------------------
# Make sure our settings are correct
  foreach(flag_var
      CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
      CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)

    if(${flag_var} MATCHES "/MD")
      string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MD")

    if(${flag_var} MATCHES "_DLL")
      string(REGEX REPLACE "_DLL" "" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "_DLL")
  endforeach(flag_var)
# --------------------------
endfunction()

function(generate_symbol_data target)
  if(UNIX)
    set(TARGET_PATH ${CMAKE_BINARY_DIR}/bin/symbols/${target}.sym)
  
    add_custom_command(TARGET ${target}
      POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/symbols
      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/symbols/${target}.pdb
      COMMAND ${BREAKPAD_EXCEPTION_HANDLER_INSTALL_DIR}/bin/dump_syms $<TARGET_FILE:${target}> > ${TARGET_PATH}
      COMMAND head -n1 ${TARGET_PATH} > /tmp/${target}.str
      COMMAND bash ${CMAKE_SCRIPT_PATH}/create_breakpad_directories.sh ${CMAKE_BINARY_DIR}/bin/symbols/${target}.pdb /tmp/${target}.str ${TARGET_PATH}
      VERBATIM
    )
  endif()
endfunction()

function(GENERATE_SQL_HEADER HDRS)
  PARSE_ARGUMENTS(ARG "SQLROOT;SQLFILE;OUTPATH;NAME;TARGET;EXPORT_MACRO" "DEBUG" ${ARGN})
<commit_msg>ensure breakpad was built before trying to generate debug symbol data.<commit_after>
macro(OSIROSE_CONFIGURE_FILE_AUTOTOOLS_COMPAT)
  set(configure_input "${ARGV1} generated from ${ARGV0} by CMake.")
  configure_file(${ARGV})
endmacro(OSIROSE_CONFIGURE_FILE_AUTOTOOLS_COMPAT)

function(CREATE_VERSION_FILE)
  # Create a version file using git data
  if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
    execute_process(
      COMMAND git rev-parse --abbrev-ref HEAD
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
      OUTPUT_VARIABLE GIT_BRANCH
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )

    execute_process(
      COMMAND git log -1 --format=%h
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
      OUTPUT_VARIABLE GIT_COMMIT_HASH
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )
  else()
    set(GIT_BRANCH "")
    set(GIT_COMMIT_HASH "")
  endif()
  # --------------------------

  #start version file
  message(STATUS "Generating version.h")
  configure_file(
    ${CMAKE_SOURCE_DIR}/cmake/version.h.in
    ${CMAKE_GEN_SRC_DIR}/version.h
  )
  #end version file
endfunction()

function(OVERWRITE_COMPILER_SETTINGS)
# --------------------------
# Make sure our settings are correct
  foreach(flag_var
      CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
      CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)

    if(${flag_var} MATCHES "/MD")
      string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MD")

    if(${flag_var} MATCHES "_DLL")
      string(REGEX REPLACE "_DLL" "" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "_DLL")
  endforeach(flag_var)
# --------------------------
endfunction()

function(generate_symbol_data target)
  if(UNIX)
    set(TARGET_PATH ${CMAKE_BINARY_DIR}/bin/symbols/${target}.sym)
    
    add_dependencies(${target} breakpad)
  
    add_custom_command(TARGET ${target}
      POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/symbols
      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/symbols/${target}.pdb
      COMMAND ${BREAKPAD_EXCEPTION_HANDLER_INSTALL_DIR}/bin/dump_syms $<TARGET_FILE:${target}> > ${TARGET_PATH}
      COMMAND head -n1 ${TARGET_PATH} > /tmp/${target}.str
      COMMAND bash ${CMAKE_SCRIPT_PATH}/create_breakpad_directories.sh ${CMAKE_BINARY_DIR}/bin/symbols/${target}.pdb /tmp/${target}.str ${TARGET_PATH}
      VERBATIM
    )
  endif()
endfunction()

function(GENERATE_SQL_HEADER HDRS)
  PARSE_ARGUMENTS(ARG "SQLROOT;SQLFILE;OUTPATH;NAME;TARGET;EXPORT_MACRO" "DEBUG" ${ARGN})

{'fraction_non_alphanumeric': 0.144765702891326, 'fraction_numerical': 0.0015952143569292123, 'mean_word_length': 3.88412852969815, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7217561', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1783, 'n_words': 292}