+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
+ ${PROJECT_SOURCE_DIR}/src/intel_galileo_rev_d.c
+ ${PROJECT_SOURCE_DIR}/src/intel_galileo_rev_g.c
+ ${PROJECT_SOURCE_DIR}/src/intel_edison_fab_c.c
+ ${PROJECT_SOURCE_DIR}/src/intel_de3815.c
+ ${PROJECT_SOURCE_DIR}/src/intel_minnow_max.c
+)
+
+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 lib)
+
+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 ()