From a4e001bbcf112981221f6d5f20c891b9212fb272 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Sep 2011 15:44:55 +0200 Subject: [PATCH] Adding CMake support --- ArduCopter/CMakeLists.txt | 162 ++++++ ArduPlane/CMakeLists.txt | 162 ++++++ cmake/PdeP.jar | Bin 0 -> 5690 bytes cmake/modules/ArduinoProcessing.cmake | 103 ++++ cmake/modules/FindArduino.cmake | 581 ++++++++++++++++++++++ cmake/modules/Platform/Arduino.cmake | 0 cmake/modules/Platform/ArduinoPaths.cmake | 21 + cmake/toolchains/Arduino.cmake | 66 +++ libraries/APM_BMP085/CMakeLists.txt | 22 + libraries/APM_PI/CMakeLists.txt | 24 + libraries/APM_RC/CMakeLists.txt | 22 + libraries/AP_ADC/CMakeLists.txt | 26 + libraries/AP_Common/CMakeLists.txt | 33 ++ libraries/AP_Compass/CMakeLists.txt | 27 + libraries/AP_DCM/CMakeLists.txt | 25 + libraries/AP_GPS/CMakeLists.txt | 44 ++ libraries/AP_IMU/CMakeLists.txt | 25 + libraries/AP_Math/CMakeLists.txt | 24 + libraries/AP_OpticalFlow/CMakeLists.txt | 24 + libraries/AP_PID/CMakeLists.txt | 24 + libraries/AP_RangeFinder/CMakeLists.txt | 27 + libraries/CMakeLists.txt | 24 + libraries/DataFlash/CMakeLists.txt | 21 + libraries/FastSerial/CMakeLists.txt | 28 ++ libraries/GCS_MAVLink/CMakeLists.txt | 19 + libraries/ModeFilter/CMakeLists.txt | 24 + libraries/PID/CMakeLists.txt | 21 + libraries/RC_Channel/CMakeLists.txt | 24 + libraries/memcheck/CMakeLists.txt | 24 + 29 files changed, 1627 insertions(+) create mode 100644 ArduCopter/CMakeLists.txt create mode 100644 ArduPlane/CMakeLists.txt create mode 100644 cmake/PdeP.jar create mode 100644 cmake/modules/ArduinoProcessing.cmake create mode 100644 cmake/modules/FindArduino.cmake create mode 100644 cmake/modules/Platform/Arduino.cmake create mode 100644 cmake/modules/Platform/ArduinoPaths.cmake create mode 100644 cmake/toolchains/Arduino.cmake create mode 100644 libraries/APM_BMP085/CMakeLists.txt create mode 100644 libraries/APM_PI/CMakeLists.txt create mode 100644 libraries/APM_RC/CMakeLists.txt create mode 100644 libraries/AP_ADC/CMakeLists.txt create mode 100644 libraries/AP_Common/CMakeLists.txt create mode 100644 libraries/AP_Compass/CMakeLists.txt create mode 100644 libraries/AP_DCM/CMakeLists.txt create mode 100644 libraries/AP_GPS/CMakeLists.txt create mode 100644 libraries/AP_IMU/CMakeLists.txt create mode 100644 libraries/AP_Math/CMakeLists.txt create mode 100644 libraries/AP_OpticalFlow/CMakeLists.txt create mode 100644 libraries/AP_PID/CMakeLists.txt create mode 100644 libraries/AP_RangeFinder/CMakeLists.txt create mode 100644 libraries/CMakeLists.txt create mode 100644 libraries/DataFlash/CMakeLists.txt create mode 100644 libraries/FastSerial/CMakeLists.txt create mode 100644 libraries/GCS_MAVLink/CMakeLists.txt create mode 100644 libraries/ModeFilter/CMakeLists.txt create mode 100644 libraries/PID/CMakeLists.txt create mode 100644 libraries/RC_Channel/CMakeLists.txt create mode 100644 libraries/memcheck/CMakeLists.txt diff --git a/ArduCopter/CMakeLists.txt b/ArduCopter/CMakeLists.txt new file mode 100644 index 0000000000..bef981f926 --- /dev/null +++ b/ArduCopter/CMakeLists.txt @@ -0,0 +1,162 @@ +#=============================================================================# +# Author: Niklaa Goddemeier & Sebastian Rohde # +# Date: 04.09.2011 # +#=============================================================================# + +set(CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../") + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) # CMake module search path +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Arduino.cmake) # Arduino Toolchain +#include(ArduinoProcessing) + +set (CMAKE_CXX_SOURCE_FILE_EXTENSIONS pde) + + +message(STATUS "DIR: ${CMAKE_SOURCE_DIR}") + +cmake_minimum_required(VERSION 2.8) +#====================================================================# +# Setup Project # +#====================================================================# +project(ArduCopter C CXX) + +find_package(Arduino 22 REQUIRED) + +add_subdirectory(../libraries "${CMAKE_CURRENT_BINARY_DIR}/libs") + +#add_subdirectory(${CMAKE_SOURCE_DIR}/ArduCopter) +#add_subdirectory(testtool) + +PRINT_BOARD_SETTINGS(mega2560) + + + +#=============================================================================# +# Author: Niklas Goddemeier & Sebastian Rohde # +# Date: 04.09.2011 # +#=============================================================================# + + +#====================================================================# +# Settings # +#====================================================================# +set(FIRMWARE_NAME arducopter) + +set(${FIRMWARE_NAME}_BOARD mega2560) # Arduino Target board + +set(${FIRMWARE_NAME}_SKETCHES + ArduCopter.pde + Attitude.pde + Camera.pde + commands.pde + commands_logic.pde + commands_process.pde + control_modes.pde + events.pde + flight_control.pde + flip.pde + GCS.pde + GCS_Ardupilot.pde + #GCS_IMU_output.pde + GCS_Jason_text.pde + GCS_Mavlink.pde + GCS_Standard.pde + GCS_Xplane.pde + heli.pde + HIL_Xplane.pde + leds.pde + Log.pde + motors_hexa.pde + motors_octa.pde + motors_octa_quad.pde + motors_quad.pde + motors_tri.pde + motors_y6.pde + navigation.pde + planner.pde + radio.pde + read_commands.pde + sensors.pde + setup.pde + system.pde + test.pde + ) # Firmware sketches + +#create dummy sourcefile +file(WRITE ${FIRMWARE_NAME}.cpp "// Do not edit") + +set(${FIRMWARE_NAME}_SRCS + #test.cpp + ${FIRMWARE_NAME}.cpp + ) # Firmware sources + +set(${FIRMWARE_NAME}_HDRS + APM_Config.h + APM_Config_mavlink_hil.h + APM_Config_xplane.h + config.h + defines.h + GCS.h + HIL.h + Mavlink_Common.h + Parameters.h + ) # Firmware sources + +set(${FIRMWARE_NAME}_LIBS + DataFlash + AP_Math + PID + RC_Channel + AP_OpticalFlow + ModeFilter + memcheck + #AP_PID + APM_PI + #APO + FastSerial + AP_Common + GCS_MAVLink + AP_GPS + APM_RC + AP_DCM + AP_ADC + AP_Compass + AP_IMU + AP_RangeFinder + APM_BMP085 + c + m +) +SET_TARGET_PROPERTIES(AP_Math PROPERTIES LINKER_LANGUAGE CXX) + + +#${CONSOLE_PORT} +set(${FIRMWARE_NAME}_PORT COM2) # Serial upload port +set(${FIRMWARE_NAME}_SERIAL putty -serial COM2 -sercfg 57600,8,n,1,X ) # Serial terminal cmd + +include_directories( +${CMAKE_SOURCE_DIR}/libraries/DataFlash +${CMAKE_SOURCE_DIR}/libraries/AP_Math +${CMAKE_SOURCE_DIR}/libraries/PID +${CMAKE_SOURCE_DIR}/libraries/AP_Common +${CMAKE_SOURCE_DIR}/libraries/RC_Channel +${CMAKE_SOURCE_DIR}/libraries/AP_OpticalFlow +${CMAKE_SOURCE_DIR}/libraries/ModeFilter +${CMAKE_SOURCE_DIR}/libraries/memcheck +#${CMAKE_SOURCE_DIR}/libraries/AP_PID +${CMAKE_SOURCE_DIR}/libraries/APM_PI +${CMAKE_SOURCE_DIR}/libraries/FastSerial +${CMAKE_SOURCE_DIR}/libraries/AP_Compass +${CMAKE_SOURCE_DIR}/libraries/AP_RangeFinder +${CMAKE_SOURCE_DIR}/libraries/AP_GPS +${CMAKE_SOURCE_DIR}/libraries/AP_IMU +${CMAKE_SOURCE_DIR}/libraries/AP_ADC +${CMAKE_SOURCE_DIR}/libraries/AP_DCM +${CMAKE_SOURCE_DIR}/libraries/APM_RC +${CMAKE_SOURCE_DIR}/libraries/GCS_MAVLink +${CMAKE_SOURCE_DIR}/libraries/APM_BMP085 +) +#====================================================================# +# Target generation # +#====================================================================# +generate_arduino_firmware(${FIRMWARE_NAME}) diff --git a/ArduPlane/CMakeLists.txt b/ArduPlane/CMakeLists.txt new file mode 100644 index 0000000000..1509de51a6 --- /dev/null +++ b/ArduPlane/CMakeLists.txt @@ -0,0 +1,162 @@ +#=============================================================================# +# Author: Niklaa Goddemeier & Sebastian Rohde # +# Date: 04.09.2011 # +#=============================================================================# + +set(CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../") + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) # CMake module search path +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Arduino.cmake) # Arduino Toolchain +#include(ArduinoProcessing) + +set (CMAKE_CXX_SOURCE_FILE_EXTENSIONS pde) + +cmake_minimum_required(VERSION 2.8) +#====================================================================# +# Setup Project # +#====================================================================# +project(ArduPlane C CXX) + +find_package(Arduino 22 REQUIRED) + +add_subdirectory(../libraries "${CMAKE_CURRENT_BINARY_DIR}/libs") + +#add_subdirectory(${CMAKE_SOURCE_DIR}/ArduCopter) +#add_subdirectory(testtool) + +PRINT_BOARD_SETTINGS(mega2560) + + + +#=============================================================================# +# Author: Niklas Goddemeier & Sebastian Rohde # +# Date: 04.09.2011 # +#=============================================================================# + + +#====================================================================# +# Settings # +#====================================================================# +set(FIRMWARE_NAME ArduPlane) + +set(${FIRMWARE_NAME}_BOARD mega2560) # Arduino Target board + +set(${FIRMWARE_NAME}_SKETCHES + ArduPlane.pde + Attitude.pde + climb_rate.pde + commands.pde + commands_logic.pde + commands_process.pde + control_modes.pde + events.pde + #flight_control.pde + #flip.pde + #GCS.pde + #GCS_Ardupilot.pde + #GCS_IMU_output.pde + #GCS_Jason_text.pde + GCS_Mavlink.pde + #GCS_Standard.pde + #GCS_Xplane.pde + #heli.pde + HIL_Xplane.pde + #leds.pde + Log.pde + #motors_hexa.pde + #motors_octa.pde + #motors_octa_quad.pde + #motors_quad.pde + #motors_tri.pde + #motors_y6.pde + navigation.pde + planner.pde + radio.pde + #read_commands.pde + sensors.pde + setup.pde + system.pde + test.pde + ) # Firmware sketches + +#create dummy sourcefile +file(WRITE ${FIRMWARE_NAME}.cpp "// Do not edit") + +set(${FIRMWARE_NAME}_SRCS + #test.cpp + ${FIRMWARE_NAME}.cpp + ) # Firmware sources + +set(${FIRMWARE_NAME}_HDRS + APM_Config.h + APM_Config_mavlink_hil.h + APM_Config_xplane.h + config.h + defines.h + GCS.h + HIL.h + Mavlink_Common.h + Parameters.h + ) # Firmware sources + +set(${FIRMWARE_NAME}_LIBS + DataFlash + AP_Math + PID + RC_Channel + AP_OpticalFlow + ModeFilter + memcheck + #AP_PID + APM_PI + #APO + FastSerial + AP_Common + GCS_MAVLink + AP_GPS + APM_RC + AP_DCM + AP_ADC + AP_Compass + AP_IMU + AP_RangeFinder + APM_BMP085 + c + m +) +SET_TARGET_PROPERTIES(AP_Math PROPERTIES LINKER_LANGUAGE CXX) + + +#${CONSOLE_PORT} +set(${FIRMWARE_NAME}_PORT COM2) # Serial upload port +set(${FIRMWARE_NAME}_SERIAL putty -serial COM2 -sercfg 57600,8,n,1,X ) # Serial terminal cmd + +include_directories( +${CMAKE_SOURCE_DIR}/libraries/DataFlash +${CMAKE_SOURCE_DIR}/libraries/AP_Math +${CMAKE_SOURCE_DIR}/libraries/PID +${CMAKE_SOURCE_DIR}/libraries/AP_Common +${CMAKE_SOURCE_DIR}/libraries/RC_Channel +${CMAKE_SOURCE_DIR}/libraries/AP_OpticalFlow +${CMAKE_SOURCE_DIR}/libraries/ModeFilter +${CMAKE_SOURCE_DIR}/libraries/memcheck +#${CMAKE_SOURCE_DIR}/libraries/AP_PID +${CMAKE_SOURCE_DIR}/libraries/APM_PI +${CMAKE_SOURCE_DIR}/libraries/FastSerial +${CMAKE_SOURCE_DIR}/libraries/AP_Compass +${CMAKE_SOURCE_DIR}/libraries/AP_RangeFinder +${CMAKE_SOURCE_DIR}/libraries/AP_GPS +${CMAKE_SOURCE_DIR}/libraries/AP_IMU +${CMAKE_SOURCE_DIR}/libraries/AP_ADC +${CMAKE_SOURCE_DIR}/libraries/AP_DCM +${CMAKE_SOURCE_DIR}/libraries/APM_RC +${CMAKE_SOURCE_DIR}/libraries/GCS_MAVLink +${CMAKE_SOURCE_DIR}/libraries/APM_BMP085 +#new +#${CMAKE_SOURCE_DIR}/libraries/Wire +#${CMAKE_SOURCE_DIR}/libraries/SPI +) +#====================================================================# +# Target generation # +#====================================================================# +generate_arduino_firmware(${FIRMWARE_NAME}) diff --git a/cmake/PdeP.jar b/cmake/PdeP.jar new file mode 100644 index 0000000000000000000000000000000000000000..ae76f9b762e0726a1fc249243eadb49b3b69cd6f GIT binary patch literal 5690 zcmZ`-WmFVgw{@l9ZN`?o>)Z^6K~g zc;ENC_wIAfT4$ZLpS}0__dJg}7#)KYQyW!D{cb4t`>6jO1Lr@@Vd-4|8Uy$D ztE0Jvy7TYtV8;6=@vnJ%+W(zM_g{(s!8rcLSh%=2IP;jnp)M|&df1*uI%M}hxKj5v z6Z36~>~@t~zQh$I5a)nfddUl!Z0PfGQ$MS+@(zvNG?u~aU ztJB(L9XwyM&Ff&9hJ{Vjpj7h(OvKBRzF07$&WU1fJM3sC;%70vBaTR9el=skEK4mm zv8>|9Dw&wNeVd5&!D@51T-Ct=s%lRiV=gl;@~2ZzZPjEW;f53`66>ByOCN{i8EL?E zycGs;n4Ow}s7z*w`NGFJrwQ}24pGXY89+H*lJ(aDROY<*$NXmbKNXAK&WcAdm(83E zSZkZ}HF44KJK748I~Y>{MKJ(jimXRm`o!SgNGjCUvCgb%!_rG+v?d}X$13m2z*CZ!VhY0Ym^+qoELj_ttiTJNj?E}?X|v}ZXsa}njwQEMN`Jj zk$>ZHY;dTHV3j!m8D!~v%kv%zWhSAd*q&Srbo>y^X z<>SD6=RhUK_mv4!Q&Y6srX9FCJ>zE1*20yS(xXy3qH0 z<5qk=UgDRP9vd>Uxe9z)XJG}e4xNny`I&eHU~I8_FyiqL%lRn0&GN`XO=7|` z^dnPQ6Z+>GrZ>RN8*tBl}6+Pt(`BOL*d!(txJ&Gvn#Rz$z zw&RL3?y{2{z{u>e6{CYLW)sSS60>6%8+7-`+b}5bQ;S}8*f>g1)4cCgwZaft3v9IfyDJp1Q2J_L)N-!-;7OkCK zp}85*jKFFle7$at!{~&s-YOPhR7^Qa*gxHkD2rE;DN2k#!xdQj$&B~rv+M#OiWMaL zvgg4@YFTKg4i*zqxk}DZ#ho;&ZW4^Gt){u$Ko&ROtkQEdH;lmeA0-uf2n5#8mh`K7|f2Uv1 zTDzH^;DeM2i_A(2GfIwB5@Nv*Kn_49Oy#tzV6Cyyn~)9S>;Us^^NA>?ZM;J2%ZVgM zmR)&*>};MlI>O_N#B+dS?$@N-{Wd!O^*^z?134sP$~e%6EpL`~^O%i04C1%}s;)ZM z=>7!wYgM=ePuldAUDAFww}3x`|HWiFVWo@{`TqxKQZo4#fX!}s3OdZ(FqPmAgb&De#qb|!@?ooUhU zK`)|=JNO>8H5YIJmKVwJLAw^>zuu<`gFp|ALH4(CcR9ne#G@FN1|_!wKBKSpCcsqw zL3Z#HKLygkGVNDb_trm&mn>gKa$e;4oVv-9ui8xjJcP6Shg z-`?OTsux(!J+o2Z7USFIzA;{BpP*1QcE(pg2iGEC8GsMRuZc_BNuwqPF!zRPUt1+WQMo1e>6t1i4u|y4uPA{jqFE@?K zv^8uC!=Um&X+tXiL!|U!x27+e?J>Kkk3ihj6OUPrMv63i1N-5`$QpG{N~?6kdKZhG z_PyPgk*H1^rf?7=PgY(qa8s0OSFUZeV;V9Q<c{caO3i^MEn%xom@ZD7+Z%$~XI*ci z+pUo_a|5xtWFA2Ir2$8i-R`BxTM6-BU0C(bsN z*!=KuVq_R~9>*N5q%i2kxAg zPWsj!4Ov`>@au{b`&B~6&&vib>OK$;ZiNG=IS|Q=^V&(A+Ji?20Wb7<-unifqbpa| zRY$I&TA@;8<+rO%jOOJ__B;hxR9*oER}Cy&qHNSEj0E}0Hxiyv>s-TO%+#5gHKSJD zxW!N$a((O;p`FG}4yIY1QXn7M)cX`Ui0WG2x_@Cfwyj-N6d4;mFIyf<8bTy5*dhVh zSS?90iLR`jm`h?YqH%Ojva!wC5=S zwGy?Dmx)eX*DTvyz~8WVVbodKI6GJNrHo2NRe3t$AF$t zO8aX*qiTwx!-mWF{w+6Mu@TyD5uJwz0kX>)^_TmPlFq4v{2JshUI5YUfh4p}RG-5| zp7L(jaBSzix^irJY?8xP)K8|*&avl4HuJ%%T|YFmm^SXBA>-06>Czr;RYj1*02|t^ z=ss3G*Xx|zXE2iTq%iaT@@#Fm;Ld_R<eS z%?}HushXJ1Mtn-ddS+C{W9)U=<&jJP{QP4PI`9E$_}<_$!)J8)=J4*w;fG7*-H&!o zl#BH-Dqpm%y(WO;Rjt_ss;WQ&4m^wBYQ%c-Rg}U_Ka0f(8Jk`0h9=##i;wNN+ox$y z+)E=7aO{5T1-@muxsfR81RoHT7#EF9YSW&nkDKVaWw`u_UY(y1BNrj^`W`CU{260)SB^S|9M3ojM;e-a`swAIlG4u@~!ADi@8Qf{^XL4T|>XYh6^UN|eU3vz+RKQuRzSx<@u9jeDTAL5)gB*mMGLBhCkd$NniNI*p)nM1e|co+ z_|^+JWs}MP!?Vq4;BiU_>whBtU2bFHmkOC_SzwSg$(%6M@>(~S$t~L9C6=fFz>sFT zB$BfTPdtoASqUNjr1GWc%REfQpk4XO5Zcr82KRpWt3u;pRmxqhER6nwZ=4`Xmkc;1 z5{j42HBc#NWkN`lo1zOIOmMyp4TQ>R2XNU~?bZbFL)lqyn%5`yK}t<3K^2tg`vOz6 zQUc=bL#;X3{V!6BT=wd03NT7x@-w+1(%S~;g^0jRH@9947}kOq1CwVOhLvIiN$UJk z6YC`5UTtBVCCj8u|Aw=n;p9XY34WcB0v6)tX}$z|krCyWG?0@BW4yb!Vd3KLhmj^T zK3Y4s^?5&jnn-;qEn*t)NEpE$v&H!bW&TAT6R;K&D~%UkoaDp;*p!WrMOk|kpe!Vk~*bX z?q_J?6Jw{Q!5l|tf+Mx1#A4b4d+^HjHm|C$%@fHLmEXwUljU=t2~*O!JR%pcr`A^O zG+CANjoyo|O@h@67?;NQLXd3sPo*-tRDXKTBRQ{fks54fI z?X+0+|JvTs!}1M`?~ULPBBga8>ghVvpGXV&LEIxIYD@;OjB{T7(Kotv|m5Xh_i>AB1iR0%c?@=Ffk6sB>lph z`1ZvdT5^4hamD3NoAw!APgWuMXpNx!N;M;Al<_ptU*4}!Fpq!j`;uBw0d?499;r^K zje5?uv-6GQSn5tEM9^6JmxVUqb#D^5m^iuWh+)=mZqzE&5Xk~d$N{8Rzfbyp;w~k& zMrNxKee3wP)1FAoz6`6auPr>50@>a)_L|WlIq{*d$XUXPk^s;eiHM#UP>_CREX(be z+8=~lta;CE@*2N2smg~)B`0R5N)n-V>^1#5!1VjfPcK<-@^MIZkCw=}&#=tdLC0o2CNG@|3O z2{>vv#!TP&;9LlPzF-HK!TW#dh9GBdS_E7PU{5FRUiD#%$H%m8W@C7u=jU@0bO! z*-VzAL2Me zp1}?=r-F+J;foDS{tcC+egpSVkMU^S#pYmDt{mKeF0Cuh>l0MTj*5-v_Yw3n=R_yZ zL*zIg$r8x-LNf@-<@<&`bu)HuT5r9Z-vu{?V>{u+pYyO+Ff!jq?f8jUo}j4yrnJH)s!Dxaop~~1R^|Q&3u!4srBG?;hDQeb#{32KoF7CKgsARm~d-y{f zTHHAqFR)Nh(DDBe2UIjtl)qike;Sp4T+x5W|L2kZse*&@|C^eBS3&$29r;K5KPKlt zISt+4sNc7${{sGBmghe|^M?oh^P_)w(BJXx$-kY}-_`zNMe1P8M}N{VelJ2)6cp0` G;Qj|rIcQP< literal 0 HcmV?d00001 diff --git a/cmake/modules/ArduinoProcessing.cmake b/cmake/modules/ArduinoProcessing.cmake new file mode 100644 index 0000000000..c7a2407a2a --- /dev/null +++ b/cmake/modules/ArduinoProcessing.cmake @@ -0,0 +1,103 @@ +# 1. Concatenate all PDE files +# 2. Write #include "WProgram.h" +# 3. Write prototypes +# 4. Write original sources +# +# +# Prefix Writer +# 1. Scrub comments +# 2. Optionally subsitute Unicode +# 3. Find imports +# 4. Find prototypes +# +# Find prototypes +# 1. Strip comments, quotes, preprocessor directives +# 2. Collapse braches +# 3. Regex + + +set(SINGLE_QUOTES_REGEX "('.')") +set(DOUBLE_QUOTES_REGEX "(\"([^\"\\\\]|\\\\.)*\")") +set(SINGLE_COMMENT_REGEX "([ ]*//[^\n]*)") +set(MULTI_COMMENT_REGEX "(/[*][^/]*[*]/)") +set(PREPROC_REGEX "([ ]*#(\\\\[\n]|[^\n])*)") + +#"[\w\[\]\*]+\s+[&\[\]\*\w\s]+\([&,\[\]\*\w\s]*\)(?=\s*\{)" +set(PROTOTPYE_REGEX "([a-zA-Z0-9]+[ ]*)*[a-zA-Z0-9]+[ ]*\([^{]*\)[ ]*{") + +function(READ_SKETCHES VAR_NAME ) + set(SKETCH_SOURCE) + foreach(SKETCH ${ARGN}) + if(EXISTS ${SKETCH}) + message(STATUS "${SKETCH}") + file(READ ${SKETCH} SKETCH_CONTENTS) + set(SKETCH_SOURCE "${SKETCH_SOURCE}\n${SKETCH_CONTENTS}") + else() + message(FATAL_ERROR "Sketch file does not exist: ${SKETCH}") + endif() + endforeach() + set(${VAR_NAME} "${SKETCH_SOURCE}" PARENT_SCOPE) +endfunction() + +function(STRIP_SOURCES VAR_NAME SOURCES) + string(REGEX REPLACE "${SINGLE_QUOTES_REGEX}|${DOUBLE_QUOTES_REGEX}|${SINGLE_COMMENT_REGEX}|${MULTI_COMMENT_REGEX}|${PREPROC_REGEX}" + "" + SOURCES + "${SOURCES}") + set(${VAR_NAME} "${SOURCES}" PARENT_SCOPE) +endfunction() + +function(COLLAPSE_BRACES VAR_NAME SOURCES) + set(PARSED_SOURCES) + string(LENGTH "${SOURCES}" SOURCES_LENGTH) + math(EXPR SOURCES_LENGTH "${SOURCES_LENGTH}-1") + + set(NESTING 0) + set(START 0) + foreach(INDEX RANGE ${SOURCES_LENGTH}) + string(SUBSTRING "${SOURCES}" ${INDEX} 1 CURRENT_CHAR) + #message("${CURRENT_CHAR}") + if(CURRENT_CHAR STREQUAL "{") + if(NESTING EQUAL 0) + math(EXPR SUBLENGTH "${INDEX}-${START} +1") + string(SUBSTRING "${SOURCES}" ${START} ${SUBLENGTH} CURRENT_CHUNK) + set(PARSED_SOURCES "${PARSED_SOURCES}${CURRENT_CHUNK}") + #message("INDEX: ${INDEX} START: ${START} LENGTH: ${SUBLENGTH}") + endif() + math(EXPR NESTING "${NESTING}+1") + elseif(CURRENT_CHAR STREQUAL "}") + math(EXPR NESTING "${NESTING}-1") + if(NESTING EQUAL 0) + set(START ${INDEX}) + endif() + endif() + endforeach() + + math(EXPR SUBLENGTH "${SOURCES_LENGTH}-${START} +1") + string(SUBSTRING "${SOURCES}" ${START} ${SUBLENGTH} CURRENT_CHUNK) + set(PARSED_SOURCES "${PARSED_SOURCES}${CURRENT_CHUNK}") + + set(${VAR_NAME} "${PARSED_SOURCES}" PARENT_SCOPE) +endfunction() + +function(extract_prototypes VAR_NAME SOURCES) + string(REGEX MATCHALL "${PROTOTPYE_REGEX}" + SOURCES + "${SOURCES}") + set(${VAR_NAME} "${SOURCES}" PARENT_SCOPE) +endfunction() + +read_sketches(SKETCH_SOURCE ${FILES}) +strip_sources(SKETCH_SOURCE "${SKETCH_SOURCE}") +collapse_braces(SKETCH_SOURCE "${SKETCH_SOURCE}") +extract_prototypes(SKETCH_SOURCE "${SKETCH_SOURCE}") + + + + +message("===============") +foreach(ENTRY ${SKETCH_SOURCE}) + message("START]]]${ENTRY}[[[END") +endforeach() +message("===============") +#message("${SKETCH_SOURCE}") diff --git a/cmake/modules/FindArduino.cmake b/cmake/modules/FindArduino.cmake new file mode 100644 index 0000000000..7faadeba15 --- /dev/null +++ b/cmake/modules/FindArduino.cmake @@ -0,0 +1,581 @@ +# - Generate firmware and libraries for Arduino Devices +# generate_arduino_firmware(TARGET_NAME) +# TARGET_NAME - Name of target +# Creates a Arduino firmware target. +# +# The target options can be configured by setting options of +# the following format: +# ${TARGET_NAME}${SUFFIX} +# The following suffixes are availabe: +# _SRCS # Sources +# _HDRS # Headers +# _SKETCHES # Arduino sketch files +# _LIBS # Libraries to linked in +# _BOARD # Board name (such as uno, mega2560, ...) +# _PORT # Serial port, for upload and serial targets [OPTIONAL] +# _AFLAGS # Override global Avrdude flags for target +# _SERIAL # Serial command for serial target [OPTIONAL] +# _NO_AUTOLIBS # Disables Arduino library detection +# Here is a short example for a target named test: +# set(test_SRCS test.cpp) +# set(test_HDRS test.h) +# set(test_BOARD uno) +# +# generate_arduino_firmware(test) +# +# +# generate_arduino_library(TARGET_NAME) +# TARGET_NAME - Name of target +# Creates a Arduino firmware target. +# +# The target options can be configured by setting options of +# the following format: +# ${TARGET_NAME}${SUFFIX} +# The following suffixes are availabe: +# +# _SRCS # Sources +# _HDRS # Headers +# _LIBS # Libraries to linked in +# _BOARD # Board name (such as uno, mega2560, ...) +# _NO_AUTOLIBS # Disables Arduino library detection +# +# Here is a short example for a target named test: +# set(test_SRCS test.cpp) +# set(test_HDRS test.h) +# set(test_BOARD uno) +# +# generate_arduino_library(test) + + +find_path(ARDUINO_SDK_PATH + NAMES lib/version.txt hardware libraries + PATH_SUFFIXES share/arduino + DOC "Arduino Development Kit path.") + + +# load_board_settings() +# +# Load the Arduino SDK board settings from the boards.txt file. +# +function(LOAD_BOARD_SETTINGS) + if(NOT ARDUINO_BOARDS AND ARDUINO_BOARDS_PATH) + file(STRINGS ${ARDUINO_BOARDS_PATH} BOARD_SETTINGS) + foreach(BOARD_SETTING ${BOARD_SETTINGS}) + if("${BOARD_SETTING}" MATCHES "^.*=.*") + string(REGEX MATCH "^[^=]+" SETTING_NAME ${BOARD_SETTING}) + string(REGEX MATCH "[^=]+$" SETTING_VALUE ${BOARD_SETTING}) + string(REPLACE "." ";" SETTING_NAME_TOKENS ${SETTING_NAME}) + + list(LENGTH SETTING_NAME_TOKENS SETTING_NAME_TOKENS_LEN) + + + # Add Arduino to main list of arduino boards + list(GET SETTING_NAME_TOKENS 0 BOARD_ID) + list(FIND ARDUINO_BOARDS ${BOARD_ID} ARDUINO_BOARD_INDEX) + if(ARDUINO_BOARD_INDEX LESS 0) + list(APPEND ARDUINO_BOARDS ${BOARD_ID}) + endif() + + # Add setting to board settings list + list(GET SETTING_NAME_TOKENS 1 BOARD_SETTING) + list(FIND ${BOARD_ID}.SETTINGS ${BOARD_SETTING} BOARD_SETTINGS_LEN) + if(BOARD_SETTINGS_LEN LESS 0) + list(APPEND ${BOARD_ID}.SETTINGS ${BOARD_SETTING}) + set(${BOARD_ID}.SETTINGS ${${BOARD_ID}.SETTINGS} + CACHE INTERNAL "Arduino ${BOARD_ID} Board settings list") + endif() + + set(ARDUINO_SETTING_NAME ${BOARD_ID}.${BOARD_SETTING}) + + # Add sub-setting to board sub-settings list + if(SETTING_NAME_TOKENS_LEN GREATER 2) + list(GET SETTING_NAME_TOKENS 2 BOARD_SUBSETTING) + list(FIND ${BOARD_ID}.${BOARD_SETTING}.SUBSETTINGS ${BOARD_SUBSETTING} BOARD_SUBSETTINGS_LEN) + if(BOARD_SUBSETTINGS_LEN LESS 0) + list(APPEND ${BOARD_ID}.${BOARD_SETTING}.SUBSETTINGS ${BOARD_SUBSETTING}) + set(${BOARD_ID}.${BOARD_SETTING}.SUBSETTINGS ${${BOARD_ID}.${BOARD_SETTING}.SUBSETTINGS} + CACHE INTERNAL "Arduino ${BOARD_ID} Board sub-settings list") + endif() + set(ARDUINO_SETTING_NAME ${ARDUINO_SETTING_NAME}.${BOARD_SUBSETTING}) + endif() + + # Save setting value + set(${ARDUINO_SETTING_NAME} ${SETTING_VALUE} CACHE INTERNAL "Arduino ${BOARD_ID} Board setting") + + + endif() + endforeach() + set(ARDUINO_BOARDS ${ARDUINO_BOARDS} CACHE STRING "List of detected Arduino Board configurations") + mark_as_advanced(ARDUINO_BOARDS) + endif() +endfunction() + +# print_board_settings(ARDUINO_BOARD) +# +# ARDUINO_BOARD - Board id +# +# Print the detected Arduino board settings. +# +function(PRINT_BOARD_SETTINGS ARDUINO_BOARD) + if(${ARDUINO_BOARD}.SETTINGS) + + message(STATUS "Arduino ${ARDUINO_BOARD} Board:") + foreach(BOARD_SETTING ${${ARDUINO_BOARD}.SETTINGS}) + if(${ARDUINO_BOARD}.${BOARD_SETTING}) + message(STATUS " ${ARDUINO_BOARD}.${BOARD_SETTING}=${${ARDUINO_BOARD}.${BOARD_SETTING}}") + endif() + if(${ARDUINO_BOARD}.${BOARD_SETTING}.SUBSETTINGS) + foreach(BOARD_SUBSETTING ${${ARDUINO_BOARD}.${BOARD_SETTING}.SUBSETTINGS}) + if(${ARDUINO_BOARD}.${BOARD_SETTING}.${BOARD_SUBSETTING}) + message(STATUS " ${ARDUINO_BOARD}.${BOARD_SETTING}.${BOARD_SUBSETTING}=${${ARDUINO_BOARD}.${BOARD_SETTING}.${BOARD_SUBSETTING}}") + endif() + endforeach() + endif() + message(STATUS "") + endforeach() + endif() +endfunction() + + + +# generate_arduino_library(TARGET_NAME) +# +# see documentation at top +function(GENERATE_ARDUINO_LIBRARY TARGET_NAME) + load_generator_settings(${TARGET_NAME} INPUT _SRCS # Sources + _HDRS # Headers + _LIBS # Libraries to linked in + _BOARD) # Board name (such as uno, mega2560, ...) + set(INPUT_AUTOLIBS True) + if(DEFINED ${TARGET_NAME}_NO_AUTOLIBS AND ${TARGET_NAME}_NO_AUTOLIBS) + set(INPUT_AUTOLIBS False) + endif() + + message(STATUS "Generating ${TARGET_NAME}") + + set(ALL_LIBS) + set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS}) + + setup_arduino_compiler(${INPUT_BOARD}) + setup_arduino_core(CORE_LIB ${INPUT_BOARD}) + + if(INPUT_AUTOLIBS) + setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}") + endif() + + list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS}) + + add_library(${TARGET_NAME} ${ALL_SRCS}) + target_link_libraries(${TARGET_NAME} ${ALL_LIBS}) +endfunction() + +# generate_arduino_firmware(TARGET_NAME) +# +# see documentation at top +function(GENERATE_ARDUINO_FIRMWARE TARGET_NAME) + load_generator_settings(${TARGET_NAME} INPUT _SRCS # Sources + _HDRS # Headers + _LIBS # Libraries to linked in + _BOARD # Board name (such as uno, mega2560, ...) + _PORT # Serial port, for upload and serial targets + _AFLAGS # Override global Avrdude flags for target + _SKETCHES # Arduino sketch files + _SERIAL) # Serial command for serial target + + set(INPUT_AUTOLIBS True) + if(DEFINED ${TARGET_NAME}_NO_AUTOLIBS AND ${TARGET_NAME}_NO_AUTOLIBS) + set(INPUT_AUTOLIBS False) + endif() + + message(STATUS "Generating ${TARGET_NAME}") + message(STATUS "Sketches ${INPUT_SKETCHES}") + + set(ALL_LIBS) + set(ALL_SRCS ${INPUT_SKETCHES} ${INPUT_SRCS} ${INPUT_HDRS} ) + #set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS} ) + + #set compile flags and file properties for pde files + #SET_SOURCE_FILES_PROPERTIES(${INPUT_SKETCHES} PROPERTIES LANGUAGE CXX) + #SET_SOURCE_FILES_PROPERTIES(${INPUT_SKETCHES} PROPERTIES COMPILE_FLAGS "-x c++" ) + + setup_arduino_compiler(${INPUT_BOARD}) + setup_arduino_core(CORE_LIB ${INPUT_BOARD}) + + #setup_arduino_sketch(SKETCH_SRCS ${INPUT_SKETCHES}) + + if(INPUT_AUTOLIBS) + setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}") + endif() + + + list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS}) + + setup_arduino_target(${TARGET_NAME} "${ALL_SRCS}" "${ALL_LIBS}") + #SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX) + #setup_arduino_target(${TARGET_NAME} "${INPUT_SKETCHES}" ${INPUT_HDRS} "${ALL_LIBS}") + + if(INPUT_PORT) + setup_arduino_upload(${INPUT_BOARD} ${TARGET_NAME} ${INPUT_PORT}) + endif() + + if(INPUT_SERIAL) + setup_serial_target(${TARGET_NAME} "${INPUT_SERIAL}") + endif() +endfunction() + + +# load_generator_settings(TARGET_NAME PREFIX [SUFFIX_1 SUFFIX_2 .. SUFFIX_N]) +# +# TARGET_NAME - The base name of the user settings +# PREFIX - The prefix name used for generator settings +# SUFFIX_XX - List of suffixes to load +# +# Loads a list of user settings into the generators scope. User settings have +# the following syntax: +# +# ${BASE_NAME}${SUFFIX} +# +# The BASE_NAME is the target name and the suffix is a specific generator settings. +# +# For every user setting found a generator setting is created of the follwoing fromat: +# +# ${PREFIX}${SUFFIX} +# +# The purpose of loading the settings into the generator is to not modify user settings +# and to have a generic naming of the settings within the generator. +# +function(LOAD_GENERATOR_SETTINGS TARGET_NAME PREFIX) + foreach(GEN_SUFFIX ${ARGN}) + if(${TARGET_NAME}${GEN_SUFFIX}) + set(${PREFIX}${GEN_SUFFIX} ${${TARGET_NAME}${GEN_SUFFIX}} PARENT_SCOPE) + endif() + endforeach() +endfunction() + +# setup_arduino_compiler(BOARD_ID) +# +# BOARD_ID - The board id name +# +# Configures the the build settings for the specified Arduino Board. +# +macro(setup_arduino_compiler BOARD_ID) + set(BOARD_CORE ${${BOARD_ID}.build.core}) + if(BOARD_CORE) + set(BOARD_CORE_PATH ${ARDUINO_CORES_PATH}/${BOARD_CORE}) + include_directories(${BOARD_CORE_PATH}) + include_directories(${ARDUINO_LIBRARIES_PATH}) + add_definitions(-DF_CPU=${${BOARD_ID}.build.f_cpu} + -DARDUINO=${ARDUINO_SDK_VERSION} + -mmcu=${${BOARD_ID}.build.mcu} + ) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mmcu=${${BOARD_ID}.build.mcu}" PARENT_SCOPE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmcu=${${BOARD_ID}.build.mcu}" PARENT_SCOPE) + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -mmcu=${${BOARD_ID}.build.mcu}" PARENT_SCOPE) + endif() +endmacro() + +# setup_arduino_core(VAR_NAME BOARD_ID) +# +# VAR_NAME - Variable name that will hold the generated library name +# BOARD_ID - Arduino board id +# +# Creates the Arduino Core library for the specified board, +# each board gets it's own version of the library. +# +function(setup_arduino_core VAR_NAME BOARD_ID) + set(CORE_LIB_NAME ${BOARD_ID}_CORE) + set(BOARD_CORE ${${BOARD_ID}.build.core}) + if(BOARD_CORE AND NOT TARGET ${CORE_LIB_NAME}) + set(BOARD_CORE_PATH ${ARDUINO_CORES_PATH}/${BOARD_CORE}) + find_sources(CORE_SRCS ${BOARD_CORE_PATH}) + add_library(${CORE_LIB_NAME} ${CORE_SRCS}) + set(${VAR_NAME} ${CORE_LIB_NAME} PARENT_SCOPE) + endif() +endfunction() + +# find_arduino_libraries(VAR_NAME SRCS) +# +# VAR_NAME - Variable name which will hold the results +# SRCS - Sources that will be analized +# +# returns a list of paths to libraries found. +# +# Finds all Arduino type libraries included in sources. Available libraries +# are ${ARDUINO_SDK_PATH}/libraries and ${CMAKE_CURRENT_SOURCE_DIR}. +# +# A Arduino library is a folder that has the same name as the include header. +# For example, if we have a include "#include " then the following +# directory structure is considered a Arduino library: +# +# LibraryName/ +# |- LibraryName.h +# `- LibraryName.c +# +# If such a directory is found then all sources within that directory are considred +# to be part of that Arduino library. +# +function(find_arduino_libraries VAR_NAME SRCS) + set(ARDUINO_LIBS ) + foreach(SRC ${SRCS}) + file(STRINGS ${SRC} SRC_CONTENTS) + foreach(SRC_LINE ${SRC_CONTENTS}) + if("${SRC_LINE}" MATCHES "^ *#include *[<\"](.*)[>\"]") + get_filename_component(INCLUDE_NAME ${CMAKE_MATCH_1} NAME_WE) + foreach(LIB_SEARCH_PATH ${ARDUINO_LIBRARIES_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) + if(EXISTS ${LIB_SEARCH_PATH}/${INCLUDE_NAME}/${CMAKE_MATCH_1}) + list(APPEND ARDUINO_LIBS ${LIB_SEARCH_PATH}/${INCLUDE_NAME}) + break() + endif() + endforeach() + endif() + endforeach() + endforeach() + if(ARDUINO_LIBS) + list(REMOVE_DUPLICATES ARDUINO_LIBS) + endif() + set(${VAR_NAME} ${ARDUINO_LIBS} PARENT_SCOPE) +endfunction() + +# setup_arduino_library(VAR_NAME BOARD_ID LIB_PATH) +# +# VAR_NAME - Vairable wich will hold the generated library names +# BOARD_ID - Board name +# LIB_PATH - path of the library +# +# Creates an Arduino library, with all it's library dependencies. +# +function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH) + set(LIB_TARGETS) + get_filename_component(LIB_NAME ${LIB_PATH} NAME) + set(TARGET_LIB_NAME ${BOARD_ID}_${LIB_NAME}) + if(NOT TARGET ${TARGET_LIB_NAME}) + find_sources(LIB_SRCS ${LIB_PATH}) + if(LIB_SRCS) + + message(STATUS "Generating Arduino ${LIB_NAME} library") + include_directories(${LIB_PATH} ${LIB_PATH}/utility) + add_library(${TARGET_LIB_NAME} STATIC ${LIB_SRCS}) + + find_arduino_libraries(LIB_DEPS "${LIB_SRCS}") + foreach(LIB_DEP ${LIB_DEPS}) + setup_arduino_library(DEP_LIB_SRCS ${BOARD_ID} ${LIB_DEP}) + list(APPEND LIB_TARGETS ${DEP_LIB_SRCS}) + endforeach() + + target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE ${LIB_TARGETS}) + list(APPEND LIB_TARGETS ${TARGET_LIB_NAME}) + endif() + else() + # Target already exists, skiping creating + include_directories(${LIB_PATH} ${LIB_PATH}/utility) + list(APPEND LIB_TARGETS ${TARGET_LIB_NAME}) + endif() + if(LIB_TARGETS) + list(REMOVE_DUPLICATES LIB_TARGETS) + endif() + set(${VAR_NAME} ${LIB_TARGETS} PARENT_SCOPE) +endfunction() + +# setup_arduino_libraries(VAR_NAME BOARD_ID SRCS) +# +# VAR_NAME - Vairable wich will hold the generated library names +# BOARD_ID - Board ID +# SRCS - source files +# +# Finds and creates all dependency libraries based on sources. +# +function(setup_arduino_libraries VAR_NAME BOARD_ID SRCS) + set(LIB_TARGETS) + find_arduino_libraries(TARGET_LIBS ${SRCS}) + foreach(TARGET_LIB ${TARGET_LIBS}) + setup_arduino_library(LIB_DEPS ${BOARD_ID} ${TARGET_LIB}) # Create static library instead of returning sources + list(APPEND LIB_TARGETS ${LIB_DEPS}) + endforeach() + set(${VAR_NAME} ${LIB_TARGETS} PARENT_SCOPE) +endfunction() + + +# setup_arduino_target(TARGET_NAME ALL_SRCS ALL_LIBS) +# +# TARGET_NAME - Target name +# ALL_SRCS - All sources +# ALL_LIBS - All libraries +# +# Creates an Arduino firmware target. +# +function(setup_arduino_target TARGET_NAME ALL_SRCS ALL_LIBS) + add_executable(${TARGET_NAME} ${ALL_SRCS}) + target_link_libraries(${TARGET_NAME} ${ALL_LIBS}) + set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".elf") + + set(TARGET_PATH ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_OBJCOPY} + ARGS ${ARDUINO_OBJCOPY_EEP_FLAGS} + ${TARGET_PATH}.elf + ${TARGET_PATH}.eep + VERBATIM) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_OBJCOPY} + ARGS ${ARDUINO_OBJCOPY_HEX_FLAGS} + ${TARGET_PATH}.elf + ${TARGET_PATH}.hex + VERBATIM) +endfunction() + +# setup_arduino_upload(BOARD_ID TARGET_NAME PORT) +# +# BOARD_ID - Arduino board id +# TARGET_NAME - Target name +# PORT - Serial port for upload +# +# Create an upload target (${TARGET_NAME}-upload) for the specified Arduino target. +# +function(setup_arduino_upload BOARD_ID TARGET_NAME PORT) + set(AVRDUDE_FLAGS ${ARDUINO_AVRDUDE_FLAGS}) + if(DEFINED ${TARGET_NAME}_AFLAGS) + set(AVRDUDE_FLAGS ${${TARGET_NAME}_AFLAGS}) + endif() + add_custom_target(${TARGET_NAME}-upload + ${ARDUINO_AVRDUDE_PROGRAM} + -U flash:w:${TARGET_NAME}.hex + ${AVRDUDE_FLAGS} + -C ${ARDUINO_AVRDUDE_CONFIG_PATH} + -p ${${BOARD_ID}.build.mcu} + -c ${${BOARD_ID}.upload.protocol} + -b ${${BOARD_ID}.upload.speed} + -P ${PORT} + DEPENDS ${TARGET_NAME}) + if(NOT TARGET upload) + add_custom_target(upload) + endif() + add_dependencies(upload ${TARGET_NAME}-upload) +endfunction() + +# find_sources(VAR_NAME LIB_PATH) +# +# VAR_NAME - Variable name that will hold the detected sources +# LIB_PATH - The base path +# +# Finds all C/C++ sources located at the specified path. +# +function(find_sources VAR_NAME LIB_PATH) + file(GLOB_RECURSE LIB_FILES ${LIB_PATH}/*.cpp + ${LIB_PATH}/*.c + ${LIB_PATH}/*.cc + ${LIB_PATH}/*.cxx + ${LIB_PATH}/*.h + ${LIB_PATH}/*.hh + ${LIB_PATH}/*.hxx) + if(LIB_FILES) + set(${VAR_NAME} ${LIB_FILES} PARENT_SCOPE) + endif() +endfunction() + +# setup_serial_target(TARGET_NAME CMD) +# +# TARGET_NAME - Target name +# CMD - Serial terminal command +# +# Creates a target (${TARGET_NAME}-serial) for launching the serial termnial. +# +function(setup_serial_target TARGET_NAME CMD) + string(CONFIGURE "${CMD}" FULL_CMD @ONLY) + add_custom_target(${TARGET_NAME}-serial + ${FULL_CMD}) +endfunction() + + +# detect_arduino_version(VAR_NAME) +# +# VAR_NAME - Variable name where the detected version will be saved +# +# Detects the Arduino SDK Version based on the revisions.txt file. +# +function(detect_arduino_version VAR_NAME) + if(ARDUINO_VERSION_PATH) + file(READ ${ARDUINO_VERSION_PATH} ARD_VERSION) + if("${ARD_VERSION}" MATCHES " *[0]+([0-9]+)") + set(${VAR_NAME} ${CMAKE_MATCH_1} PARENT_SCOPE) + endif() + endif() +endfunction() + + +function(convert_arduino_sketch VAR_NAME SRCS) +endfunction() + + +# Setting up Arduino enviroment settings +if(NOT ARDUINO_FOUND) + find_file(ARDUINO_CORES_PATH + NAMES cores + PATHS ${ARDUINO_SDK_PATH} + PATH_SUFFIXES hardware/arduino) + + find_file(ARDUINO_LIBRARIES_PATH + NAMES libraries + PATHS ${ARDUINO_SDK_PATH}) + + find_file(ARDUINO_BOARDS_PATH + NAMES boards.txt + PATHS ${ARDUINO_SDK_PATH} + PATH_SUFFIXES hardware/arduino) + + find_file(ARDUINO_PROGRAMMERS_PATH + NAMES programmers.txt + PATHS ${ARDUINO_SDK_PATH} + PATH_SUFFIXES hardware/arduino) + + find_file(ARDUINO_REVISIONS_PATH + NAMES revisions.txt + PATHS ${ARDUINO_SDK_PATH}) + + find_file(ARDUINO_VERSION_PATH + NAMES lib/version.txt + PATHS ${ARDUINO_SDK_PATH}) + + find_program(ARDUINO_AVRDUDE_PROGRAM + NAMES avrdude + PATHS ${ARDUINO_SDK_PATH} + PATH_SUFFIXES hardware/tools) + + find_program(ARDUINO_AVRDUDE_CONFIG_PATH + NAMES avrdude.conf + PATHS ${ARDUINO_SDK_PATH} /etc/avrdude + PATH_SUFFIXES hardware/tools + hardware/tools/avr/etc) + + set(ARDUINO_OBJCOPY_EEP_FLAGS -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 + CACHE STRING "") + set(ARDUINO_OBJCOPY_HEX_FLAGS -O ihex -R .eeprom + CACHE STRING "") + set(ARDUINO_AVRDUDE_FLAGS -V -F + CACHE STRING "Arvdude global flag list.") + + if(ARDUINO_SDK_PATH) + detect_arduino_version(ARDUINO_SDK_VERSION) + set(ARDUINO_SDK_VERSION ${ARDUINO_SDK_VERSION} CACHE STRING "Arduino SDK Version") + endif(ARDUINO_SDK_PATH) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Arduino + REQUIRED_VARS ARDUINO_SDK_PATH + ARDUINO_SDK_VERSION + VERSION_VAR ARDUINO_SDK_VERSION) + + + mark_as_advanced(ARDUINO_CORES_PATH + ARDUINO_SDK_VERSION + ARDUINO_LIBRARIES_PATH + ARDUINO_BOARDS_PATH + ARDUINO_PROGRAMMERS_PATH + ARDUINO_REVISIONS_PATH + ARDUINO_AVRDUDE_PROGRAM + ARDUINO_AVRDUDE_CONFIG_PATH + ARDUINO_OBJCOPY_EEP_FLAGS + ARDUINO_OBJCOPY_HEX_FLAGS) + load_board_settings() + +endif() + diff --git a/cmake/modules/Platform/Arduino.cmake b/cmake/modules/Platform/Arduino.cmake new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cmake/modules/Platform/ArduinoPaths.cmake b/cmake/modules/Platform/ArduinoPaths.cmake new file mode 100644 index 0000000000..27372098cc --- /dev/null +++ b/cmake/modules/Platform/ArduinoPaths.cmake @@ -0,0 +1,21 @@ +if(UNIX) + include(Platform/UnixPaths) + if(APPLE) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications + /Applications + /Developer/Applications + /sw # Fink + /opt/local) # MacPorts + endif() +elseif(WIN32) + include(Platform/WindowsPaths) +endif() + +if(ARDUINO_SDK_PATH) + if(WIN32) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/bin) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils/bin) + elseif(APPLE) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/bin) + endif() +endif() diff --git a/cmake/toolchains/Arduino.cmake b/cmake/toolchains/Arduino.cmake new file mode 100644 index 0000000000..616c7b9160 --- /dev/null +++ b/cmake/toolchains/Arduino.cmake @@ -0,0 +1,66 @@ +set(CMAKE_SYSTEM_NAME Arduino) + +set(CMAKE_C_COMPILER avr-gcc) +set(CMAKE_CXX_COMPILER avr-g++) + +#=============================================================================# +# C Flags # +#=============================================================================# +set(ARDUINO_C_FLAGS "-ffunction-sections -fdata-sections") +set(CMAKE_C_FLAGS "-g -Os ${ARDUINO_C_FLAGS}" CACHE STRING "") +set(CMAKE_C_FLAGS_DEBUG "-g ${ARDUINO_C_FLAGS}" CACHE STRING "") +set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG ${ARDUINO_C_FLAGS}" CACHE STRING "") +set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG -w ${ARDUINO_C_FLAGS}" CACHE STRING "") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g -w ${ARDUINO_C_FLAGS}" CACHE STRING "") + +#=============================================================================# +# C++ Flags # +#=============================================================================# +set(ARDUINO_CXX_FLAGS "${ARDUINO_C_FLAGS} -fno-exceptions") +set(CMAKE_CXX_FLAGS "-g -Os ${ARDUINO_CXX_FLAGS}" CACHE STRING "") +set(CMAKE_CXX_FLAGS_DEBUG "-g -Os ${ARDUINO_CXX_FLAGS}" CACHE STRING "") +set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG ${ARDUINO_CXX_FLAGS}" CACHE STRING "") +set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG ${ARDUINO_CXX_FLAGS}" CACHE STRING "") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g ${ARDUINO_CXX_FLAGS}" CACHE STRING "") + +#=============================================================================# +# Executable Linker Flags # +#=============================================================================# +set(ARDUINO_LINKER_FLAGS "-Wl,--gc-sections -lc -lm") +set(CMAKE_EXE_LINKER_FLAGS "${ARDUINO_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${ARDUINO_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${ARDUINO_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${ARDUINO_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${ARDUINO_LINKER_FLAGS}" CACHE STRING "") + +#=============================================================================# +# Shared Lbrary Linker Flags # +#=============================================================================# +set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "") + +set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "") +set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "" CACHE STRING "") +set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "" CACHE STRING "") +set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "" CACHE STRING "") +set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "") + + + + +set(ARDUINO_PATHS) +foreach(VERSION RANGE 22 1) + list(APPEND ARDUINO_PATHS arduino-00${VERSION}) +endforeach() + +find_path(ARDUINO_SDK_PATH + NAMES lib/version.txt + PATH_SUFFIXES share/arduino + Arduino.app/Contents/Resources/Java/ + ${ARDUINO_PATHS} + DOC "Arduino Development Kit path.") + +include(Platform/ArduinoPaths) diff --git a/libraries/APM_BMP085/CMakeLists.txt b/libraries/APM_BMP085/CMakeLists.txt new file mode 100644 index 0000000000..342fe4668f --- /dev/null +++ b/libraries/APM_BMP085/CMakeLists.txt @@ -0,0 +1,22 @@ +set(LIB_NAME APM_BMP085) + +set(${LIB_NAME}_SRCS + APM_BMP085.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + APM_BMP085.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/APM_PI/CMakeLists.txt b/libraries/APM_PI/CMakeLists.txt new file mode 100644 index 0000000000..e65e76f6a4 --- /dev/null +++ b/libraries/APM_PI/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME APM_PI) + +set(${LIB_NAME}_SRCS + APM_PI.cpp + #AP_OpticalFlow_ADNS3080.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + APM_PI.h + #AP_OpticalFlow_ADNS3080.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/APM_RC/CMakeLists.txt b/libraries/APM_RC/CMakeLists.txt new file mode 100644 index 0000000000..3e4aab0011 --- /dev/null +++ b/libraries/APM_RC/CMakeLists.txt @@ -0,0 +1,22 @@ +set(LIB_NAME APM_RC) + +set(${LIB_NAME}_SRCS + APM_RC.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + APM_RC.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_ADC/CMakeLists.txt b/libraries/AP_ADC/CMakeLists.txt new file mode 100644 index 0000000000..df85645fb2 --- /dev/null +++ b/libraries/AP_ADC/CMakeLists.txt @@ -0,0 +1,26 @@ +set(LIB_NAME AP_ADC) + +set(${LIB_NAME}_SRCS + AP_ADC_HIL.cpp + AP_ADC_ADS7844.cpp + AP_ADC.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_ADC_HIL.h + AP_ADC_ADS7844.h + AP_ADC.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_Common/CMakeLists.txt b/libraries/AP_Common/CMakeLists.txt new file mode 100644 index 0000000000..7d89ba1e40 --- /dev/null +++ b/libraries/AP_Common/CMakeLists.txt @@ -0,0 +1,33 @@ +set(LIB_NAME AP_Common) + +set(${LIB_NAME}_SRCS + AP_Common.cpp + AP_Loop.cpp + AP_MetaClass.cpp + AP_Var.cpp + AP_Var_menufuncs.cpp + c++.cpp + menu.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_Common.h + AP_Loop.h + AP_MetaClass.h + AP_Var.h + AP_Test.h + c++.h + AP_Vector.h +) + +include_directories( + + - + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + ${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_Compass/CMakeLists.txt b/libraries/AP_Compass/CMakeLists.txt new file mode 100644 index 0000000000..613b751ef4 --- /dev/null +++ b/libraries/AP_Compass/CMakeLists.txt @@ -0,0 +1,27 @@ +set(LIB_NAME AP_Compass) + +set(${LIB_NAME}_SRCS + AP_Compass_HIL.cpp + AP_Compass_HMC5843.cpp + Compass.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + Compass.h + AP_Compass_HIL.h + AP_Compass_HMC5843.h + AP_Compass.h + ) + + + +include_directories( + + - + ${ARDUINO_LIBRARIES_PATH}/Wire + #${CMAKE_SOURCE_DIR}/libraries/FastSerial + # +) +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_DCM/CMakeLists.txt b/libraries/AP_DCM/CMakeLists.txt new file mode 100644 index 0000000000..0131eeb495 --- /dev/null +++ b/libraries/AP_DCM/CMakeLists.txt @@ -0,0 +1,25 @@ +set(LIB_NAME AP_DCM) + +set(${LIB_NAME}_SRCS + AP_DCM.cpp + AP_DCM_HIL.cpp + #AP_OpticalFlow_ADNS3080.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_DCM.h + AP_DCM_HIL.h + ) + +include_directories( + + - + ${CMAKE_SOURCE_DIR}/libraries/AP_DCM + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_GPS/CMakeLists.txt b/libraries/AP_GPS/CMakeLists.txt new file mode 100644 index 0000000000..57409c6d24 --- /dev/null +++ b/libraries/AP_GPS/CMakeLists.txt @@ -0,0 +1,44 @@ +set(LIB_NAME AP_GPS) + +set(${LIB_NAME}_SRCS + AP_GPS_406.cpp + AP_GPS_Auto.cpp + AP_GPS_HIL.cpp + AP_GPS_IMU.cpp + AP_GPS_MTK.cpp + AP_GPS_MTK16.cpp + AP_GPS_NMEA.cpp + AP_GPS_SIRF.cpp + AP_GPS_UBLOX.cpp + GPS.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_GPS_406.h + AP_GPS_Auto.h + AP_GPS_HIL.h + AP_GPS_IMU.h + AP_GPS_MTK.h + AP_GPS_MTK_Common.h + AP_GPS_MTK16.h + AP_GPS_NMEA.h + AP_GPS_None.h + AP_GPS_Shim.h + AP_GPS_SIRF.h + AP_GPS_UBLOX.h + AP_GPS.h + GPS.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + ${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_IMU/CMakeLists.txt b/libraries/AP_IMU/CMakeLists.txt new file mode 100644 index 0000000000..2447a078c4 --- /dev/null +++ b/libraries/AP_IMU/CMakeLists.txt @@ -0,0 +1,25 @@ +set(LIB_NAME AP_IMU) + +set(${LIB_NAME}_SRCS + AP_IMU_Oilpan.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_IMU.h + AP_IMU_Shim.h + AP_IMU_Oilpan.h + IMU.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + ${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_Math/CMakeLists.txt b/libraries/AP_Math/CMakeLists.txt new file mode 100644 index 0000000000..f4a83b3102 --- /dev/null +++ b/libraries/AP_Math/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME AP_Math) + +set(${LIB_NAME}_SRCS + + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_Math.h + matrix3.h + vector2.h + vector3.h + ) + +include_directories( + + - +# ${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_OpticalFlow/CMakeLists.txt b/libraries/AP_OpticalFlow/CMakeLists.txt new file mode 100644 index 0000000000..74d7457ac4 --- /dev/null +++ b/libraries/AP_OpticalFlow/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME AP_OpticalFlow) + +set(${LIB_NAME}_SRCS + AP_OpticalFlow.cpp + #AP_OpticalFlow_ADNS3080.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_OpticalFlow.h + #AP_OpticalFlow_ADNS3080.h + ) + +include_directories( + + - + ${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_PID/CMakeLists.txt b/libraries/AP_PID/CMakeLists.txt new file mode 100644 index 0000000000..14e9782e51 --- /dev/null +++ b/libraries/AP_PID/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME AP_PID) + +set(${LIB_NAME}_SRCS + AP_PID.cpp + #AP_OpticalFlow_ADNS3080.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_PID.h + #AP_OpticalFlow_ADNS3080.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/AP_RangeFinder/CMakeLists.txt b/libraries/AP_RangeFinder/CMakeLists.txt new file mode 100644 index 0000000000..add2e2928e --- /dev/null +++ b/libraries/AP_RangeFinder/CMakeLists.txt @@ -0,0 +1,27 @@ +set(LIB_NAME AP_RangeFinder) + +set(${LIB_NAME}_SRCS + AP_RangeFinder_MaxsonarXL.cpp + AP_RangeFinder_SharpGP2Y.cpp + RangeFinder.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + AP_RangeFinder.h + AP_RangeFinder_MaxsonarXL.h + AP_RangeFinder_SharpGP2Y.h + RangeFinder.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt new file mode 100644 index 0000000000..ed27448a23 --- /dev/null +++ b/libraries/CMakeLists.txt @@ -0,0 +1,24 @@ +add_subdirectory(DataFlash) +add_subdirectory(AP_Math) +add_subdirectory(PID) +add_subdirectory(AP_Common) +add_subdirectory(RC_Channel) +add_subdirectory(AP_OpticalFlow) +add_subdirectory(ModeFilter) +add_subdirectory(memcheck) +add_subdirectory(APM_PI) +add_subdirectory(AP_GPS) +add_subdirectory(AP_DCM) +add_subdirectory(AP_Compass) +add_subdirectory(AP_ADC) +add_subdirectory(AP_IMU) +add_subdirectory(AP_RangeFinder) + +add_subdirectory(APM_RC) +add_subdirectory(APM_BMP085) + +#add_subdirectory(APO) +add_subdirectory(FastSerial) +add_subdirectory(GCS_MAVLink) + +#add_subdirectory(playgroundlib) diff --git a/libraries/DataFlash/CMakeLists.txt b/libraries/DataFlash/CMakeLists.txt new file mode 100644 index 0000000000..2e13294932 --- /dev/null +++ b/libraries/DataFlash/CMakeLists.txt @@ -0,0 +1,21 @@ +set(LIB_NAME DataFlash) + +set(${LIB_NAME}_SRCS + DataFlash.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + DataFlash.h + ) + +include_directories( + + - +# ${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/FastSerial/CMakeLists.txt b/libraries/FastSerial/CMakeLists.txt new file mode 100644 index 0000000000..78e94e9023 --- /dev/null +++ b/libraries/FastSerial/CMakeLists.txt @@ -0,0 +1,28 @@ +set(LIB_NAME FastSerial) + +set(${LIB_NAME}_SRCS + BetterStream.cpp + FastSerial.cpp + vprintf.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + BetterStream.h + FastSerial.h + ftoa_engine.h + ntz.h + xtoa_fast.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/GCS_MAVLink/CMakeLists.txt b/libraries/GCS_MAVLink/CMakeLists.txt new file mode 100644 index 0000000000..326d2b959c --- /dev/null +++ b/libraries/GCS_MAVLink/CMakeLists.txt @@ -0,0 +1,19 @@ +set(LIB_NAME GCS_MAVLink) + +set(${LIB_NAME}_SRCS + GCS_MAVLink.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + GCS_MAVLink.h +) + +include_directories( + #${CMAKE_SOURCE_DIR}/libraries/ + ${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/ModeFilter/CMakeLists.txt b/libraries/ModeFilter/CMakeLists.txt new file mode 100644 index 0000000000..cba4eec1b8 --- /dev/null +++ b/libraries/ModeFilter/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME ModeFilter) + +set(${LIB_NAME}_SRCS + ModeFilter.cpp + #AP_OpticalFlow_ADNS3080.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + ModeFilter.h + #AP_OpticalFlow_ADNS3080.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + #${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/PID/CMakeLists.txt b/libraries/PID/CMakeLists.txt new file mode 100644 index 0000000000..c814e841d1 --- /dev/null +++ b/libraries/PID/CMakeLists.txt @@ -0,0 +1,21 @@ +set(LIB_NAME PID) + +set(${LIB_NAME}_SRCS + PID.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + PID.h + ) + +include_directories( + + - + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/RC_Channel/CMakeLists.txt b/libraries/RC_Channel/CMakeLists.txt new file mode 100644 index 0000000000..94ed383fcb --- /dev/null +++ b/libraries/RC_Channel/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME RC_Channel) + +set(${LIB_NAME}_SRCS + RC_Channel.cpp + RC_Channel_aux.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + RC_Channel.h + RC_Channel_aux.h + ) + +include_directories( + + - + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + ${CMAKE_SOURCE_DIR}/libraries/APM_RC + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME}) diff --git a/libraries/memcheck/CMakeLists.txt b/libraries/memcheck/CMakeLists.txt new file mode 100644 index 0000000000..ec9121b1ce --- /dev/null +++ b/libraries/memcheck/CMakeLists.txt @@ -0,0 +1,24 @@ +set(LIB_NAME memcheck) + +set(${LIB_NAME}_SRCS + memcheck.cpp + #AP_OpticalFlow_ADNS3080.cpp + ) # Firmware sources + +set(${LIB_NAME}_HDRS + memcheck.h + #AP_OpticalFlow_ADNS3080.h + ) + +include_directories( + + - + #${CMAKE_SOURCE_DIR}/libraries/AP_Math + ${CMAKE_SOURCE_DIR}/libraries/AP_Common + #${CMAKE_SOURCE_DIR}/libraries/FastSerial +# + ) + +set(${LIB_NAME}_BOARD mega2560) + +generate_arduino_library(${LIB_NAME})