<commit_before># FIXME: Work out which CMake version we actually need.
cmake_minimum_required(VERSION 3.5)

set(CMAKE_MACOSX_RPATH 1)

project(test_ffig)

if(MSVC)
  add_compile_options("/EHsc")
else()
  add_compile_options("-std=c++14")
endif()

if(NOT WIN32)
  set(CMAKE_CXX_FLAGS_ASAN "-g -fno-omit-frame-pointer -O0 -fsanitize=address")
  set(CMAKE_C_FLAGS_ASAN "-g -fno-omit-frame-pointer -O0 -fsanitize=address")
  set(CMAKE_EXE_LINKER_FLAGS_ASAN "-fsanitize=address")
  set(CMAKE_SHARED_LINKER_FLAGS_ASAN "-fsanitize=address")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(ffig)

include_directories(externals/catch2/single_include)
include_directories(externals/variant/include)
# FIXME: Use FFIG to get this path.
include_directories(ffig/include)

# Check that the found version of Python==3 on Windows.
# Trust the user if they have supplied their own.
# FIXME: Get to the bottom of the libclang/ctypes issues with Python2 on Windows.
if(NOT PYTHON_EXECUTABLE)
  find_package(PythonInterp REQUIRED)
  if(WIN32)
    execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; assert sys.version_info[0] == 3" 
                    RESULT_VARIABLE result 
                    OUTPUT_QUIET 
                    ERROR_QUIET)
    if(result)
      message(FATAL_ERROR "CMake failed: Python 3 is required for Windows.")
    endif()
  endif()
else()
  execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import this" 
                  RESULT_VARIABLE result 
                  OUTPUT_QUIET 
                  ERROR_QUIET)
  if(result)
    message(FATAL_ERROR "CMake failed: ${PYTHON_EXECUTABLE} cannot execute a simple Python script.")
  endif()
endif()

# FFIG won't work without Python and a C++ compiler so we can assume
# support for Python and C++ must exist.
set(all_ffig_bindings "PYTHON;CPP;CPP_MOCKS")

# Look for Go
# FIXME: Make this less hacky, ideally using a real CMake module
execute_process(COMMAND go version 
                RESULT_VARIABLE result 
                OUTPUT_QUIET 
                ERROR_QUIET)
if(result)
  set(Go_FOUND FALSE)
else()
  set(Go_FOUND True)
  list(APPEND all_ffig_bindings "GO")
endif()

# Look for Ruby
find_package(Ruby)
if(NOT Ruby_FOUND)
  message(STATUS "Ruby tests disabled: Ruby interpreter not found.")
else()
  list(APPEND all_ffig_bindings "RUBY")
endif()

# Look for Java
find_package(Java)
find_package(Java COMPONENTS Runtime)
find_package(Java COMPONENTS Development)
if(NOT Java_FOUND)
  message(STATUS "Java tests disabled: Java SDK not found.")
else()
  include(UseJava)
  # FIXME: append JAVA to all_ffig_bindings once we have a test.
endif()

# Look for Lua
# FIXME: Make this less hacky, ideally using a real CMake module
execute_process(COMMAND luajit -e "print('testing')" 
                RESULT_VARIABLE result 
                OUTPUT_QUIET <commit_msg>Handle missing Ruby FFI dependency with a warning message (#371)<commit_after># FIXME: Work out which CMake version we actually need.
cmake_minimum_required(VERSION 3.5)

set(CMAKE_MACOSX_RPATH 1)

project(test_ffig)

if(MSVC)
  add_compile_options("/EHsc")
else()
  add_compile_options("-std=c++14")
endif()

if(NOT WIN32)
  set(CMAKE_CXX_FLAGS_ASAN "-g -fno-omit-frame-pointer -O0 -fsanitize=address")
  set(CMAKE_C_FLAGS_ASAN "-g -fno-omit-frame-pointer -O0 -fsanitize=address")
  set(CMAKE_EXE_LINKER_FLAGS_ASAN "-fsanitize=address")
  set(CMAKE_SHARED_LINKER_FLAGS_ASAN "-fsanitize=address")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(ffig)

include_directories(externals/catch2/single_include)
include_directories(externals/variant/include)
# FIXME: Use FFIG to get this path.
include_directories(ffig/include)

# Check that the found version of Python==3 on Windows.
# Trust the user if they have supplied their own.
# FIXME: Get to the bottom of the libclang/ctypes issues with Python2 on Windows.
if(NOT PYTHON_EXECUTABLE)
  find_package(PythonInterp REQUIRED)
  if(WIN32)
    execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; assert sys.version_info[0] == 3" 
                    RESULT_VARIABLE result 
                    OUTPUT_QUIET 
                    ERROR_QUIET)
    if(result)
      message(FATAL_ERROR "CMake failed: Python 3 is required for Windows.")
    endif()
  endif()
else()
  execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import this" 
                  RESULT_VARIABLE result 
                  OUTPUT_QUIET 
                  ERROR_QUIET)
  if(result)
    message(FATAL_ERROR "CMake failed: ${PYTHON_EXECUTABLE} cannot execute a simple Python script.")
  endif()
endif()

# FFIG won't work without Python and a C++ compiler so we can assume
# support for Python and C++ must exist.
set(all_ffig_bindings "PYTHON;CPP;CPP_MOCKS")

# Look for Go
# FIXME: Make this less hacky, ideally using a real CMake module
execute_process(COMMAND go version 
                RESULT_VARIABLE result 
                OUTPUT_QUIET 
                ERROR_QUIET)
if(result)
  set(Go_FOUND FALSE)
else()
  set(Go_FOUND True)
  list(APPEND all_ffig_bindings "GO")
endif()

# Look for Ruby
find_package(Ruby)
if(NOT Ruby_FOUND)
  message(STATUS "Ruby tests disabled: Ruby interpreter not found.")
else()
  execute_process(COMMAND ${RUBY_EXECUTABLE} -rffi -e "puts FFI"
                  RESULT_VARIABLE result
                  OUTPUT_QUIET
                  ERROR_QUIET)
  if(result)
    message(WARNING "CMake failed: Ruby FFI dependencies is required.  Run 'gem install ffi' to install FFI dependency")
  else()
    list(APPEND all_ffig_bindings "RUBY")
  endif()
endif()

# Look for Java
find_package(Java)
find_package(Java COMPONENTS Runtime)
find_package(Java COMPONENTS Development)
if(NOT Java_FOUND)
  message(STATUS "Java tests disabled: Java SDK not found.")
else()
  include(UseJava)
  # FIXME: append JAVA to all_ffig_bindings once we have a test.
endif()

# Look for Lua
# FIXME: Make this less hacky, ideally using a real CMake module
execute_process(COMMAND luajit -e "print('testing')" 
                RESULT_VARIABLE result 
                OUTPUT_QUIET 
{'fraction_non_alphanumeric': 0.08659861705630556, 'fraction_numerical': 0.006091537701679289, 'mean_word_length': 3.6838858905165766, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3252082', 'n_tokens_mistral': 2129, 'n_tokens_neox': 2012, 'n_words': 558}