No Description

CMakeLists.txt 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. # Extract module name from non-standard example name
  2. macro(get_module_name example_name module_name)
  3. string(LENGTH ${example_name} length)
  4. string(FIND ${example_name} "-" index)
  5. if (${index} GREATER 1)
  6. string(SUBSTRING ${example_name} 0 ${index} substr)
  7. set(${module_name} ${substr})
  8. elseif (${example_name} MATCHES "^grove")
  9. set (${module_name} "grove")
  10. elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
  11. set (${module_name} "gas")
  12. else()
  13. set(${module_name} ${example_name})
  14. endif()
  15. endmacro()
  16. # Set source file, include and linker settings for an example
  17. # If example cannot be built, example_bin is cleared
  18. macro(add_custom_example example_bin example_src example_module_list)
  19. set(found_all_modules TRUE)
  20. foreach (module ${example_module_list})
  21. if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}")
  22. set(found_all_modules FALSE)
  23. endif()
  24. if (MODULE_LIST)
  25. list(FIND MODULE_LIST ${module} index)
  26. if (${index} EQUAL -1)
  27. set(found_all_modules FALSE)
  28. endif()
  29. endif()
  30. endforeach()
  31. if (found_all_modules)
  32. add_executable (${example_bin} ${example_src})
  33. target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
  34. foreach (module ${example_module_list})
  35. set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
  36. include_directories (${module_dir})
  37. if (${module} STREQUAL "lcd")
  38. set(module "i2clcd")
  39. endif()
  40. target_link_libraries (${example_bin} ${module})
  41. endforeach()
  42. else()
  43. MESSAGE(INFO " Ignored ${example_bin}")
  44. set (example_bin "")
  45. endif()
  46. endmacro()
  47. # Add specified example by name
  48. # Note special case for grove based examples
  49. macro(add_example example_name)
  50. set(example_src "${example_name}.cxx")
  51. set(example_bin "${example_name}-example")
  52. get_module_name(${example_name} module_name)
  53. set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
  54. if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
  55. AND EXISTS ${module_dir}
  56. AND IS_DIRECTORY ${module_dir})
  57. add_custom_example(${example_bin} ${example_src} ${module_name})
  58. if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
  59. set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
  60. if (EXISTS ${grove_module_path})
  61. include_directories(${grove_module_path})
  62. target_link_libraries (${example_bin} ${example_name})
  63. endif()
  64. endif()
  65. else()
  66. MESSAGE(INFO " Ignored ${example_bin}")
  67. endif()
  68. endmacro()
  69. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
  70. # Set the mraa include and link directories prior to adding examples
  71. include_directories (${MRAA_INCLUDE_DIRS})
  72. link_directories (${MRAA_LIBDIR})
  73. # If your sample source file matches the name of the module it tests, add it here
  74. # Exceptions are as follows:
  75. # string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
  76. # mq? will use module gas
  77. # grove* will use module grove
  78. add_example (hmc5883l)
  79. add_example (groveled)
  80. add_example (groverelay)
  81. add_example (grovelight)
  82. add_example (grovetemp)
  83. add_example (grovebutton)
  84. add_example (groverotary)
  85. add_example (groveslide)
  86. add_example (buzzer-sound)
  87. add_example (nrf24l01-transmitter)
  88. add_example (nrf24l01-receiver)
  89. add_example (nrf24l01-broadcast)
  90. add_example (hcsr04)
  91. add_example (max44000)
  92. add_example (mma7455)
  93. add_example (st7735)
  94. add_example (max31855)
  95. add_example (bmpx8x)
  96. add_example (stepmotor)
  97. add_example (pulsensor)
  98. add_example (mic)
  99. add_example (mpu9150)
  100. add_example (maxds3231m)
  101. add_example (max31723)
  102. add_example (max5487)
  103. add_example (nrf8001-broadcast)
  104. add_example (nrf8001-helloworld)
  105. add_example (lpd8806)
  106. add_example (mlx90614)
  107. add_example (ecs1030)
  108. add_example (mq2)
  109. add_example (mq3)
  110. add_example (mq4)
  111. add_example (mq5)
  112. add_example (mq6)
  113. add_example (mq7)
  114. add_example (mq8)
  115. add_example (mq9)
  116. add_example (tp401)
  117. add_example (tcs3414cs)
  118. add_example (th02)
  119. add_example (ttp223)
  120. add_example (lsm303)
  121. add_example (joystick12)
  122. add_example (lol)
  123. add_example (tsl2561)
  124. add_example (htu21d)
  125. add_example (mpl3115a2)
  126. add_example (ldt0028)
  127. add_example (am2315)
  128. add_example (itg3200)
  129. add_example (enc03r)
  130. add_example (adc121c021)
  131. add_example (ds1307)
  132. add_example (a110x)
  133. add_example (gp2y0a)
  134. add_example (grovemoisture)
  135. add_example (groveehr)
  136. add_example (ta12200)
  137. add_example (grovelinefinder)
  138. add_example (grovevdiv)
  139. add_example (grovewater)
  140. add_example (guvas12d)
  141. add_example (mpr121)
  142. add_example (ublox6)
  143. add_example (yg1006)
  144. add_example (wt5001)
  145. add_example (ppd42ns)
  146. add_example (mq303a)
  147. add_example (grovespeaker)
  148. add_example (rfr359f)
  149. add_example (biss0001)
  150. add_example (rotaryencoder)
  151. add_example (adxl345)
  152. add_example (rpr220)
  153. add_example (rpr220-intr)
  154. add_example (mma7660)
  155. add_example (cjq4435)
  156. add_example (adxl335)
  157. add_example (hmtrp)
  158. add_example (nunchuck)
  159. add_example (otp538u)
  160. add_example (grovecollision)
  161. add_example (groveelectromagnet)
  162. add_example (groveemg)
  163. add_example (groveo2)
  164. add_example (grovegsr)
  165. add_example (ina132)
  166. add_example (l298)
  167. add_example (l298-stepper)
  168. add_example (at42qt1070)
  169. add_example (grovemd)
  170. add_example (grovemd-stepper)
  171. add_example (pca9685)
  172. add_example (groveeldriver)
  173. add_example (adafruitss)
  174. add_example (adafruitms1438)
  175. add_example (adafruitms1438-stepper)
  176. add_example (hx711)
  177. add_example (flex)
  178. add_example (a110x-intr)
  179. add_example (mhz16)
  180. add_example (apds9002)
  181. add_example (waterlevel)
  182. add_example (tm1637)
  183. add_example (zfm20)
  184. add_example (zfm20-register)
  185. add_example (uln200xa)
  186. add_example (grovewfs)
  187. add_example (isd1820)
  188. add_example (sx6119)
  189. add_example (si114x)
  190. add_example (maxsonarez)
  191. add_example (hm11)
  192. add_example (ht9170)
  193. add_example (h3lis331dl)
  194. add_example (ad8232)
  195. add_example (grovescam)
  196. add_example (m24lr64e)
  197. add_example (rgbringcoder)
  198. add_example (hp20x)
  199. add_example (pn532)
  200. add_example (pn532-writeurl)
  201. add_example (lsm9ds0)
  202. add_example (loudness)
  203. add_example (mg811)
  204. add_example (wheelencoder)
  205. add_example (sm130)
  206. add_example (grovegprs)
  207. add_example (lm35)
  208. add_example (micsv89)
  209. add_example (xbee)
  210. add_example (urm37)
  211. add_example (urm37-uart)
  212. add_example (adxrs610)
  213. add_example (bma220)
  214. add_example (dfrph)
  215. add_example (mcp9808)
  216. add_example (groveultrasonic)
  217. add_example (sx1276-lora)
  218. add_example (sx1276-fsk)
  219. add_example (ili9341)
  220. if (OPENZWAVE_FOUND)
  221. include_directories(${OPENZWAVE_INCLUDE_DIRS})
  222. add_example (ozw)
  223. endif()
  224. add_example (nlgpio16)
  225. add_example (ads1x15)
  226. if (MODBUS_FOUND)
  227. include_directories(${MODBUS_INCLUDE_DIRS})
  228. add_example (t3311)
  229. add_example (hwxpxx)
  230. add_example (h803x)
  231. endif()
  232. add_example (hdxxvxta)
  233. add_example (rhusb)
  234. add_example (apds9930)
  235. add_example (kxcjk1013)
  236. add_example (ssd1351)
  237. add_example (bme280)
  238. add_example (ds1808lc)
  239. add_example (hlg150h)
  240. add_example (lp8860)
  241. add_example (max44009)
  242. add_example (si1132)
  243. add_example (si7005)
  244. add_example (t6713)
  245. add_example (cwlsxxa)
  246. add_example (teams)
  247. add_example (apa102)
  248. add_example (tex00)
  249. add_example (bmi160)
  250. add_example (smartdrive)
  251. if (HAVE_FIRMATA)
  252. add_example (curieimu)
  253. endif ()
  254. # These are special cases where you specify example binary, source file and module(s)
  255. include_directories (${PROJECT_SOURCE_DIR}/src)
  256. add_custom_example (groveled-multi-example groveled-multi.cxx grove)
  257. add_custom_example (lcm1602-i2c-example lcm1602-i2c.cxx lcd)
  258. add_custom_example (lcm1602-parallel-example lcm1602-parallel.cxx lcd)
  259. add_custom_example (jhd1313m1-lcd-example jhd1313m1-lcd.cxx lcd)
  260. add_custom_example (es08a-example es08a.cxx servo)
  261. add_custom_example (ssd1306-oled-example ssd1306-oled.cxx lcd)
  262. add_custom_example (ssd1308-oled-example ssd1308-oled.cxx lcd)
  263. add_custom_example (ssd1327-oled-example ssd1327-oled.cxx lcd)
  264. add_custom_example (sainsmartks-example sainsmartks.cxx lcd)
  265. add_custom_example (eboled-example eboled.cxx lcd)
  266. add_custom_example (mpu60x0-example mpu60x0.cxx mpu9150)
  267. add_custom_example (ak8975-example ak8975.cxx mpu9150)
  268. add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
  269. add_custom_example (groveledbar-example groveledbar.cxx my9221)
  270. add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
  271. add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmp180;bme280")
  272. add_custom_example (humidity-sensor-example humidity-sensor.cxx "si7005;bme280")
  273. add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmp180;bme280")
  274. add_custom_example (co2-sensor-example co2-sensor.cxx "t6713")
  275. add_custom_example (adc-example adc-sensor.cxx "ads1x15")
  276. add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
  277. add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")