<commit_before>if(UNIX)
    # 3.1: Required by CTEST_COVERAGE_EXTRA_FLAGS and CTEST_UPDATE_VERSION_ONLY
    # 3.8: Required by fixed CTEST_MEMORYCHECK_SANITIZER_OPTIONS
    cmake_minimum_required(VERSION 3.8)
else()
    # 3.5: Required by COBERTURADIR
    cmake_minimum_required(VERSION 3.5)
endif()

if(NOT DEFINED ENV{CI})
    message(FATAL_ERROR "Not a CI server.")
endif()

# Compiler
if(UNIX)
    exec_program(uname ARGS -m OUTPUT_VARIABLE CC_ARCH)
    if(DEFINED ENV{CC})
        find_program(CC_FOUND NAMES $ENV{CC})
        if(NOT CC_FOUND)
            message( FATAL_ERROR "Compiler $ENV{CC} not found." )
        endif()
        if($ENV{CC} STREQUAL "icc")
            set(CC_NAME "icc")
            exec_program($ENV{CC} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
            exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
            string(STRIP "-pc-linux-gnu" CC_ARCH))
        elseif($ENV{CC} STREQUAL "tcc")
            set(CC_NAME "tcc")
            exec_program($ENV{CC} ARGS -v OUTPUT_VARIABLE CC_VERSION)
            string(REGEX REPLACE ".*tcc version ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
        elseif($ENV{CC} STREQUAL "x86_64-w64-mingw32-gcc" OR $ENV{CC} STREQUAL "i686-w64-mingw32-gcc")
            set(CC_NAME "mingw")
            exec_program($ENV{CC} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
            if((CC_VERSION VERSION_GREATER 5) OR (CC_VERSION VERSION_EQUAL 5))
                string(SUBSTRING "${CC_VERSION}" 0 1 CC_VERSION)
            else()
                string(SUBSTRING "${CC_VERSION}" 0 3 CC_VERSION)
            endif()
            exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
            string(STRIP "-w64-mingw32" CC_ARCH))
            #Warmup wine or test timings are going to be wrong
            exec_program(wine ARGS version OUTPUT_VARIABLE WINE_VERSION)
        elseif($ENV{CC} STREQUAL "emcc")
            set(CC_NAME "emscripten")
            set(CC_ARCH "asmjs")  
            exec_program($ENV{CC} ARGS --version OUTPUT_VARIABLE CC_VERSION)
            string(REGEX REPLACE ".*gcc\\/clang\\-like replacement\\) ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
        else()
            string(SUBSTRING "$ENV{CC}" 0 3 CC)
            if(CC STREQUAL "gcc")
                set(CC_NAME "gcc")
                exec_program($ENV{CC} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
                if((CC_VERSION VERSION_GREATER 5) OR (CC_VERSION VERSION_EQUAL 5))
                    string(SUBSTRING "${CC_VERSION}" 0 1 CC_VERSION)
                else()
                    string(SUBSTRING "${CC_VERSION}" 0 3 CC_VERSION)
                endif()
                exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
                string(STRIP "-unknown-linux-gnu" CC_ARCH))
            endif()
            string(SUBSTRING "$ENV{CC}" 0 5 CC)
            if(CC STREQUAL "clang")
                if(APPLE)
                    set(CC_NAME "xcode")
                    exec_program(xcodebuild ARGS -version OUTPUT_VARIABLE CC_VERSION)
                    string(REGEX REPLACE ".*Xcode ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
                else()
                    set(CC_NAME "clang")
                    exec_program($ENV{CC} ARGS --version OUTPUT_VARIABLE CC_VERSION)
                    string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
                endif()
                exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
                string(STRIP "-unknown-linux-gnu" CC_ARCH))
            endif()
        endif()
    else()
        set(CC_NAME "gcc")
        exec_program(${CC_NAME} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
        string(SUBSTRING "${CC_VERSION}" 0 3 CC_VERSION)
        exec_program($ENV{CC_NAME} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
        string(STRIP "-unknown-linux-gnu" CC_ARCH))
    endif()
    if(${CC_ARCH} STREQUAL "x86_64" OR ${CC_ARCH} STREQUAL "amd64")
        set(CC_ARCH "x86_64")
    elseif(${CC_ARCH} STREQUAL "i386" OR ${CC_ARCH} STREQUAL "i486" OR ${CC_ARCH} STREQUAL "i586" OR ${CC_ARCH} STREQUAL "i686" OR ${CC_ARCH} STREQUAL "i786")
        set(CC_ARCH "x86")
    endif()
else()
    set(CC_NAME "msvc")
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
        set(CC_ARCH "x86_64")
    else()
        set(CC_ARCH "x86")
    endif()
endif()

# CI service
# TODO set CTEST_CHANGE_ID for all services
if(DEFINED ENV{APPVEYOR})<commit_msg>Bugfix.<commit_after>if(UNIX)
    # 3.1: Required by CTEST_COVERAGE_EXTRA_FLAGS and CTEST_UPDATE_VERSION_ONLY
    # 3.8: Required by fixed CTEST_MEMORYCHECK_SANITIZER_OPTIONS
    cmake_minimum_required(VERSION 3.8)
else()
    # 3.5: Required by COBERTURADIR
    cmake_minimum_required(VERSION 3.5)
endif()

if(NOT DEFINED ENV{CI})
    message(FATAL_ERROR "Not a CI server.")
endif()

# Compiler
if(UNIX)
    exec_program(uname ARGS -m OUTPUT_VARIABLE CC_ARCH)
    if(DEFINED ENV{CC})
        find_program(CC_FOUND NAMES $ENV{CC})
        if(NOT CC_FOUND)
            message( FATAL_ERROR "Compiler $ENV{CC} not found." )
        endif()
        if($ENV{CC} STREQUAL "icc")
            set(CC_NAME "icc")
            exec_program($ENV{CC} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
            exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
            string(STRIP "-pc-linux-gnu" CC_ARCH)
        elseif($ENV{CC} STREQUAL "tcc")
            set(CC_NAME "tcc")
            exec_program($ENV{CC} ARGS -v OUTPUT_VARIABLE CC_VERSION)
            string(REGEX REPLACE ".*tcc version ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
        elseif($ENV{CC} STREQUAL "x86_64-w64-mingw32-gcc" OR $ENV{CC} STREQUAL "i686-w64-mingw32-gcc")
            set(CC_NAME "mingw")
            exec_program($ENV{CC} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
            if((CC_VERSION VERSION_GREATER 5) OR (CC_VERSION VERSION_EQUAL 5))
                string(SUBSTRING "${CC_VERSION}" 0 1 CC_VERSION)
            else()
                string(SUBSTRING "${CC_VERSION}" 0 3 CC_VERSION)
            endif()
            exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
            string(STRIP "-w64-mingw32" CC_ARCH)
            #Warmup wine or test timings are going to be wrong
            exec_program(wine ARGS version OUTPUT_VARIABLE WINE_VERSION)
        elseif($ENV{CC} STREQUAL "emcc")
            set(CC_NAME "emscripten")
            set(CC_ARCH "asmjs")  
            exec_program($ENV{CC} ARGS --version OUTPUT_VARIABLE CC_VERSION)
            string(REGEX REPLACE ".*gcc\\/clang\\-like replacement\\) ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
        else()
            string(SUBSTRING "$ENV{CC}" 0 3 CC)
            if(CC STREQUAL "gcc")
                set(CC_NAME "gcc")
                exec_program($ENV{CC} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
                if((CC_VERSION VERSION_GREATER 5) OR (CC_VERSION VERSION_EQUAL 5))
                    string(SUBSTRING "${CC_VERSION}" 0 1 CC_VERSION)
                else()
                    string(SUBSTRING "${CC_VERSION}" 0 3 CC_VERSION)
                endif()
                exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
                string(STRIP "-unknown-linux-gnu" CC_ARCH)
            endif()
            string(SUBSTRING "$ENV{CC}" 0 5 CC)
            if(CC STREQUAL "clang")
                if(APPLE)
                    set(CC_NAME "xcode")
                    exec_program(xcodebuild ARGS -version OUTPUT_VARIABLE CC_VERSION)
                    string(REGEX REPLACE ".*Xcode ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
                else()
                    set(CC_NAME "clang")
                    exec_program($ENV{CC} ARGS --version OUTPUT_VARIABLE CC_VERSION)
                    string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CC_VERSION ${CC_VERSION})
                endif()
                exec_program($ENV{CC} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
                string(STRIP "-unknown-linux-gnu" CC_ARCH)
            endif()
        endif()
    else()
        set(CC_NAME "gcc")
        exec_program(${CC_NAME} ARGS -dumpversion OUTPUT_VARIABLE CC_VERSION)
        string(SUBSTRING "${CC_VERSION}" 0 3 CC_VERSION)
        exec_program($ENV{CC_NAME} ARGS -dumpmachine OUTPUT_VARIABLE CC_ARCH)
        string(STRIP "-unknown-linux-gnu" CC_ARCH)
    endif()
    if(${CC_ARCH} STREQUAL "x86_64" OR ${CC_ARCH} STREQUAL "amd64")
        set(CC_ARCH "x86_64")
    elseif(${CC_ARCH} STREQUAL "i386" OR ${CC_ARCH} STREQUAL "i486" OR ${CC_ARCH} STREQUAL "i586" OR ${CC_ARCH} STREQUAL "i686" OR ${CC_ARCH} STREQUAL "i786")
        set(CC_ARCH "x86")
    endif()
else()
    set(CC_NAME "msvc")
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
        set(CC_ARCH "x86_64")
    else()
        set(CC_ARCH "x86")
    endif()
endif()

# CI service
# TODO set CTEST_CHANGE_ID for all services
if(DEFINED ENV{APPVEYOR})
{'fraction_non_alphanumeric': 0.12181271573321456, 'fraction_numerical': 0.02249192740229373, 'mean_word_length': 2.319290465631929, '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': '58516', 'n_tokens_mistral': 3267, 'n_tokens_neox': 3043, 'n_words': 667}