<commit_before>option(FIRST_ERROR "stop on first compilation error" FALSE)
option(COVERAGE "active coverage (only clang)" FALSE)
option(SANITIZER "active sanitizers (address,address-full,memory,thread) (only clang)" "")

macro(GENERATE_CLANG)
	# Generate .clang_complete for full completation in vim + clang_complete
	set(extra_parameters "")
	get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
	foreach(dir ${dirs})
	  set(extra_parameters ${extra_parameters} -I${dir})
	endforeach()
	get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
	foreach(dir ${dirs})
	  set(extra_parameters ${extra_parameters} -D${dir})
	endforeach()
	STRING(REGEX REPLACE ";" "\n" extra_parameters "${extra_parameters}")
	FILE(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/.clang_complete" "${extra_parameters}\n")
endmacro()

macro(COMMONS_FLAGS)
	if(SANITIZER)
		add_definitions(-g3)
		# "address-full" "memory" "thread"
		SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZER}")
		SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZER}")
		add_definitions(-fsanitize=${SANITIZER})
	endif()
	IF(COVERAGE)
		if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
		else()
			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs")
			SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -lgcov")
		endif()
	endif()

	if(NOT WIN32)
		SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -pthread" )
		if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
			SET( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -lpthread" )
		endif()
	endif()

	# include_directories(BEFORE ${TOOLCHAIN_ROOT}/include)
	# link_directories(${TOOLCHAIN_ROOT}/lib)
	# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ltcmalloc")
endmacro()

macro(ENABLE_MODERN_CPP)

    if(WIN32)
        add_definitions(/EHsc)
        #add_definitions(/GR-)
        #add_definitions(/D_HAS_EXCEPTIONS=0)
    else()
        # add_definitions(-fno-rtti -fno-exceptions )
		# activate all warnings and convert in errors
        # add_definitions(-Weffc++)
        add_definitions(-Wall -pedantic -pedantic-errors -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion)
        add_definitions(-Wdisabled-optimization -Werror -Wfloat-equal -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k)
        add_definitions(-Wimport  -Winit-self  -Winline -Winvalid-pch -Wlong-long -Wmissing-field-initializers -Wmissing-format-attribute)
		add_definitions(-Wmissing-include-dirs -Wpacked -Wpointer-arith -Wredundant-decls -Wshadow)
        add_definitions(-Wstack-protector -Wunreachable-code -Wunused)
        add_definitions(-Wunused-parameter -Wvariadic-macros -Wwrite-strings)
        add_definitions(-Wdelete-non-virtual-dtor)
		add_definitions(-Wswitch-default -Wswitch-enum)
		# only gcc
		# convert error in warnings
		add_definitions(-Wno-error=shadow)
		add_definitions(-Wno-error=long-long)
		add_definitions(-Wno-error=aggregate-return)
		add_definitions(-Wno-error=aggregate-return)
		add_definitions(-Wno-error=unused-variable)
		add_definitions(-Wno-error=unused-parameter)
		add_definitions(-Wno-error=deprecated-declarations)
		add_definitions(-Wno-error=sign-conversion)

		if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
			add_definitions(-Wno-error=suggest-attribute=noreturn)
			add_definitions(-Wno-aggregate-return)
			add_definitions(-Wno-long-long)
			add_definitions(-Wno-shadow)
			add_definitions(-Wno-strict-aliasing)
			add_definitions(-Wno-error=inline)
		else()
			add_definitions(-Wstrict-aliasing=2)
		endif()

		# no export symbols by default
		add_definitions(-fvisibility=hidden)
		add_definitions(-fvisibility-inlines-hidden)

		# stop in first error
		if(FIRST_ERROR)
			add_definitions(-Wfatal-errors)
		endif()

    endif()

	if (NOT DEFINED EXTRA_DEF)
		if(NOT WIN32)
		    include(CheckCXXCompilerFlag)
		    #CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z)
		    CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
		    CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)<commit_msg>minor changes<commit_after>option(FIRST_ERROR "stop on first compilation error" FALSE)
option(COVERAGE "active coverage (only clang)" FALSE)
option(SANITIZER "active sanitizers (address,address-full,memory,thread) (only clang)" "")

macro(GENERATE_CLANG)
	# Generate .clang_complete for full completation in vim + clang_complete
	set(extra_parameters "")
	get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
	foreach(dir ${dirs})
	  set(extra_parameters ${extra_parameters} -I${dir})
	endforeach()
	get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
	foreach(dir ${dirs})
	  set(extra_parameters ${extra_parameters} -D${dir})
	endforeach()
	STRING(REGEX REPLACE ";" "\n" extra_parameters "${extra_parameters}")
	FILE(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/.clang_complete" "${extra_parameters}\n")
endmacro()

macro(COMMONS_FLAGS)
	if(SANITIZER)
		add_definitions(-g3)
		# "address-full" "memory" "thread"
		SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZER}")
		SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZER}")
		add_definitions(-fsanitize=${SANITIZER})
	endif()
	IF(COVERAGE)
		if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
		else()
			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs")
			SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -lgcov")
		endif()
	endif()

	if(NOT WIN32)
		SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -pthread" )
		if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
			SET( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -lpthread" )
		endif()
	endif()

	# include_directories(BEFORE ${TOOLCHAIN_ROOT}/include)
	# link_directories(${TOOLCHAIN_ROOT}/lib)
	# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ltcmalloc")
endmacro()

macro(ENABLE_MODERN_CPP)

    if(WIN32)
        add_definitions(/EHsc)
        #add_definitions(/GR-)
        #add_definitions(/D_HAS_EXCEPTIONS=0)
    else()
        # add_definitions(-fno-rtti -fno-exceptions )
		# activate all warnings and convert in errors
        # add_definitions(-Weffc++)
        add_definitions(-Wall -pedantic -pedantic-errors -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion)
        add_definitions(-Wdisabled-optimization -Werror -Wfloat-equal -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k)
        add_definitions(-Wimport  -Winit-self  -Winline -Winvalid-pch -Wlong-long -Wmissing-field-initializers -Wmissing-format-attribute)
		add_definitions(-Wmissing-include-dirs -Wpacked -Wpointer-arith -Wredundant-decls -Wshadow)
        add_definitions(-Wstack-protector -Wunreachable-code -Wunused)
        add_definitions(-Wunused-parameter -Wvariadic-macros -Wwrite-strings)
        add_definitions(-Wdelete-non-virtual-dtor)
		add_definitions(-Wswitch-default -Wswitch-enum)
		# only gcc
		# convert error in warnings
		add_definitions(-Wno-error=shadow)
		add_definitions(-Wno-error=long-long)
		add_definitions(-Wno-error=aggregate-return)
		add_definitions(-Wno-error=aggregate-return)
		add_definitions(-Wno-error=unused-variable)
		add_definitions(-Wno-error=unused-parameter)
		add_definitions(-Wno-error=deprecated-declarations)
		add_definitions(-Wno-error=sign-conversion)
		add_definitions(-Wno-error=switch-enum)

		if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
			add_definitions(-Wno-error=suggest-attribute=noreturn)
			add_definitions(-Wno-aggregate-return)
			add_definitions(-Wno-long-long)
			add_definitions(-Wno-shadow)
			add_definitions(-Wno-strict-aliasing)
			add_definitions(-Wno-error=inline)
		else()
			add_definitions(-Wstrict-aliasing=2)
		endif()

		# no export symbols by default
		add_definitions(-fvisibility=hidden)
		add_definitions(-fvisibility-inlines-hidden)

		# stop in first error
		if(FIRST_ERROR)
			add_definitions(-Wfatal-errors)
		endif()

    endif()

	if (NOT DEFINED EXTRA_DEF)
		if(NOT WIN32)
		    include(CheckCXXCompilerFlag)
		    #CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z)
		    CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
		    CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
{'fraction_non_alphanumeric': 0.12226450999048526, 'fraction_numerical': 0.004519505233111323, 'mean_word_length': 5.275373134328358, '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': '6904638', 'n_tokens_mistral': 3374, 'n_tokens_neox': 3114, 'n_words': 447}