<commit_before>
project(Halide)
cmake_minimum_required(VERSION 2.8.12)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(LLVM_BIN "llvm3.6/bin/Debug/"
  CACHE PATH "Path to LLVM bin directory")
set(LLVM_LIB "llvm3.6/lib/Debug/"
  CACHE PATH "Path to LLVM lib directory")
set(LLVM_INCLUDE "llvm3.6/include/"
  CACHE PATH "Path to LLVM include directory")
set(LLVM_VERSION "36" CACHE STRING "First two digits of LLVM version (omitting '.')")

file(TO_NATIVE_PATH "${LLVM_BIN}/llvm-as${CMAKE_EXECUTABLE_SUFFIX}" LLVM_AS)
file(TO_NATIVE_PATH "${LLVM_BIN}/llvm-nm${CMAKE_EXECUTABLE_SUFFIX}" LLVM_NM)
file(TO_NATIVE_PATH "${LLVM_BIN}/clang${CMAKE_EXECUTABLE_SUFFIX}" CLANG)

# Check LLVM
function(check_dir VARNAME PATH)
  if (NOT IS_ABSOLUTE "${PATH}")
    message(FATAL_ERROR "\"${PATH}\" (${VARNAME}) must be an absolute path")
  endif()
  if (NOT IS_DIRECTORY "${PATH}")
    message(FATAL_ERROR "\"${PATH}\" (${VARNAME}) must be a directory")
  endif()
endfunction()
function(check_tool_exists NAME PATH)
  # Need to convert to CMake path so that backslashes don't get
  # interpreted as an escape.
  file(TO_CMAKE_PATH "${PATH}" TOOL_PATH)
  if (NOT EXISTS "${TOOL_PATH}")
    message(FATAL_ERROR "Tool ${NAME} not found at ${TOOL_PATH}")
  endif()
  message(STATUS "Using ${NAME} at ${TOOL_PATH}")
endfunction()

# Notify the user what paths and LLVM version we are using
message(STATUS "LLVM_BIN:${LLVM_BIN}")
message(STATUS "LLVM_LIB:${LLVM_LIB}")
message(STATUS "LLVM_INCLUDE:${LLVM_INCLUDE}")
message(STATUS "LLVM_VERSION:${LLVM_VERSION}")

# Check path to LLVM directories exist
check_dir(LLVM_BIN "${LLVM_BIN}")
check_dir(LLVM_LIB "${LLVM_LIB}")
# Include might be a list of directories if LLVM was built out of source
foreach( include_dir ${LLVM_INCLUDE})
  check_dir(LLVM_INCLUDE "${include_dir}")
endforeach()

# Check LLVM tools exist
check_tool_exists(llvm-as "${LLVM_AS}")
check_tool_exists(llvm-nm "${LLVM_NM}")
check_tool_exists(clang "${CLANG}")

# Check reported LLVM version
if (NOT "${LLVM_VERSION}" MATCHES "^[0-9][0-9]$")
  message(FATAL_ERROR "LLVM_VERSION not specified correctly. Must be <major><minor> E.g. LLVM 3.5 is \"35\"")
endif()
if (LLVM_VERSION LESS 35)
  message(FATAL_ERROR "LLVM version must be 3.5 or newer")
endif()

option(TARGET_NATIVE_CLIENT "Include Native Client" OFF)
option(TARGET_X86 "Include x86 target" ON)
option(TARGET_ARM "Include ARM target" ON)
option(TARGET_AARCH64 "Include AARCH64 (arm64) target" ON)
# Hexagon requires LLVM 3.9 or later.
if (NOT(LLVM_VERSION LESS 39))
  option(TARGET_HEXAGON "Include Hexagon target" ON)
else()
  option(TARGET_HEXAGON "Include Hexagon target" OFF)
endif()
option(TARGET_METAL "Include Metal target" ON)
option(TARGET_MIPS "Include MIPS target" ON)
option(TARGET_POWERPC "Include POWERPC target" ON)
option(TARGET_PTX "Include PTX target" ON)
option(TARGET_OPENCL "Include OpenCL-C target" ON)
option(TARGET_OPENGL "Include OpenGL/GLSL target" ON)
option(TARGET_OPENGLCOMPUTE "Include OpenGLCompute target" ON)
option(HALIDE_SHARED_LIBRARY "Build as a shared library" ON)
option(HALIDE_ENABLE_RTTI "Build with RTTI enabled" OFF)

function(halide_project name folder)
  add_executable("${name}" ${ARGN})
  target_link_libraries("${name}" PRIVATE Halide)
  target_include_directories("${name}" PRIVATE "${CMAKE_SOURCE_DIR}/src")
  set_target_properties("${name}" PROPERTIES FOLDER "${folder}")
  if (MSVC)
    set_target_properties("${name}" PROPERTIES LINK_FLAGS "/STACK:8388608,1048576")
    target_compile_definitions("${name}" PRIVATE _CRT_SECURE_NO_WARNINGS)
    target_link_libraries("${name}" PRIVATE Kernel32)
  endif()
endfunction(halide_project)

# Set warnings globally
option(WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
if (WARNINGS_AS_ERRORS)
    message(STATUS "WARNINGS_AS_ERRORS enabled")
else()
    message(STATUS "WARNINGS_AS_ERRORS disabled")
endif()

if (NOT MSVC)
    add_compile_options(-Wall
                        -Wno-unused-function<commit_msg>Add extra include for cmake<commit_after>
project(Halide)
cmake_minimum_required(VERSION 2.8.12)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(LLVM_BIN "llvm3.6/bin/Debug/"
  CACHE PATH "Path to LLVM bin directory")
set(LLVM_LIB "llvm3.6/lib/Debug/"
  CACHE PATH "Path to LLVM lib directory")
set(LLVM_INCLUDE "llvm3.6/include/"
  CACHE PATH "Path to LLVM include directory")
set(LLVM_VERSION "36" CACHE STRING "First two digits of LLVM version (omitting '.')")

file(TO_NATIVE_PATH "${LLVM_BIN}/llvm-as${CMAKE_EXECUTABLE_SUFFIX}" LLVM_AS)
file(TO_NATIVE_PATH "${LLVM_BIN}/llvm-nm${CMAKE_EXECUTABLE_SUFFIX}" LLVM_NM)
file(TO_NATIVE_PATH "${LLVM_BIN}/clang${CMAKE_EXECUTABLE_SUFFIX}" CLANG)

# Check LLVM
function(check_dir VARNAME PATH)
  if (NOT IS_ABSOLUTE "${PATH}")
    message(FATAL_ERROR "\"${PATH}\" (${VARNAME}) must be an absolute path")
  endif()
  if (NOT IS_DIRECTORY "${PATH}")
    message(FATAL_ERROR "\"${PATH}\" (${VARNAME}) must be a directory")
  endif()
endfunction()
function(check_tool_exists NAME PATH)
  # Need to convert to CMake path so that backslashes don't get
  # interpreted as an escape.
  file(TO_CMAKE_PATH "${PATH}" TOOL_PATH)
  if (NOT EXISTS "${TOOL_PATH}")
    message(FATAL_ERROR "Tool ${NAME} not found at ${TOOL_PATH}")
  endif()
  message(STATUS "Using ${NAME} at ${TOOL_PATH}")
endfunction()

# Notify the user what paths and LLVM version we are using
message(STATUS "LLVM_BIN:${LLVM_BIN}")
message(STATUS "LLVM_LIB:${LLVM_LIB}")
message(STATUS "LLVM_INCLUDE:${LLVM_INCLUDE}")
message(STATUS "LLVM_VERSION:${LLVM_VERSION}")

# Check path to LLVM directories exist
check_dir(LLVM_BIN "${LLVM_BIN}")
check_dir(LLVM_LIB "${LLVM_LIB}")
# Include might be a list of directories if LLVM was built out of source
foreach( include_dir ${LLVM_INCLUDE})
  check_dir(LLVM_INCLUDE "${include_dir}")
endforeach()

# Check LLVM tools exist
check_tool_exists(llvm-as "${LLVM_AS}")
check_tool_exists(llvm-nm "${LLVM_NM}")
check_tool_exists(clang "${CLANG}")

# Check reported LLVM version
if (NOT "${LLVM_VERSION}" MATCHES "^[0-9][0-9]$")
  message(FATAL_ERROR "LLVM_VERSION not specified correctly. Must be <major><minor> E.g. LLVM 3.5 is \"35\"")
endif()
if (LLVM_VERSION LESS 35)
  message(FATAL_ERROR "LLVM version must be 3.5 or newer")
endif()

option(TARGET_NATIVE_CLIENT "Include Native Client" OFF)
option(TARGET_X86 "Include x86 target" ON)
option(TARGET_ARM "Include ARM target" ON)
option(TARGET_AARCH64 "Include AARCH64 (arm64) target" ON)
# Hexagon requires LLVM 3.9 or later.
if (NOT(LLVM_VERSION LESS 39))
  option(TARGET_HEXAGON "Include Hexagon target" ON)
else()
  option(TARGET_HEXAGON "Include Hexagon target" OFF)
endif()
option(TARGET_METAL "Include Metal target" ON)
option(TARGET_MIPS "Include MIPS target" ON)
option(TARGET_POWERPC "Include POWERPC target" ON)
option(TARGET_PTX "Include PTX target" ON)
option(TARGET_OPENCL "Include OpenCL-C target" ON)
option(TARGET_OPENGL "Include OpenGL/GLSL target" ON)
option(TARGET_OPENGLCOMPUTE "Include OpenGLCompute target" ON)
option(HALIDE_SHARED_LIBRARY "Build as a shared library" ON)
option(HALIDE_ENABLE_RTTI "Build with RTTI enabled" OFF)

function(halide_project name folder)
  add_executable("${name}" ${ARGN})
  target_link_libraries("${name}" PRIVATE Halide)
  target_include_directories("${name}" PRIVATE "${CMAKE_SOURCE_DIR}/src")
  target_include_directories("${name}" PRIVATE "${CMAKE_SOURCE_DIR}/tools")
  set_target_properties("${name}" PROPERTIES FOLDER "${folder}")
  if (MSVC)
    set_target_properties("${name}" PROPERTIES LINK_FLAGS "/STACK:8388608,1048576")
    target_compile_definitions("${name}" PRIVATE _CRT_SECURE_NO_WARNINGS)
    target_link_libraries("${name}" PRIVATE Kernel32)
  endif()
endfunction(halide_project)

# Set warnings globally
option(WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
if (WARNINGS_AS_ERRORS)
    message(STATUS "WARNINGS_AS_ERRORS enabled")
else()
    message(STATUS "WARNINGS_AS_ERRORS disabled")
endif()

if (NOT MSVC)
    add_compile_options(-Wall
                        -Wno-unused-function
{'fraction_non_alphanumeric': 0.1249404478323011, 'fraction_numerical': 0.012863268222963315, 'mean_word_length': 6.571686203787196, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1013127', 'n_tokens_mistral': 3106, 'n_tokens_neox': 2969, 'n_words': 746}