1set (mraa_LIB_INCLUDE_DIRS 2 ${PROJECT_SOURCE_DIR}/api 3 ${PROJECT_SOURCE_DIR}/api/mraa 4 ${PROJECT_SOURCE_DIR}/include 5) 6 7include_directories( 8 ${mraa_LIB_INCLUDE_DIRS} 9) 10 11set (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 20) 21 22set (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 31) 32 33message (INFO " - Adding support for platform ${MRAAPLATFORMFORCE}") 34 35#keywords in if statements are case sensitive 36if (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) 52 else () 53 message (ERROR " - Unknown x86 platform enabled!") 54 endif () 55else () 56 message (INFO " - Adding support for all platforms") 57endif () 58 59set (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 65) 66 67set (mraa_LIBS ${CMAKE_THREAD_LIBS_INIT}) 68 69if (X86PLAT) 70 add_subdirectory(x86) 71 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1") 72endif() 73 74if (ARMPLAT) 75 add_subdirectory(arm) 76 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1") 77endif() 78 79if (USBPLAT) 80 message (INFO " - Adding USB platforms") 81 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1") 82 if (FTDID2xx) 83 find_package (Ftd2xx) 84 if (${LIBFTD2XX_FOUND}) 85 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDID2XX=1") 86 set (mraa_LIBS ${mraa_LIBS} ${LIBFTD2XX_LIBRARIES}) 87 else () 88 message (WARNING " - Enabled FTDID2xx support but library not found") 89 endif () 90 endif () 91 if (FTDI4222) 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}) 96 else () 97 message (WARNING " - Enabled FTDI4222 support but library not found") 98 endif () 99 endif () 100 add_subdirectory(usb) 101endif () 102 103set (mraa_LIB_SRCS 104 ${mraa_LIB_PLAT_SRCS_NOAUTO} 105# autogenerated version file 106 ${CMAKE_CURRENT_BINARY_DIR}/version.c 107) 108 109set (mraa_LIB_GLOB_HEADERS 110 ${PROJECT_SOURCE_DIR}/api/mraa.h 111 ${PROJECT_SOURCE_DIR}/api/mraa.hpp 112) 113 114add_library (mraa ${mraa_LIB_SRCS}) 115 116 117target_link_libraries (mraa ${mraa_LIBS}) 118 119set_target_properties( 120 mraa 121 PROPERTIES 122 SOVERSION ${mraa_VERSION_MAJOR} 123 VERSION ${mraa_VERSION_STRING} 124) 125install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 126install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mraa) 127 128macro (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}) 131endmacro (mraa_CREATE_INSTALL_PKGCONFIG) 132mraa_create_install_pkgconfig (mraa.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 133mraa_create_install_pkgconfig (mraajava.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 134 135install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR}) 136 137if (DOXYGEN_FOUND) 138 set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND}) 139 set (DOCCLASSES aio gpio i2c pwm spi uart) 140 # CPP class headers 141 foreach (_file ${DOCCLASSES}) 142 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i 143 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n 144 ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml 145 ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i 146 DEPENDS ${CMAKE_BINARY_DIR}/xml/classmraa_1_1_${_file}.xml 147 ) 148 add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i) 149 add_dependencies (${_file}class_doc_i doc) 150 endforeach () 151 # C header files 152 set (DOCFILES common ${DOCCLASSES}) 153 foreach (_file ${DOCFILES}) 154 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i 155 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n 156 ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml 157 ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i 158 DEPENDS ${CMAKE_BINARY_DIR}/xml/${_file}_8h.xml 159 ) 160 add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i) 161 add_dependencies (${_file}doc_i doc) 162 endforeach () 163 # CPP common header 164 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i 165 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n 166 ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml 167 ${CMAKE_CURRENT_BINARY_DIR}//common_hpp_doc.i 168 DEPENDS ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml 169 ) 170 add_custom_target (common_hpp_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i) 171 add_dependencies (common_hpp_doc_i doc) 172endif () 173 174if (BUILDSWIG) 175 enable_language(CXX) 176 find_package (SWIG) 177 if (SWIG_FOUND) 178 include (${SWIG_USE_FILE}) 179 set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src") 180 181 if (BUILDSWIGPYTHON) 182 add_subdirectory (python) 183 endif () 184 if (BUILDSWIGJAVA) 185 add_subdirectory (java) 186 endif () 187 if (BUILDSWIGNODE) 188 if (SWIG_VERSION VERSION_GREATER 3.0.4) 189 add_subdirectory (javascript) 190 else () 191 message ("WARN - SWIG is ${SWIG_VERSION}. Please upgrade to 3.0.5+ to build nodejs addon") 192 endif () 193 endif () 194 endif () 195endif () 196