<commit_before>include(CMakeParseArguments)

function(_get_msvc_ide_version result)
    set(${result} "" PARENT_SCOPE)
    if(${CMAKE_GENERATOR} STREQUAL "Ninja")
        string(REGEX MATCHALL "[0-9]+" output "$ENV{VisualStudioVersion}")
        list(GET output 0 _msvc_version)
        set(${result} ${_msvc_version} PARENT_SCOPE)
    else()
        if(CMAKE_VS_PLATFORM_TOOLSET)
            string(REGEX MATCHALL "[0-9]+" output "${CMAKE_VS_PLATFORM_TOOLSET}")
            list(GET output 0 _toolset_version)
            if(_toolset_version LESS 142)
                if ("${_toolset_version}" EQUAL "141")
                    set(_msvc_version "15")
                else()
                    string(SUBSTRING ${_toolset_version} 0 2 _msvc_version)
                endif()
                set(${result} ${_msvc_version} PARENT_SCOPE)
                return()
            else()
                message(STATUS "Conan **WARNING** : Unknown MSVC toolset ${_toolset_version}")
            endif()
        endif()

        string(REGEX MATCHALL "[0-9]+" output "${CMAKE_GENERATOR}")
        list(GET output 0 _msvc_version)
        set(${result} ${_msvc_version} PARENT_SCOPE)
    endif()
endfunction()

function(conan_cmake_settings result)
    #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
    #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
    #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
    #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
    #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
    #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
    #message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
    #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})

    message(STATUS "Conan ** WARNING** : This detection of settings from cmake is experimental and incomplete. "
                    "Please check 'conan.cmake' and contribute")

    if(CONAN_CMAKE_MULTI)
        set(_SETTINGS -g cmake_multi)
    else()
        set(_SETTINGS -g cmake)
    endif()
    if(CMAKE_BUILD_TYPE)
        set(_SETTINGS ${_SETTINGS} -s build_type=${CMAKE_BUILD_TYPE})
    else()
        message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
    endif()

    #handle -s os setting
    if(CMAKE_SYSTEM_NAME)
    #use default conan os setting if CMAKE_SYSTEM_NAME is not defined
        set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
        if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
            set(CONAN_SYSTEM_NAME Macos)
        endif()
        set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD)
        list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index)
        if (${_index} GREATER -1)
            #check if the cmake system is a conan supported one
            set(_SETTINGS ${_SETTINGS} -s os=${CONAN_SYSTEM_NAME})
        else()
            message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}")
        endif()
    endif()

    if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
        # using GCC
        # TODO: Handle other params
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        conan_cmake_detect_gnu_libcxx(_LIBCXX)
        set(_SETTINGS ${_SETTINGS} -s compiler=gcc -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=${_LIBCXX})
    elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
        # using AppleClang
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        set(_SETTINGS ${_SETTINGS} -s compiler=apple-clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libc++)
    elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
        # using Clang
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        set(_SETTINGS ${_SETTINGS} -s compiler=clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libstdc++)
    elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
        set(_VISUAL "Visual Studio")
        _get_msvc_ide_version(_VISUAL_VERSION)
        if("${_VISUAL_VERSION}" STREQUAL "")
            message(FATAL_ERROR "Visual Studio not recognized")
        else()
            set(_SETTINGS ${_SETTINGS} -s compiler=${_VISUAL} -s compiler.version=${_VISUAL_VERSION})
        endif()

        if(${CMAKE_GENERATOR} STREQUAL "Ninja")
            if($ENV{Platform} STREQUAL "X64")
                set(_SETTINGS ${_SETTINGS} -s arch=x86_64)
            elseif($ENV{Platform} STREQUAL "ARM")
                message(STATUS "Conan: Using default ARM architecture from MSVC")
                set(_SETTINGS ${_SETTINGS} -s arch=armv6)
            else()
                set(_SETTINGS ${_SETTINGS} -s arch=x86)
            endif()
        else()
            if(${CMAKE_GENERATOR} MATCHES "Win64")
                set(_SETTINGS ${_SETTINGS} -s arch=x86_64)
            elseif (${CMAKE_GENERATOR} MATCHES "ARM")
                message(STATUS "Conan: Using default ARM architecture from MSVC")
                set(_SETTINGS ${_SETTINGS} -s arch=armv6)
            else()
                set(_SETTINGS ${_SETTINGS} -s arch=x86)
            endif()
        endif()

        conan_cmake_detect_vs_runtime(_vs_runtime)
        message(STATUS "Detected VS runtime: ${_vs_runtime}")<commit_msg>Use same code for Ninja and "Visual Studio" generators<commit_after>include(CMakeParseArguments)

function(_get_msvc_ide_version result)
    set(${result} "" PARENT_SCOPE)
    if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500)
        set(${result} 8 PARENT_SCOPE)
    elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600)
        set(${result} 9 PARENT_SCOPE)
    elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700)
        set(${result} 10 PARENT_SCOPE)
    elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800)
        set(${result} 11 PARENT_SCOPE)
    elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900)
        set(${result} 12 PARENT_SCOPE)
    elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910)
        set(${result} 14 PARENT_SCOPE)
    elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920)
        set(${result} 15 PARENT_SCOPE)
    else()
        message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]")
    endif()
endfunction()

function(conan_cmake_settings result)
    #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
    #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
    #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
    #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
    #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
    #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
    #message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
    #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})

    message(STATUS "Conan ** WARNING** : This detection of settings from cmake is experimental and incomplete. "
                    "Please check 'conan.cmake' and contribute")

    if(CONAN_CMAKE_MULTI)
        set(_SETTINGS -g cmake_multi)
    else()
        set(_SETTINGS -g cmake)
    endif()
    if(CMAKE_BUILD_TYPE)
        set(_SETTINGS ${_SETTINGS} -s build_type=${CMAKE_BUILD_TYPE})
    else()
        message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
    endif()

    #handle -s os setting
    if(CMAKE_SYSTEM_NAME)
        #use default conan os setting if CMAKE_SYSTEM_NAME is not defined
        set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
        if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
            set(CONAN_SYSTEM_NAME Macos)
        endif()
        set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD)
        list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index)
        if (${_index} GREATER -1)
            #check if the cmake system is a conan supported one
            set(_SETTINGS ${_SETTINGS} -s os=${CONAN_SYSTEM_NAME})
        else()
            message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}")
        endif()
    endif()

    if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
        # using GCC
        # TODO: Handle other params
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        conan_cmake_detect_gnu_libcxx(_LIBCXX)
        set(_SETTINGS ${_SETTINGS} -s compiler=gcc -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=${_LIBCXX})
    elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
        # using AppleClang
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        set(_SETTINGS ${_SETTINGS} -s compiler=apple-clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libc++)
    elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
        # using Clang
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        set(_SETTINGS ${_SETTINGS} -s compiler=clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libstdc++)
    elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
        set(_VISUAL "Visual Studio")
        _get_msvc_ide_version(_VISUAL_VERSION)
        if("${_VISUAL_VERSION}" STREQUAL "")
            message(FATAL_ERROR "Conan: Visual Studio not recognized")
        else()
            set(_SETTINGS ${_SETTINGS} -s compiler=${_VISUAL} -s compiler.version=${_VISUAL_VERSION})
        endif()

        if (MSVC_CXX_ARCHITECTURE_ID MATCHES "64")
            set(_SETTINGS ${_SETTINGS} -s arch=x86_64)
        elseif (MSVC_CXX_ARCHITECTURE_ID MATCHES "^ARM")
            message(STATUS "Conan: Using default ARM architecture from MSVC")
            set(_SETTINGS ${_SETTINGS} -s arch=armv6)
        elseif (MSVC_CXX_ARCHITECTURE_ID MATCHES "86")
            set(_SETTINGS ${_SETTINGS} -s arch=x86)
        else ()
            message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_CXX_ARCHITECTURE_ID}]")
        endif()

        conan_cmake_detect_vs_runtime(_vs_runtime)
        message(STATUS "Detected VS runtime: ${_vs_runtime}")
{'fraction_non_alphanumeric': 0.10515405634599076, 'fraction_numerical': 0.01300292094600961, 'mean_word_length': 3.088597842835131, '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': '1939309', 'n_tokens_mistral': 3787, 'n_tokens_neox': 3552, 'n_words': 773}