<commit_before>include(ExternalProject)

set(OPTIONS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_POSIX_RE=0 -DGTEST_HAS_STREAM_REDIRECTION=0 -DGTEST_MOCK_FS=1")

ExternalProject_Add(gtest_source
  GIT_REPOSITORY https://github.com/google/googletest.git
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
  UPDATE_DISCONNECTED 1
  INSTALL_COMMAND ""
  PATCH_COMMAND
    git apply ${CMAKE_CURRENT_SOURCE_DIR}/patches/0001-Allow-mocking-file-system-getcmd-mkdir.patch
    && git apply ${CMAKE_CURRENT_SOURCE_DIR}/patches/0002-Fix-passing-CXX-flags.patch
  CMAKE_ARGS
    -DBUILD_GMOCK=OFF
    -DBUILD_GTEST=ON
    -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/toolchain.cmake
    -DCMAKE_CXX_FLAGS=${OPTIONS}
    -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
    -DCMAKE_BUILD_TYPE:STRING=$<CONFIG>
  EXCLUDE_FROM_ALL 1
)

ExternalProject_Get_Property(gtest_source source_dir)
ExternalProject_Get_Property(gtest_source binary_dir)

function(addExternalLib name dependency source_location binary_location include_directory)
    add_library(${name} INTERFACE)
    add_dependencies(${name} ${dependency})
    target_link_libraries(${name} INTERFACE "${binary_location}/${CMAKE_FIND_LIBRARY_PREFIXES}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}") 
    target_include_directories(${name} INTERFACE "${include_directory}")
endfunction(addExternalLib)
<commit_msg>Use fork of GTest instead of patching<commit_after>include(ExternalProject)

set(OPTIONS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_POSIX_RE=0 -DGTEST_HAS_STREAM_REDIRECTION=0 -DGTEST_MOCK_FS=1")

ExternalProject_Add(gtest_source
  GIT_REPOSITORY https://github.com/PW-Sat2/googletest.git
  GIT_TAG newlib
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
  UPDATE_DISCONNECTED 1
  INSTALL_COMMAND ""
  CMAKE_ARGS
    -DBUILD_GMOCK=OFF
    -DBUILD_GTEST=ON
    -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/toolchain.cmake
    -DCMAKE_CXX_FLAGS=${OPTIONS}
    -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
    -DCMAKE_BUILD_TYPE:STRING=$<CONFIG>
  EXCLUDE_FROM_ALL 1
)

ExternalProject_Get_Property(gtest_source source_dir)
ExternalProject_Get_Property(gtest_source binary_dir)

function(addExternalLib name dependency source_location binary_location include_directory)
    add_library(${name} INTERFACE)
    add_dependencies(${name} ${dependency})
    target_link_libraries(${name} INTERFACE "${binary_location}/${CMAKE_FIND_LIBRARY_PREFIXES}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
    target_include_directories(${name} INTERFACE "${include_directory}")
endfunction(addExternalLib)

{'fraction_non_alphanumeric': 0.09939637826961771, 'fraction_numerical': 0.007645875251509054, 'mean_word_length': 7.602076124567474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1440066', 'n_tokens_mistral': 957, 'n_tokens_neox': 870, 'n_words': 103}