<commit_before># Allow to easily add flags for C and C++
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)

function(add_c_compiler_flag)
	foreach(f ${ARGN})
		CHECK_C_COMPILER_FLAG(${f} FLAG_IS_SUPPORTED)
		if(FLAG_IS_SUPPORTED)
			string(APPEND CMAKE_C_FLAGS " ${f}")
		endif()
	endforeach()
	set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} PARENT_SCOPE)
endfunction()

function(add_cxx_compiler_flag)
	foreach(f ${ARGN})
		CHECK_CXX_COMPILER_FLAG(${f} FLAG_IS_SUPPORTED)
		if(FLAG_IS_SUPPORTED)
			string(APPEND CMAKE_CXX_FLAGS " ${f}")
		endif()
	endforeach()
	set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} PARENT_SCOPE)
endfunction()

macro(add_compiler_flag)
	add_c_compiler_flag(${ARGN})
	add_cxx_compiler_flag(${ARGN})
endmacro()

macro(remove_compiler_flags)
	if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
		string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
		set(BUILD_TYPE_CXX_FLAGS "CMAKE_CXX_FLAGS_${BUILD_TYPE}")
		set(BUILD_TYPE_C_FLAGS "CMAKE_C_FLAGS_${BUILD_TYPE}")
	endif()
	
	foreach(f ${ARGN})
		string(REGEX REPLACE "${f}( |$)" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
		string(REGEX REPLACE "${f}( |$)" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
		if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
			string(REGEX REPLACE "${f}( |$)" "" ${BUILD_TYPE_CXX_FLAGS} "${${BUILD_TYPE_CXX_FLAGS}}")
			string(REGEX REPLACE "${f}( |$)" "" ${BUILD_TYPE_C_FLAGS} "${${BUILD_TYPE_C_FLAGS}}")
		endif()
	endforeach()
endmacro()

# Note that CMake does not provide any facility to check that a linker flag is
# supported by the compiler, but most linker will just drop any unsupported flag
# (eventually with a warning).
function(add_linker_flag)
	foreach(f ${ARGN})
		string(APPEND CMAKE_EXE_LINKER_FLAGS " ${f}")
	endforeach()
	set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} PARENT_SCOPE)
endfunction()<commit_msg>[CMAKE] Split remove_compiler_flags into C and CXX variants<commit_after># Allow to easily add flags for C and C++
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)

function(add_c_compiler_flag)
	foreach(f ${ARGN})
		CHECK_C_COMPILER_FLAG(${f} FLAG_IS_SUPPORTED)
		if(FLAG_IS_SUPPORTED)
			string(APPEND CMAKE_C_FLAGS " ${f}")
		endif()
	endforeach()
	set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} PARENT_SCOPE)
endfunction()

function(add_cxx_compiler_flag)
	foreach(f ${ARGN})
		CHECK_CXX_COMPILER_FLAG(${f} FLAG_IS_SUPPORTED)
		if(FLAG_IS_SUPPORTED)
			string(APPEND CMAKE_CXX_FLAGS " ${f}")
		endif()
	endforeach()
	set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} PARENT_SCOPE)
endfunction()

macro(add_compiler_flag)
	add_c_compiler_flag(${ARGN})
	add_cxx_compiler_flag(${ARGN})
endmacro()

macro(remove_c_compiler_flags)
	if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
		string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
		set(BUILD_TYPE_C_FLAGS "CMAKE_C_FLAGS_${BUILD_TYPE}")
	endif()
	
	foreach(f ${ARGN})
		string(REGEX REPLACE "${f}( |$)" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
		if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
			string(REGEX REPLACE "${f}( |$)" "" ${BUILD_TYPE_C_FLAGS} "${${BUILD_TYPE_C_FLAGS}}")
		endif()
	endforeach()
endmacro()

macro(remove_cxx_compiler_flags)
	if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
		string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
		set(BUILD_TYPE_CXX_FLAGS "CMAKE_CXX_FLAGS_${BUILD_TYPE}")
	endif()
	
	foreach(f ${ARGN})
		string(REGEX REPLACE "${f}( |$)" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
		if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
			string(REGEX REPLACE "${f}( |$)" "" ${BUILD_TYPE_CXX_FLAGS} "${${BUILD_TYPE_CXX_FLAGS}}")
		endif()
	endforeach()
endmacro()

macro(remove_compiler_flags)
	remove_c_compiler_flags(${ARGN})
	remove_cxx_compiler_flags(${ARGN})
endmacro()

# Note that CMake does not provide any facility to check that a linker flag is
# supported by the compiler, but most linker will just drop any unsupported flag
# (eventually with a warning).
function(add_linker_flag)
	foreach(f ${ARGN})
		string(APPEND CMAKE_EXE_LINKER_FLAGS " ${f}")
	endforeach()
	set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} PARENT_SCOPE)
endfunction()
{'fraction_non_alphanumeric': 0.1408874404612685, 'fraction_numerical': 0.0, 'mean_word_length': 7.673913043478261, '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': '5546651', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1543, 'n_words': 284}