<commit_before>macro(read_config_header config_file)
	if(EXISTS ${config_file})
		FILE(READ ${config_file} SHOGUN_CONFIG)
	else()
		message(fatal_error "Could not locate config.h of shogun at: ${config_file}")
	endif()
endmacro()

function(is_set CONFIG_FILE FLAG)
	STRING(REGEX MATCH "\#define ${FLAG}" IS_SET_${FLAG} ${CONFIG_FILE})
	if (IS_SET_${FLAG})
		set(${FLAG} ON PARENT_SCOPE)
	else()
		set(${FLAG} OFF PARENT_SCOPE)
	endif()
endfunction()

function(get_excluded_meta_examples)
    read_config_header(${shogun_INCLUDE_DIR}/shogun/lib/config.h)
    is_set(${SHOGUN_CONFIG} HAVE_NLOPT)
    is_set(${SHOGUN_CONFIG} USE_GPL_SHOGUN)
    is_set(${SHOGUN_CONFIG} HAVE_LAPACK)
    is_set(${SHOGUN_CONFIG} USE_SVMLIGHT)

    IF(NOT HAVE_NLOPT)
        LIST(APPEND EXCLUDED_META_EXAMPLES
            gaussian_process/regression.sg
            )
    ENDIF()

	IF(NOT USE_GPL_SHOGUN)
		LIST(APPEND EXCLUDED_META_EXAMPLES
			multiclass/logistic_regression.sg
      statistical_testing/linear_time_maximum_mean_discrepancy.sg
      statistical_testing/quadratic_time_maximum_mean_discrepancy.sg
      gaussian_process/classifier.sg
      gaussian_process/regression.sg
      )
	ENDIF()

	IF(NOT HAVE_LAPACK)
		LIST(APPEND EXCLUDED_META_EXAMPLES
			)
	ENDIF()

	IF(NOT USE_SVMLIGHT)
		LIST(APPEND EXCLUDED_META_EXAMPLES
			regression/multiple_kernel_learning.sg
			binary/multiple_kernel_learning.sg
		)
	ENDIF()
  LIST(REMOVE_DUPLICATES EXCLUDED_META_EXAMPLES)
    SET(EXCLUDED_META_EXAMPLES ${EXCLUDED_META_EXAMPLES} PARENT_SCOPE)

endfunction()

# Remove meta example that cannot be built because of missing dependencies
function(find_meta_examples)

	FILE(GLOB_RECURSE META_EXAMPLE_LISTINGS ${CMAKE_SOURCE_DIR}/examples/meta/src/*.sg)
    get_excluded_meta_examples()

    FOREACH(META_EXAMPLE ${EXCLUDED_META_EXAMPLES})
        SET(EXCLUDED_EXAMPLE_FNAME ${CMAKE_SOURCE_DIR}/examples/meta/src/${META_EXAMPLE})
        LIST(FIND META_EXAMPLE_LISTINGS ${EXCLUDED_EXAMPLE_FNAME} HAS_EXAMPLE)
 
        IF(HAS_EXAMPLE EQUAL -1)
            MESSAGE(FATAL_ERROR "Guarded meta example ${META_EXAMPLE} does not exist.")
        ENDIF()
        LIST(REMOVE_ITEM META_EXAMPLE_LISTINGS ${EXCLUDED_EXAMPLE_FNAME})<commit_msg>avoid remove duplicates list call on empty list<commit_after>macro(read_config_header config_file)
	if(EXISTS ${config_file})
		FILE(READ ${config_file} SHOGUN_CONFIG)
	else()
		message(fatal_error "Could not locate config.h of shogun at: ${config_file}")
	endif()
endmacro()

function(is_set CONFIG_FILE FLAG)
	STRING(REGEX MATCH "\#define ${FLAG}" IS_SET_${FLAG} ${CONFIG_FILE})
	if (IS_SET_${FLAG})
		set(${FLAG} ON PARENT_SCOPE)
	else()
		set(${FLAG} OFF PARENT_SCOPE)
	endif()
endfunction()

function(get_excluded_meta_examples)
    read_config_header(${shogun_INCLUDE_DIR}/shogun/lib/config.h)
    is_set(${SHOGUN_CONFIG} HAVE_NLOPT)
    is_set(${SHOGUN_CONFIG} USE_GPL_SHOGUN)
    is_set(${SHOGUN_CONFIG} HAVE_LAPACK)
    is_set(${SHOGUN_CONFIG} USE_SVMLIGHT)

    IF(NOT HAVE_NLOPT)
        LIST(APPEND EXCLUDED_META_EXAMPLES
            gaussian_process/regression.sg
            )
    ENDIF()

	IF(NOT USE_GPL_SHOGUN)
		LIST(APPEND EXCLUDED_META_EXAMPLES
			multiclass/logistic_regression.sg
      statistical_testing/linear_time_maximum_mean_discrepancy.sg
      statistical_testing/quadratic_time_maximum_mean_discrepancy.sg
      gaussian_process/classifier.sg
      gaussian_process/regression.sg
      )
	ENDIF()

	IF(NOT HAVE_LAPACK)
		LIST(APPEND EXCLUDED_META_EXAMPLES
			)
	ENDIF()

	IF(NOT USE_SVMLIGHT)
		LIST(APPEND EXCLUDED_META_EXAMPLES
			regression/multiple_kernel_learning.sg
			binary/multiple_kernel_learning.sg
		)
	ENDIF()
  
  # remove double entries to avoid errors due to "double" removing
  LIST(LENGTH EXCLUDED_META_EXAMPLES NUM_EXCLUDED)
  IF(NUM_EXCLUDED GREATER 0)
    LIST(REMOVE_DUPLICATES EXCLUDED_META_EXAMPLES)
  ENDIF()
  
  SET(EXCLUDED_META_EXAMPLES ${EXCLUDED_META_EXAMPLES} PARENT_SCOPE)

endfunction()

# Remove meta example that cannot be built because of missing dependencies
function(find_meta_examples)

	FILE(GLOB_RECURSE META_EXAMPLE_LISTINGS ${CMAKE_SOURCE_DIR}/examples/meta/src/*.sg)
    get_excluded_meta_examples()

    FOREACH(META_EXAMPLE ${EXCLUDED_META_EXAMPLES})
        SET(EXCLUDED_EXAMPLE_FNAME ${CMAKE_SOURCE_DIR}/examples/meta/src/${META_EXAMPLE})
        LIST(FIND META_EXAMPLE_LISTINGS ${EXCLUDED_EXAMPLE_FNAME} HAS_EXAMPLE)
 
        IF(HAS_EXAMPLE EQUAL -1)
            MESSAGE(FATAL_ERROR "Guarded meta example ${META_EXAMPLE} does not exist.")
        ENDIF()
        LIST(REMOVE_ITEM META_EXAMPLE_LISTINGS ${EXCLUDED_EXAMPLE_FNAME})
{'fraction_non_alphanumeric': 0.09020116807268008, 'fraction_numerical': 0.0006489292667099286, 'mean_word_length': 4.943444730077121, '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': '5188850', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1732, 'n_words': 269}