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
19 ${PROJECT_SOURCE_DIR}/src/iio/iio.c
22 set (mraa_LIB_X86_SRCS_NOAUTO
23 ${PROJECT_SOURCE_DIR}/src/x86/x86.c
24 ${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_d.c
25 ${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_g.c
26 ${PROJECT_SOURCE_DIR}/src/x86/intel_edison_fab_c.c
27 ${PROJECT_SOURCE_DIR}/src/x86/intel_de3815.c
28 ${PROJECT_SOURCE_DIR}/src/x86/intel_nuc5.c
29 ${PROJECT_SOURCE_DIR}/src/x86/intel_minnow_byt_compatible.c
30 ${PROJECT_SOURCE_DIR}/src/x86/intel_sofia_3gr.c
33 message (INFO " - Adding support for platform ${MRAAPLATFORMFORCE}")
35 #keywords in if statements are case sensitive
36 if (NOT ${MRAAPLATFORMFORCE} STREQUAL "ALL")
37 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dx${MRAAPLATFORMFORCE} -DMRAA_PLATFORM_FORCE=${MRAAPLATFORMFORCE}")
38 if (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_GALILEO_GEN2")
39 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_g.c)
40 elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_GALILEO_GEN1")
41 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_d.c)
42 elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_DE3815")
43 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_de3815.c)
44 elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_EDISON_FAB_C")
45 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_edison_fab_c.c)
46 elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_MINNOWBOARD_MAX")
47 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_minnow_byt_compatible.c)
48 elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_NUC5")
49 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_nuc5.c)
50 elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_SOFIA_3GR")
51 set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_sofia_3gr.c)
53 message (ERROR " - Unknown x86 platform enabled!")
56 message (INFO " - Adding support for all platforms")
59 set (mraa_LIB_ARM_SRCS_NOAUTO
60 ${PROJECT_SOURCE_DIR}/src/arm/arm.c
61 ${PROJECT_SOURCE_DIR}/src/arm/96boards.c
62 ${PROJECT_SOURCE_DIR}/src/arm/raspberry_pi.c
63 ${PROJECT_SOURCE_DIR}/src/arm/beaglebone.c
64 ${PROJECT_SOURCE_DIR}/src/arm/banana.c
67 set (mraa_LIBS ${CMAKE_THREAD_LIBS_INIT})
71 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1")
76 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1")
80 message (INFO " - Adding USB platforms")
81 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
84 if (${LIBFTD2XX_FOUND})
85 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDID2XX=1")
86 set (mraa_LIBS ${mraa_LIBS} ${LIBFTD2XX_LIBRARIES})
88 message (WARNING " - Enabled FTDID2xx support but library not found")
92 find_package (Ftd4222)
93 if (${LIBFT4222_FOUND})
94 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDI4222=1")
95 set (mraa_LIBS ${mraa_LIBS} ${LIBFT4222_LIBRARIES})
97 message (WARNING " - Enabled FTDI4222 support but library not found")
100 add_subdirectory(usb)
104 ${mraa_LIB_PLAT_SRCS_NOAUTO}
105 # autogenerated version file
106 ${CMAKE_CURRENT_BINARY_DIR}/version.c
109 set (mraa_LIB_GLOB_HEADERS
110 ${PROJECT_SOURCE_DIR}/api/mraa.h
111 ${PROJECT_SOURCE_DIR}/api/mraa.hpp
114 add_library (mraa SHARED ${mraa_LIB_SRCS})
117 target_link_libraries (mraa ${mraa_LIBS})
119 set_target_properties(
122 SOVERSION ${mraa_VERSION_MAJOR}
123 VERSION ${mraa_VERSION_STRING}
125 install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
126 install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mraa)
128 macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
129 configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
130 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
131 endmacro (mraa_CREATE_INSTALL_PKGCONFIG)
132 mraa_create_install_pkgconfig (mraa.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
134 install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR})
137 set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
138 set (DOCCLASSES aio gpio i2c pwm spi uart)
140 foreach (_file ${DOCCLASSES})
141 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
142 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
143 ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
144 ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
145 DEPENDS ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml
147 add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
148 add_dependencies (${_file}class_doc_i doc)
151 set (DOCFILES common ${DOCCLASSES})
152 foreach (_file ${DOCFILES})
153 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
154 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
155 ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
156 ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
157 DEPENDS ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml
159 add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
160 add_dependencies (${_file}doc_i doc)
163 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i
164 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
165 ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
166 ${CMAKE_CURRENT_BINARY_DIR}//common_hpp_doc.i
167 DEPENDS ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
169 add_custom_target (common_hpp_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i)
170 add_dependencies (common_hpp_doc_i doc)
176 include (${SWIG_USE_FILE})
177 set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
180 add_subdirectory (python)
183 add_subdirectory (java)
186 if (SWIG_VERSION VERSION_GREATER 3.0.4)
187 add_subdirectory (javascript)
189 message ("WARN - SWIG is ${SWIG_VERSION}. Please upgrade to 3.0.5+ to build nodejs addon")