1 set (mraa_LIB_INCLUDE_DIRS
2 ${PROJECT_SOURCE_DIR}/api
3 ${PROJECT_SOURCE_DIR}/api/mraa
4 ${PROJECT_SOURCE_DIR}/include
8 ${mraa_LIB_INCLUDE_DIRS}
11 set (mraa_LIB_SRCS_NOAUTO
12 ${PROJECT_SOURCE_DIR}/src/mraa.c
13 ${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
14 ${PROJECT_SOURCE_DIR}/src/i2c/i2c.c
15 ${PROJECT_SOURCE_DIR}/src/pwm/pwm.c
16 ${PROJECT_SOURCE_DIR}/src/spi/spi.c
17 ${PROJECT_SOURCE_DIR}/src/aio/aio.c
18 ${PROJECT_SOURCE_DIR}/src/uart/uart.c
21 set (mraa_LIB_X86_SRCS_NOAUTO
22 ${PROJECT_SOURCE_DIR}/src/x86/x86.c
23 ${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_d.c
24 ${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_g.c
25 ${PROJECT_SOURCE_DIR}/src/x86/intel_edison_fab_c.c
26 ${PROJECT_SOURCE_DIR}/src/x86/intel_de3815.c
27 ${PROJECT_SOURCE_DIR}/src/x86/intel_nuc5.c
28 ${PROJECT_SOURCE_DIR}/src/x86/intel_minnow_max.c
31 set (mraa_LIB_ARM_SRCS_NOAUTO
32 ${PROJECT_SOURCE_DIR}/src/arm/arm.c
33 ${PROJECT_SOURCE_DIR}/src/arm/raspberry_pi.c
34 ${PROJECT_SOURCE_DIR}/src/arm/beaglebone.c
35 ${PROJECT_SOURCE_DIR}/src/arm/banana.c
38 set (mraa_LIBS ${CMAKE_THREAD_LIBS_INIT})
42 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1")
47 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1")
52 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
55 if (${LIBFTD2XX_FOUND})
56 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDID2XX=1")
57 set (mraa_LIBS ${mraa_LIBS} ${LIBFTD2XX_LIBRARIES})
59 message (WARNING " - Enabled FTDID2xx support but library not found")
66 ${mraa_LIB_PLAT_SRCS_NOAUTO}
67 # autogenerated version file
68 ${CMAKE_CURRENT_BINARY_DIR}/version.c
71 set (mraa_LIB_GLOB_HEADERS
72 ${PROJECT_SOURCE_DIR}/api/mraa.h
73 ${PROJECT_SOURCE_DIR}/api/mraa.hpp
76 add_library (mraa SHARED ${mraa_LIB_SRCS})
79 target_link_libraries (mraa ${mraa_LIBS})
81 set_target_properties(
84 SOVERSION ${mraa_VERSION_MAJOR}
85 VERSION ${mraa_VERSION_STRING}
87 install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION include/)
88 install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION include/mraa)
90 macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
91 configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
92 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
93 endmacro (mraa_CREATE_INSTALL_PKGCONFIG)
94 mraa_create_install_pkgconfig (mraa.pc lib${LIB_SUFFIX}/pkgconfig)
96 install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR})
99 set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
100 set (DOCCLASSES aio gpio i2c pwm spi uart)
102 foreach (_file ${DOCCLASSES})
103 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
104 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
105 ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
106 ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
107 DEPENDS ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
109 add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
110 add_dependencies (${_file}class_doc_i doc)
113 set (DOCFILES common ${DOCCLASSES})
114 foreach (_file ${DOCFILES})
115 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
116 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
117 ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
118 ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
119 DEPENDS ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
121 add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
122 add_dependencies (${_file}doc_i doc)
125 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i
126 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
127 ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
128 ${CMAKE_CURRENT_BINARY_DIR}//common_hpp_doc.i
129 DEPENDS ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
131 add_custom_target (common_hpp_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i)
132 add_dependencies (common_hpp_doc_i doc)
138 include (${SWIG_USE_FILE})
139 set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
142 add_subdirectory (python)
145 add_subdirectory (java)
148 if (SWIG_VERSION VERSION_GREATER 3.0.4)
149 add_subdirectory (javascript)
151 message ("WARN - SWIG is ${SWIG_VERSION}. Please upgrade to 3.0.5+ to build nodejs addon")