<commit_before>cmake_minimum_required(VERSION 2.8)

# create c libs
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wextra -Wfloat-equal -ansi")
add_library(tinyspline_shared SHARED tinyspline.c)
set_target_properties(tinyspline_shared PROPERTIES OUTPUT_NAME "tinyspline")
add_library(tinyspline_static STATIC tinyspline.c)
set_target_properties(tinyspline_static PROPERTIES OUTPUT_NAME "tinyspline")
install(TARGETS tinyspline_shared tinyspline_static
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
)
install(FILES tinyspline.h
  DESTINATION include
)

# create c++ libs
if(CMAKE_COMPILER_IS_GNUCXX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wfloat-equal -std=c++11")
  add_library(tinysplinecpp_shared SHARED tinyspline.c tinysplinecpp.cpp)
  set_target_properties(tinysplinecpp_shared PROPERTIES OUTPUT_NAME "tinysplinecpp")
  add_library(tinysplinecpp_static STATIC tinyspline.c tinysplinecpp.cpp)
  set_target_properties(tinysplinecpp_static PROPERTIES OUTPUT_NAME "tinysplinecpp")
  install(TARGETS tinysplinecpp_shared tinysplinecpp_static
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
  )
  install(FILES tinysplinecpp.h
    DESTINATION include
  )
endif()

# create proxies
find_package(SWIG 3.0.1)
if(SWIG_FOUND)
  include(${SWIG_USE_FILE})
  include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  # http://www.swig.org/Doc1.3/Java.html#compiling_dynamic
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
  # define the output dirs
  set(TS_GENERATED_PYTHON_DIR ${CMAKE_CURRENT_BINARY_DIR}/python)
  set(TS_GENERATED_JAVA_DIR ${CMAKE_CURRENT_BINARY_DIR}/so/tinyspline)
  set(TS_GENERATED_CSHARP_DIR ${CMAKE_CURRENT_BINARY_DIR}/csharp)

  # python
  find_package(PythonLibs)
  if (PYTHONLIBS_FOUND)
    include_directories(${PYTHON_INCLUDE_PATH})
    set_source_files_properties(tinysplinepython.i PROPERTIES CPLUSPLUS ON)
    if (${PYTHONLIBS_VERSION_STRING} MATCHES "^3.")
      message(STATUS "Using Python 3 mode.")
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
      set(CMAKE_SWIG_FLAGS -py3 -O)
    else()
      message(STATUS "Using Python 2 mode.")
      set(CMAKE_SWIG_FLAGS -O)
    endif()
    set(CMAKE_SWIG_OUTDIR ${TS_GENERATED_PYTHON_DIR})
    swig_add_module(tinysplinepython python tinysplinepython.i tinyspline.c tinysplinecpp.cpp)
    swig_link_libraries(tinysplinepython ${PYTHON_LIBRARIES})
    # for some reason the generated make target for python is _tinysplinepython
    add_custom_command(TARGET _tinysplinepython POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E copy ${TS_GENERATED_PYTHON_DIR}/tinysplinepython.py
      ${CMAKE_CURRENT_BINARY_DIR}/tinyspline.py
    )
    install(TARGETS _tinysplinepython
      LIBRARY DESTINATION lib
    )
  endif()

  # java
  find_package(JNI)
  if(JNI_FOUND)
    include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})<commit_msg>added the ability to set environment variables for python<commit_after>cmake_minimum_required(VERSION 2.8)

# create c libs
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wextra -Wfloat-equal -ansi")
add_library(tinyspline_shared SHARED tinyspline.c)
set_target_properties(tinyspline_shared PROPERTIES OUTPUT_NAME "tinyspline")
add_library(tinyspline_static STATIC tinyspline.c)
set_target_properties(tinyspline_static PROPERTIES OUTPUT_NAME "tinyspline")
install(TARGETS tinyspline_shared tinyspline_static
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
)
install(FILES tinyspline.h
  DESTINATION include
)

# create c++ libs
if(CMAKE_COMPILER_IS_GNUCXX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wfloat-equal -std=c++11")
  add_library(tinysplinecpp_shared SHARED tinyspline.c tinysplinecpp.cpp)
  set_target_properties(tinysplinecpp_shared PROPERTIES OUTPUT_NAME "tinysplinecpp")
  add_library(tinysplinecpp_static STATIC tinyspline.c tinysplinecpp.cpp)
  set_target_properties(tinysplinecpp_static PROPERTIES OUTPUT_NAME "tinysplinecpp")
  install(TARGETS tinysplinecpp_shared tinysplinecpp_static
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
  )
  install(FILES tinysplinecpp.h
    DESTINATION include
  )
endif()

# create proxies
find_package(SWIG 3.0.1)
if(SWIG_FOUND)
  include(${SWIG_USE_FILE})
  include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  # http://www.swig.org/Doc1.3/Java.html#compiling_dynamic
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
  # define the output dirs
  set(TS_GENERATED_PYTHON_DIR ${CMAKE_CURRENT_BINARY_DIR}/python)
  set(TS_GENERATED_JAVA_DIR ${CMAKE_CURRENT_BINARY_DIR}/so/tinyspline)
  set(TS_GENERATED_CSHARP_DIR ${CMAKE_CURRENT_BINARY_DIR}/csharp)

  # python
  if(DEFINED ENV{PYTHON_LIBRARY} AND DEFINED ENV{PYTHON_INCLUDE_DIR})
    message(STATUS "Using environment variables PYTHON_LIBRARY and PYTHON_INCLUDE_DIR")
    set(PYTHON_LIBRARY $ENV{PYTHON_LIBRARY})
    set(PYTHON_INCLUDE_DIR $ENV{PYTHON_INCLUDE_DIR})
  endif()
  find_package(PythonLibs)
  if (PYTHONLIBS_FOUND)
    include_directories(${PYTHON_INCLUDE_DIRS})
    set_source_files_properties(tinysplinepython.i PROPERTIES CPLUSPLUS ON)
    if (${PYTHONLIBS_VERSION_STRING} MATCHES "^3.")
      message(STATUS "Using Python 3 mode.")
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
      set(CMAKE_SWIG_FLAGS -py3 -O)
    else()
      message(STATUS "Using Python 2 mode.")
      set(CMAKE_SWIG_FLAGS -O)
    endif()
    set(CMAKE_SWIG_OUTDIR ${TS_GENERATED_PYTHON_DIR})
    swig_add_module(tinysplinepython python tinysplinepython.i tinyspline.c tinysplinecpp.cpp)
    swig_link_libraries(tinysplinepython ${PYTHON_LIBRARIES})
    # for some reason the generated make target for python is _tinysplinepython
    add_custom_command(TARGET _tinysplinepython POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E copy ${TS_GENERATED_PYTHON_DIR}/tinysplinepython.py
      ${CMAKE_CURRENT_BINARY_DIR}/tinyspline.py
    )
    install(TARGETS _tinysplinepython
      LIBRARY DESTINATION lib
    )
  endif()

  # java
  find_package(JNI)
  if(JNI_FOUND)
    include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
{'fraction_non_alphanumeric': 0.0866018198933166, 'fraction_numerical': 0.004392845936617509, 'mean_word_length': 5.914316702819956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1321027', 'n_tokens_mistral': 2595, 'n_tokens_neox': 2406, 'n_words': 384}