<commit_before>INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)

#
# Perform the VXL specific test with status output
#
# Sets the TEST to 1 if the corresponding program could be compiled
# and linked
#

MACRO(PERFORM_CMAKE_TEST FILE TEST)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${TEST} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${TEST}")
    # Perform test
    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
        "-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(TEST_ADD_LIBRARIES
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    MESSAGE(STATUS "Performing Test ${TEST}")

    TRY_COMPILE(${TEST}
                ${CMAKE_BINARY_DIR}
                ${vxl_config_SOURCE_DIR}/${FILE}
                CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
                "${TEST_ADD_LIBRARIES}"
                OUTPUT_VARIABLE OUTPUT)
    IF(${TEST})
      SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION}")
      MESSAGE(STATUS "Performing Test ${TEST} - Success")
    ELSE(${TEST})
      MESSAGE(STATUS "Performing Test ${TEST} - Failed")
      SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION}")
      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                 "Performing Test ${TEST} failed with the following output:\n"
                 "${OUTPUT}\n")
    ENDIF(${TEST})
  ELSE()
    # Have result
    #FOREACH(tst ${TEST})
    #  MESSAGE("Test ${TEST} resulted in ${${tst}}")
    #ENDFOREACH(tst ${TEST})
  ENDIF()
ENDMACRO(PERFORM_CMAKE_TEST FILE TEST)

#
# Perform a custom VXL try compile test with status output
#
# DIR is the directory containing the test project
#
# Sets the TEST to 1 if the corresponding program could be compiled
# and linked
#

MACRO(PERFORM_CMAKE_TEST_CUSTOM DIR TEST)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${TEST} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${TEST}")
    # Perform test
    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
        "-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(TEST_ADD_LIBRARIES
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    MESSAGE(STATUS "Performing Test ${TEST}")

    TRY_COMPILE(${TEST}
                ${CMAKE_BINARY_DIR}/config/${DIR}
                ${vxl_config_SOURCE_DIR}/${DIR}
                ${TEST}
                CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
                -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
                -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
                "${TEST_ADD_LIBRARIES}"
                OUTPUT_VARIABLE OUTPUT)
    IF(${TEST})
      SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION}")
      MESSAGE(STATUS "Performing Test ${TEST} - Success")
    ELSE(${TEST})
      MESSAGE(STATUS "Performing Test ${TEST} - Failed")
      SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION}")
      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                 "Performing Test ${TEST} failed with the following output:\n"
                 "${OUTPUT}\n")
    ENDIF(${TEST})
  ENDIF()
  FILE(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/config/${DIR})
ENDMACRO(PERFORM_CMAKE_TEST_CUSTOM DIR TEST)

#
# Perform the VXL specific try-run test with status output
#
# Sets TEST to 1 if the corresponding program compiles, links, run,
# and returns 0 (indicating success).
#

MACRO(PERFORM_CMAKE_TEST_RUN FILE TEST)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${TEST} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${TEST}")
    # Perform test
    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
        "-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(TEST_ADD_LIBRARIES
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    MESSAGE(STATUS "Performing Test ${TEST}")

    TRY_RUN(${TEST} ${TEST}_COMPILED
            ${CMAKE_BINARY_DIR}
            ${vxl_config_SOURCE_DIR}/${FILE}
            CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
            "${TEST_ADD_LIBRARIES}"
            OUTPUT_VARIABLE OUTPUT)
    IF(${TEST}_COMPILED)
      IF(${TEST})
        MESSAGE(STATUS "Performing Test ${TEST} - Failed")
        SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION} (failed to run)")
        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                   "Performing Test ${TEST} failed with the following output:\n"
                   "${OUTPUT}\n")
      ELSE(${TEST})
        SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION} (successful run)")
        MESSAGE(STATUS "Performing Test ${TEST} - Success")
        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                   "Performing Test ${TEST} succeeded with the following output:\n"
                   "${OUTPUT}\n")
      ENDIF(${TEST})
    ELSE(${TEST}_COMPILED)
      MESSAGE(STATUS "Performing Try-Run Test ${TEST} - Test Compilation Failed")
      SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION} (failed to compile)")
      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                 "Performing Try-Run Test ${TEST} failed to compile with the following output:\n"
                 "${OUTPUT}\n")
    ENDIF(${TEST}_COMPILED)
  ELSE()
    # Have result
    #FOREACH(tst ${TEST})
    #  MESSAGE("Test ${TEST} resulted in ${${tst}}")
    #ENDFOREACH(tst ${TEST})
  ENDIF()
ENDMACRO(PERFORM_CMAKE_TEST_RUN FILE TEST)

#
# Check for include file and if not found, set variable to 0
#

MACRO(PERFORM_CHECK_HEADER FILE VARIABLE)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET(${VARIABLE})
  ENDIF( VXL_UPDATE_CONFIGURATION )
  CHECK_INCLUDE_FILE_CXX(${FILE} ${VARIABLE})
  IF("x${${VARIABLE}}" STREQUAL "x")
    SET(${VARIABLE} 0)
  ENDIF()
ENDMACRO(PERFORM_CHECK_HEADER FILE VARIABLE)

#
# Check value of variable and if true, set to VALUE_TRUE, otherwise to
# VALUE_FALSE
#

MACRO(SET_BOOL VAR VALUE_TRUE VALUE_FALSE)
  SET(SET_BOOL_VAR "${VAR}")
  IF(${SET_BOOL_VAR})
    SET(${VAR} ${VALUE_TRUE})
  ELSE(${SET_BOOL_VAR})
    SET(${VAR} ${VALUE_FALSE})
  ENDIF(${SET_BOOL_VAR})
ENDMACRO(SET_BOOL VAR VALUE_TRUE VALUE_FALSE)

#
# Set the variable to inverse of the given value
#

MACRO(SET_INVERT VAR VALUE)
  SET(SET_INVERT_VAR "${VALUE}")
  IF(SET_INVERT_VAR)
    SET(${VAR} "0")
  ELSE(SET_INVERT_VAR)
    SET(${VAR} "1")
  ENDIF(SET_INVERT_VAR)
ENDMACRO(SET_INVERT VAR VALUE)

#
# Check if the type exists (should really go to CMake/Modules)
#

MACRO(CHECK_TYPE_EXISTS TYPE FILES VARIABLE)
  IF( VXL_UPDATE_CONFIGURATION )
    SET( ${VARIABLE} "${VARIABLE}" )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${VARIABLE}")
    SET(CHECK_TYPE_EXISTS_CONTENT "/* */\n")
    SET(MACRO_CHECK_TYPE_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(CHECK_TYPE_EXISTS_LIBS
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    FOREACH(FILE ${FILES})
      SET(CHECK_TYPE_EXISTS_CONTENT
          "${CHECK_TYPE_EXISTS_CONTENT}#include <${FILE}>\n")
    ENDFOREACH(FILE)
    SET(CHECK_TYPE_EXISTS_CONTENT
        "${CHECK_TYPE_EXISTS_CONTENT}\nvoid cmakeRequireSymbol(${TYPE} dummy){(void)dummy;}\nint main()\n{return 0;\n}\n")

    FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeExists.cxx
         "${CHECK_TYPE_EXISTS_CONTENT}")

    MESSAGE(STATUS "Looking for ${TYPE}")<commit_msg>COMP: Fix one more vxl_config_macros check broken by refactoring<commit_after>INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)

#
# Perform the VXL specific test with status output
#
# Sets the TEST to 1 if the corresponding program could be compiled
# and linked
#

MACRO(PERFORM_CMAKE_TEST FILE TEST)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${TEST} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${TEST}")
    # Perform test
    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
        "-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(TEST_ADD_LIBRARIES
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    MESSAGE(STATUS "Performing Test ${TEST}")

    TRY_COMPILE(${TEST}
                ${CMAKE_BINARY_DIR}
                ${vxl_config_SOURCE_DIR}/${FILE}
                CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
                "${TEST_ADD_LIBRARIES}"
                OUTPUT_VARIABLE OUTPUT)
    IF(${TEST})
      SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION}")
      MESSAGE(STATUS "Performing Test ${TEST} - Success")
    ELSE(${TEST})
      MESSAGE(STATUS "Performing Test ${TEST} - Failed")
      SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION}")
      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                 "Performing Test ${TEST} failed with the following output:\n"
                 "${OUTPUT}\n")
    ENDIF(${TEST})
  ELSE()
    # Have result
    #FOREACH(tst ${TEST})
    #  MESSAGE("Test ${TEST} resulted in ${${tst}}")
    #ENDFOREACH(tst ${TEST})
  ENDIF()
ENDMACRO(PERFORM_CMAKE_TEST FILE TEST)

#
# Perform a custom VXL try compile test with status output
#
# DIR is the directory containing the test project
#
# Sets the TEST to 1 if the corresponding program could be compiled
# and linked
#

MACRO(PERFORM_CMAKE_TEST_CUSTOM DIR TEST)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${TEST} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${TEST}")
    # Perform test
    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
        "-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(TEST_ADD_LIBRARIES
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    MESSAGE(STATUS "Performing Test ${TEST}")

    TRY_COMPILE(${TEST}
                ${CMAKE_BINARY_DIR}/config/${DIR}
                ${vxl_config_SOURCE_DIR}/${DIR}
                ${TEST}
                CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
                -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
                -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
                "${TEST_ADD_LIBRARIES}"
                OUTPUT_VARIABLE OUTPUT)
    IF(${TEST})
      SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION}")
      MESSAGE(STATUS "Performing Test ${TEST} - Success")
    ELSE(${TEST})
      MESSAGE(STATUS "Performing Test ${TEST} - Failed")
      SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION}")
      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                 "Performing Test ${TEST} failed with the following output:\n"
                 "${OUTPUT}\n")
    ENDIF(${TEST})
  ENDIF()
  FILE(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/config/${DIR})
ENDMACRO(PERFORM_CMAKE_TEST_CUSTOM DIR TEST)

#
# Perform the VXL specific try-run test with status output
#
# Sets TEST to 1 if the corresponding program compiles, links, run,
# and returns 0 (indicating success).
#

MACRO(PERFORM_CMAKE_TEST_RUN FILE TEST)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${TEST} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${TEST}")
    # Perform test
    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
        "-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(TEST_ADD_LIBRARIES
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    MESSAGE(STATUS "Performing Test ${TEST}")

    TRY_RUN(${TEST} ${TEST}_COMPILED
            ${CMAKE_BINARY_DIR}
            ${vxl_config_SOURCE_DIR}/${FILE}
            CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
            "${TEST_ADD_LIBRARIES}"
            OUTPUT_VARIABLE OUTPUT)
    IF(${TEST}_COMPILED)
      IF(${TEST})
        MESSAGE(STATUS "Performing Test ${TEST} - Failed")
        SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION} (failed to run)")
        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                   "Performing Test ${TEST} failed with the following output:\n"
                   "${OUTPUT}\n")
      ELSE(${TEST})
        SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION} (successful run)")
        MESSAGE(STATUS "Performing Test ${TEST} - Success")
        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                   "Performing Test ${TEST} succeeded with the following output:\n"
                   "${OUTPUT}\n")
      ENDIF(${TEST})
    ELSE(${TEST}_COMPILED)
      MESSAGE(STATUS "Performing Try-Run Test ${TEST} - Test Compilation Failed")
      SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION} (failed to compile)")
      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
                 "Performing Try-Run Test ${TEST} failed to compile with the following output:\n"
                 "${OUTPUT}\n")
    ENDIF(${TEST}_COMPILED)
  ELSE()
    # Have result
    #FOREACH(tst ${TEST})
    #  MESSAGE("Test ${TEST} resulted in ${${tst}}")
    #ENDFOREACH(tst ${TEST})
  ENDIF()
ENDMACRO(PERFORM_CMAKE_TEST_RUN FILE TEST)

#
# Check for include file and if not found, set variable to 0
#

MACRO(PERFORM_CHECK_HEADER FILE VARIABLE)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET(${VARIABLE})
  ENDIF( VXL_UPDATE_CONFIGURATION )
  CHECK_INCLUDE_FILE_CXX(${FILE} ${VARIABLE})
  IF("x${${VARIABLE}}" STREQUAL "x")
    SET(${VARIABLE} 0)
  ENDIF()
ENDMACRO(PERFORM_CHECK_HEADER FILE VARIABLE)

#
# Check value of variable and if true, set to VALUE_TRUE, otherwise to
# VALUE_FALSE
#

MACRO(SET_BOOL VAR VALUE_TRUE VALUE_FALSE)
  SET(SET_BOOL_VAR "${VAR}")
  IF(${SET_BOOL_VAR})
    SET(${VAR} ${VALUE_TRUE})
  ELSE(${SET_BOOL_VAR})
    SET(${VAR} ${VALUE_FALSE})
  ENDIF(${SET_BOOL_VAR})
ENDMACRO(SET_BOOL VAR VALUE_TRUE VALUE_FALSE)

#
# Set the variable to inverse of the given value
#

MACRO(SET_INVERT VAR VALUE)
  SET(SET_INVERT_VAR "${VALUE}")
  IF(SET_INVERT_VAR)
    SET(${VAR} "0")
  ELSE(SET_INVERT_VAR)
    SET(${VAR} "1")
  ENDIF(SET_INVERT_VAR)
ENDMACRO(SET_INVERT VAR VALUE)

#
# Check if the type exists (should really go to CMake/Modules)
#

MACRO(CHECK_TYPE_EXISTS TYPE FILES VARIABLE)
  IF( VXL_UPDATE_CONFIGURATION )
    UNSET( ${VARIABLE} )
  ENDIF( VXL_UPDATE_CONFIGURATION )
  IF(NOT DEFINED "${VARIABLE}")
    SET(CHECK_TYPE_EXISTS_CONTENT "/* */\n")
    SET(MACRO_CHECK_TYPE_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
    IF(CMAKE_REQUIRED_LIBRARIES)
      SET(CHECK_TYPE_EXISTS_LIBS
          "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
    FOREACH(FILE ${FILES})
      SET(CHECK_TYPE_EXISTS_CONTENT
          "${CHECK_TYPE_EXISTS_CONTENT}#include <${FILE}>\n")
    ENDFOREACH(FILE)
    SET(CHECK_TYPE_EXISTS_CONTENT
        "${CHECK_TYPE_EXISTS_CONTENT}\nvoid cmakeRequireSymbol(${TYPE} dummy){(void)dummy;}\nint main()\n{return 0;\n}\n")

    FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeExists.cxx
         "${CHECK_TYPE_EXISTS_CONTENT}")

    MESSAGE(STATUS "Looking for ${TYPE}")
{'fraction_non_alphanumeric': 0.12326696892042842, 'fraction_numerical': 0.002102634864314344, 'mean_word_length': 3.5705705705705704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3404954', 'n_tokens_mistral': 5604, 'n_tokens_neox': 5293, 'n_words': 1048}