<commit_before>set (mraa_LIB_INCLUDE_DIRS
  ${PROJECT_SOURCE_DIR}/api
  ${PROJECT_SOURCE_DIR}/api/mraa
  ${PROJECT_SOURCE_DIR}/include
)

include_directories(
  ${mraa_LIB_INCLUDE_DIRS}
)

set (mraa_LIB_SRCS_NOAUTO
  ${PROJECT_SOURCE_DIR}/src/mraa.c
  ${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
  ${PROJECT_SOURCE_DIR}/src/i2c/i2c.c
  ${PROJECT_SOURCE_DIR}/src/pwm/pwm.c
  ${PROJECT_SOURCE_DIR}/src/spi/spi.c
  ${PROJECT_SOURCE_DIR}/src/aio/aio.c
  ${PROJECT_SOURCE_DIR}/src/uart/uart.c
)

if (X86PLAT)
  add_subdirectory(x86)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1")
endif()

if (ARMPLAT)
  add_subdirectory(arm)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1")
endif()

set (mraa_LIB_SRCS
  ${mraa_LIB_SRCS_NOAUTO}
# autogenerated version file
  ${CMAKE_CURRENT_BINARY_DIR}/version.c
)

set (mraa_LIB_GLOB_HEADERS
  ${PROJECT_SOURCE_DIR}/api/mraa.h
  ${PROJECT_SOURCE_DIR}/api/mraa.hpp
)

add_library (mraa SHARED ${mraa_LIB_SRCS})
target_link_libraries (mraa ${CMAKE_THREAD_LIBS_INIT})

set_target_properties(
   mraa
   PROPERTIES
   SOVERSION ${mraa_VERSION_MAJOR}
   VERSION ${mraa_VERSION_STRING}
)
install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION include/)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION include/mraa)

macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
  configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro (mraa_CREATE_INSTALL_PKGCONFIG)
mraa_create_install_pkgconfig (mraa.pc lib${LIB_SUFFIX}/pkgconfig)

install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR})

if (DOXYGEN_FOUND)
  set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
  set (DOCCLASSES aio gpio i2c pwm spi uart)
  # CPP class headers
  foreach (_file ${DOCCLASSES})
    add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
      COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
        ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
        ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
      DEPENDS ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
    )
    add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
    add_dependencies (${_file}class_doc_i doc)
  endforeach ()
  # C header files
  set (DOCFILES common ${DOCCLASSES})
  foreach (_file ${DOCFILES})
    add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
      COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
        ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
        ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
      DEPENDS ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
    )
    add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
    add_dependencies (${_file}doc_i doc)
  endforeach ()
  # CPP common header
  add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i
    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
      ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
      ${CMAKE_CURRENT_BINARY_DIR}//common_hpp_doc.i
    DEPENDS ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
  )
  add_custom_target (common_hpp_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i)
  add_dependencies (common_hpp_doc_i doc)
endif ()

if (BUILDSWIG)
  find_package (SWIG)
  if (SWIG_FOUND)
    include (${SWIG_USE_FILE})
    set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")

    if (BUILDSWIGPYTHON)
      add_subdirectory (python)
    endif ()
    if (BUILDSWIGNODE)
      add_subdirectory (javascript)
    endif ()
  endif ()
endif ()<commit_msg>src/CMakeLists.txt: warn if swig is less than 3.0.5<commit_after>set (mraa_LIB_INCLUDE_DIRS
  ${PROJECT_SOURCE_DIR}/api
  ${PROJECT_SOURCE_DIR}/api/mraa
  ${PROJECT_SOURCE_DIR}/include
)

include_directories(
  ${mraa_LIB_INCLUDE_DIRS}
)

set (mraa_LIB_SRCS_NOAUTO
  ${PROJECT_SOURCE_DIR}/src/mraa.c
  ${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
  ${PROJECT_SOURCE_DIR}/src/i2c/i2c.c
  ${PROJECT_SOURCE_DIR}/src/pwm/pwm.c
  ${PROJECT_SOURCE_DIR}/src/spi/spi.c
  ${PROJECT_SOURCE_DIR}/src/aio/aio.c
  ${PROJECT_SOURCE_DIR}/src/uart/uart.c
)

if (X86PLAT)
  add_subdirectory(x86)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1")
endif()

if (ARMPLAT)
  add_subdirectory(arm)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1")
endif()

set (mraa_LIB_SRCS
  ${mraa_LIB_SRCS_NOAUTO}
# autogenerated version file
  ${CMAKE_CURRENT_BINARY_DIR}/version.c
)

set (mraa_LIB_GLOB_HEADERS
  ${PROJECT_SOURCE_DIR}/api/mraa.h
  ${PROJECT_SOURCE_DIR}/api/mraa.hpp
)

add_library (mraa SHARED ${mraa_LIB_SRCS})
target_link_libraries (mraa ${CMAKE_THREAD_LIBS_INIT})

set_target_properties(
   mraa
   PROPERTIES
   SOVERSION ${mraa_VERSION_MAJOR}
   VERSION ${mraa_VERSION_STRING}
)
install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION include/)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION include/mraa)

macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
  configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro (mraa_CREATE_INSTALL_PKGCONFIG)
mraa_create_install_pkgconfig (mraa.pc lib${LIB_SUFFIX}/pkgconfig)

install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR})

if (DOXYGEN_FOUND)
  set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
  set (DOCCLASSES aio gpio i2c pwm spi uart)
  # CPP class headers
  foreach (_file ${DOCCLASSES})
    add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
      COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
        ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
        ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
      DEPENDS ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
    )
    add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
    add_dependencies (${_file}class_doc_i doc)
  endforeach ()
  # C header files
  set (DOCFILES common ${DOCCLASSES})
  foreach (_file ${DOCFILES})
    add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
      COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
        ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
        ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
      DEPENDS ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
    )
    add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
    add_dependencies (${_file}doc_i doc)
  endforeach ()
  # CPP common header
  add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i
    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
      ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
      ${CMAKE_CURRENT_BINARY_DIR}//common_hpp_doc.i
    DEPENDS ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
  )
  add_custom_target (common_hpp_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i)
  add_dependencies (common_hpp_doc_i doc)
endif ()

if (BUILDSWIG)
  find_package (SWIG)
  if (SWIG_FOUND)
    include (${SWIG_USE_FILE})
    set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")

    if (BUILDSWIGPYTHON)
      add_subdirectory (python)
    endif ()
    if (BUILDSWIGNODE)
      if (SWIG_VERSION VERSION_GREATER 3.0.4)
        add_subdirectory (javascript)
      else ()
        message ("WARN - SWIG is ${SWIG_VERSION}. Please upgrade to 3.0.5+ to build nodejs addon")
      endif ()
    endif ()
  endif ()
endif ()
{'fraction_non_alphanumeric': 0.1189421573736321, 'fraction_numerical': 0.006904637832204273, 'mean_word_length': 5.3975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, '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': '6915767', 'n_tokens_mistral': 3273, 'n_tokens_neox': 3150, 'n_words': 428}