<commit_before>cmake_minimum_required(VERSION 2.8)

project(Criterion C)

set(MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
set(LIBCSPTR_DISABLE_TESTS ON)
set(LIBCSPTR_DISABLE_COVERALLS ON)

# Content options

option(THEORIES "Activate the support for theories" ON)

# Initialization

include(Submodules)
include(Capabilities)

if (MSVC)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
endif ()

add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)

include(ExternalProject)
include(CMakeParseArguments)

function (add_cmake_subproject _NAME)
  set (options)
  set (oneValueArgs GIT PATH PREFIX)
  set (multiValueArgs OPTS)
  cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

  if (NOT "${ARGS_PREFIX}" STREQUAL "")
    set (install_prefix ${CMAKE_BINARY_DIR}/external/${ARGS_PREFIX})
  else ()
    set (install_prefix ${CMAKE_BINARY_DIR}/external)
  endif ()

  if (NOT "${ARGS_GIT}" STREQUAL "")
    string(REPLACE "#" ";" git_opts ${ARGS_GIT})
    list(LENGTH ${git_opts} git_opts_len)
    list(GET 0 repo)
    set (epa_opts GIT_REPOSITORY "${repo}")
    if (git_opts_len GREATER 1)
      list(GET 1 object)
      set (epa_opts ${epa_opts} GIT_TAG "${object}")
    endif ()
  elseif (NOT "${ARGS_PATH}" STREQUAL "")
      set (epa_opts SOURCE_DIR "${CMAKE_SOURCE_DIR}/${ARGS_PATH}")
  endif ()

  externalproject_add(
    ${_NAME}
    ${epa_opts}

    BINARY_DIR "${CMAKE_BINARY_DIR}/${_NAME}"

    CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
      -DCMAKE_INSTALL_PREFIX=${install_prefix}
      -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
      ${ARGS_OPTS}
    BUILD_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}"
    INSTALL_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}" --target install
  )
endfunction ()

include_directories(${CMAKE_BINARY_DIR}/external/include)
link_directories(${CMAKE_BINARY_DIR}/external/lib)

if (THEORIES)
  add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
  include_directories(dependencies/dyncall/dyncall/)
endif ()

include_directories(SYSTEM
  /usr/local/include
  /usr/include/GNUstep
)

if (MSVC)
  add_cmake_subproject(nanomsg-patched
    PATH dependencies/nanomsg-patched
    OPTS "-DNN_TESTS=OFF")

else ()

  include(ExternalProject)

  externalproject_add(
      nanomsg
      SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/nanomsg-patched"
      PREFIX "${CMAKE_CURRENT_BINARY_DIR}/nanomsg-patched"

      UPDATE_COMMAND <SOURCE_DIR>/autogen.sh
      CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
      BUILD_COMMAND make -j4
      INSTALL_COMMAND make install
  )

  externalproject_get_property(nanomsg install_dir)
  set(NANOMSG_INSTALL_DIR "${install_dir}")<commit_msg>Fixed nanomsg not being picked up as cmake dependency<commit_after>cmake_minimum_required(VERSION 2.8)

project(Criterion C)

set(MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
set(LIBCSPTR_DISABLE_TESTS ON)
set(LIBCSPTR_DISABLE_COVERALLS ON)

# Content options

option(THEORIES "Activate the support for theories" ON)

# Initialization

include(Submodules)
include(Capabilities)

if (MSVC)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
endif ()

add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)

include(ExternalProject)
include(CMakeParseArguments)

function (add_cmake_subproject _NAME)
  set (options)
  set (oneValueArgs GIT PATH PREFIX)
  set (multiValueArgs OPTS)
  cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

  if (NOT "${ARGS_PREFIX}" STREQUAL "")
    set (install_prefix ${CMAKE_BINARY_DIR}/external/${ARGS_PREFIX})
  else ()
    set (install_prefix ${CMAKE_BINARY_DIR}/external)
  endif ()

  if (NOT "${ARGS_GIT}" STREQUAL "")
    string(REPLACE "#" ";" git_opts ${ARGS_GIT})
    list(LENGTH ${git_opts} git_opts_len)
    list(GET 0 repo)
    set (epa_opts GIT_REPOSITORY "${repo}")
    if (git_opts_len GREATER 1)
      list(GET 1 object)
      set (epa_opts ${epa_opts} GIT_TAG "${object}")
    endif ()
  elseif (NOT "${ARGS_PATH}" STREQUAL "")
      set (epa_opts SOURCE_DIR "${CMAKE_SOURCE_DIR}/${ARGS_PATH}")
  endif ()

  externalproject_add(
    ${_NAME}
    ${epa_opts}

    BINARY_DIR "${CMAKE_BINARY_DIR}/${_NAME}"

    CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
      -DCMAKE_INSTALL_PREFIX=${install_prefix}
      -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
      ${ARGS_OPTS}
    BUILD_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}"
    INSTALL_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}" --target install
  )
endfunction ()

include_directories(${CMAKE_BINARY_DIR}/external/include)
link_directories(${CMAKE_BINARY_DIR}/external/lib)

if (THEORIES)
  add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
  include_directories(dependencies/dyncall/dyncall/)
endif ()

include_directories(SYSTEM
  /usr/local/include
  /usr/include/GNUstep
)

if (MSVC)
  add_cmake_subproject(nanomsg
    PATH dependencies/nanomsg-patched
    OPTS "-DNN_TESTS=OFF")

else ()

  include(ExternalProject)

  externalproject_add(
      nanomsg
      SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/nanomsg-patched"
      PREFIX "${CMAKE_CURRENT_BINARY_DIR}/nanomsg-patched"

      UPDATE_COMMAND <SOURCE_DIR>/autogen.sh
      CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
      BUILD_COMMAND make -j4
      INSTALL_COMMAND make install
  )

  externalproject_get_property(nanomsg install_dir)
  set(NANOMSG_INSTALL_DIR "${install_dir}")
{'fraction_non_alphanumeric': 0.1210881934566145, 'fraction_numerical': 0.0024893314366998577, 'mean_word_length': 5.236141906873614, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1248369', 'n_tokens_mistral': 2103, 'n_tokens_neox': 2000, 'n_words': 339}