<commit_before>include(ExternalProject)

find_library(GLOG_FIND_LIBRARY libglog.a)
if(${GLOG_FIND_LIBRARY} MATCHES GLOG_FIND_LIBRARY-NOTFOUND)

    set(GLOG_CXXFLAGS "-fPIC -w")
    if(CMAKE_BUILD_TYPE MATCHES Debug)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
    elseif(CMAKE_BUILD_TYPE MATCHES Release)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
    elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
    elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}")
    endif()

    set(GLOG_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/src/glog")
    if(EXISTS ${GLOG_BUILD_DIR}/.libs/libglog.a)
        set(GLOG_CONFIGURE_COMMAND "cd")    # nop
        set(GLOG_BUILD_COMMAND "cd")        # nop
    endif()

    ExternalProject_Add(glogBuild
        PREFIX ${CMAKE_CURRENT_BINARY_DIR}
        SOURCE_DIR ${GLOG_BUILD_DIR}
        GIT_REPOSITORY https://github.com/RoXeon/google-glog.git
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> CXXFLAGS=${GLOG_CXXFLAGS}
        UPDATE_COMMAND ""
        BUILD_COMMAND ${MAKE}
        BUILD_IN_SOURCE 1
        INSTALL_COMMAND ""
    )

    # Export dep includes and lib paths
    ExternalProject_Get_Property(glogBuild prefix)
    ExternalProject_Get_Property(glogBuild source_dir)
    set(GLOG_INCLUDE_DIR ${source_dir}/src PARENT_SCOPE)
    set(GLOG_LIBRARIES ${source_dir}/.libs/libglog.a)
    set(GLOG_LIBRARIES ${GLOG_LIBRARIES} PARENT_SCOPE)<commit_msg>VFS-679 Manually set CFLAGS for Glog build.<commit_after>include(ExternalProject)

find_library(GLOG_FIND_LIBRARY libglog.a)
if(${GLOG_FIND_LIBRARY} MATCHES GLOG_FIND_LIBRARY-NOTFOUND)

    set(GLOG_CXXFLAGS "-fPIC -w")
    if(CMAKE_BUILD_TYPE MATCHES Debug)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
    elseif(CMAKE_BUILD_TYPE MATCHES Release)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
    elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
    elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
        set(GLOG_CXXFLAGS "${GLOG_CXXFLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}")
    endif()

    set(GLOG_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/src/glog")
    if(EXISTS ${GLOG_BUILD_DIR}/.libs/libglog.a)
        set(GLOG_CONFIGURE_COMMAND "cd")    # nop
        set(GLOG_BUILD_COMMAND "cd")        # nop
    endif()

    ExternalProject_Add(glogBuild
        PREFIX ${CMAKE_CURRENT_BINARY_DIR}
        SOURCE_DIR ${GLOG_BUILD_DIR}
        GIT_REPOSITORY https://github.com/RoXeon/google-glog.git
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> CXXFLAGS=${GLOG_CXXFLAGS} CC=${CMAKE_CXX_COMPILER} CFLAGS=${GLOG_CXXFLAGS}
        UPDATE_COMMAND ""
        BUILD_COMMAND ${MAKE}
        BUILD_IN_SOURCE 1
        INSTALL_COMMAND ""
    )

    # Export dep includes and lib paths
    ExternalProject_Get_Property(glogBuild prefix)
    ExternalProject_Get_Property(glogBuild source_dir)
    set(GLOG_INCLUDE_DIR ${source_dir}/src PARENT_SCOPE)
    set(GLOG_LIBRARIES ${source_dir}/.libs/libglog.a)
    set(GLOG_LIBRARIES ${GLOG_LIBRARIES} PARENT_SCOPE)
{'fraction_non_alphanumeric': 0.09972636059592581, 'fraction_numerical': 0.0015202189115232593, 'mean_word_length': 4.280898876404494, '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': '4858320', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1207, 'n_words': 167}