參考案例px4cmakelists解讀_第1頁(yè)
參考案例px4cmakelists解讀_第2頁(yè)
參考案例px4cmakelists解讀_第3頁(yè)
參考案例px4cmakelists解讀_第4頁(yè)
參考案例px4cmakelists解讀_第5頁(yè)
已閱讀5頁(yè),還剩6頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

##Copyright(c)2015PX4DevelopmentTeam.Allrights.#Redistributionanduseinsourceandbinaryforms,withorwithout#modification,arepermittedprovidedthatthefollowingconditions#aremet:##1.Redistributionsofsourcecodemustretaintheabovecopyright notice,thislistofconditionsandthefollowingdier.#2.Redistributionsinbinaryformmustreproducetheabovecopyright notice,thislistofconditionsandthefollowingdierin theationand/orothermaterialsprovidedwith##3.NeitherthenamePX4northenamesofitscontributorsmaybe#usedtoendorseorpromoteproductsderivedfromthissoftware#withoutspecificpriorwrittenpermission.##THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS#"ASIS"ANDANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOT#LIMITEDTO,THEIMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESS#FORAPARTICULARPURPOSEAREDIED.INNOEVENTSHALLTHE#COPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,#AL,SPECIAL, RY,ORCONSEQUENTIALDAMAGES#BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODSORSERVICES;LOSS#OFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)HOWEVERCAUSED#ANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,#LIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGIN#ANYWAYOUTOFTHEUSEOFTHISSOFTWARE,EVENIFADVISEDOFTHE#POSSIBILITYOFSUCHDAMAGE.#CMAKECODINGSTANDARDFORPX4##*Commonfunctionsshouldbeincludedinpx_base.cmake.#*OS/board tionsshouldbeinclude#######*Usehardindentstomatchthepx4sourcecode.#*Allfunctionandscriptargumentsareuppercase.#*Alllocalvariablesarelowercase.#*Allcmakefunctionsarelowercase.#*Forelse,endif,endfunction,etc,neverputthenameofthe##Insteadoftheveryif(${var}STREQUAL"1")<--conditionnow#dosomthingesifelseif(${var}STREQUAL"2")<--anothercondition#dosomthingelse(${var}STREQUAL"1")<--tagisreferringtonameof#doendif(${var}STREQUAL"1")<--tagisreferringtonameofDoif(${var}STREQUAL"1")<--conditionnow#dosomthingesifelseif(${var}STREQUAL"2")<--anothercondition#dosomthingelse()<--leaveblank#dosomthingendif()<--leave###*Usepx4_parse_function_argstoparsefunctionsandcheckfor oneargument andit #*Neverusemacros.Theyallowoverwritingglobalvariablesandthis makesvariabledeclarationshardtolocate.##*Ifatargetfromadd_custom_*issetinafunction,explicitlypass asanoutputargumentsothatthetargetnameiscleartotheuser.##IncludedCMakeFiles##*Allvariablesinconfigfilesmusthavetheprefix##IncludedCMakeFiles##*Allvariablesinconfigfilesmusthavetheprefix"config_".#*Neversetglobalvariablesinanincludedcmake#youmayonlydefinefunctions.ThisexcludesconfigandToolchainfiles.Thismakesitcleartotheuserwhenvariablesarebeingsetortargetsarebeing#*SettingaglobalvariableinaCMakeLists.txtfileisok,#eachCMakeLists.txtfilehasscopeinthecurrentdirectoryandsubdirecties,soitisnottruly#*Alltoolchainfilesshouldbeincludedinthe##directoryandnamedToolchain-####*Ifreferencingastringvariable,don'tputitin#Don'tdo"${OS}"STREQUALinsteadtype${OS}STREQUAL"posix".Thiswillthrowanerrorwhen${OS}isnotdefinedinsteadofsilentlyevaluatingto#Warning:ChangingthismodifiesCMake'sinternal#andleadstowrongtoolchaincmake_minimum_required(VERSION2.8FATAL_ERROR) cmake_(VERSION從而將cmale的策略版本級(jí)別設(shè)置為指定的版本。當(dāng)指定的版本是 2.4或更低時(shí),這條命c(diǎn)make_(VERSION CMake Use #SET( PILER/usr/bin/clang-3.6)#SET( PILER/usr/bin/clang++-3.6) ## CMAKE_BUILD_TYPE"" CACHESTRING"build 把變量CMAKE_BUILD_TYPE CMakeGUI用來(lái)選擇一個(gè)帶有字符串“ buildtype CMAKE_BUILD_TYPEPROPERTYSTRINGS";Debug;Release;RelWithDebInfo;MinSizeRel") #在給定的作用域內(nèi)設(shè)置一個(gè)命名的屬性。CACHE作用域指定了一個(gè)名為CMAKE_BUILD_TYPE的cache中的條目。將其屬性值設(shè)置為;Debug;Release;RelWithDebInfo;MinSizeRel CACHESTRING"desired 變量CONFIG 賦值為"nuttx_px4fmu-v2_default" ,并且被CMakeGUI用來(lái)選擇一個(gè)帶有字符串"desiredconfiguration" RELATIVE 在路徑cmake/configs CONFIGPROPERTYSTRINGS${ "numberofthreadstouseforexternalbuild 把變量賦值為4,并且被 CMakeGUI "numberofthreadstouseforexternalbuildprocesses" set(DEBUG_PORT"/dev/ttyACM0"CACHESTRING"debuggingport") DEBUG_PORT賦值為"/dev/ttyACM0" CMakeGUI "debuggingport" #mustcomebeforeprojecttoset CE"_"";" ${CONFIG}) 將變量CONFIG中的 “;”,并輸出到變量 0OS) 在config_args 變量OS中(#nuttx 1BOARD) 2LABEL) #default #為 if("${OSSTREQUAL #ifset(DF_TARGETdarwin) set(DF_TARGETlinux) set(DF_TARGET # message(STATUS"${ #輸出一個(gè)非重要的消息,消息內(nèi)容為與操作系統(tǒng),#switchtorosCMakefileifbuildingif(${OS}STREQUAL #如果操作系統(tǒng) ros操作系統(tǒng)(機(jī)器人操作系統(tǒng)),就 else()#otherwiseusetherestofthisfilelist(APPENDCMAKE_MODULE_PATH${ CMAKE_SOURCE_DI}/cmake) #在名為 set(config_module"configs/${ 為config_module #包含路徑中的文cmake #展開(kāi) 所表示CMake的文#thebasicconceptofEcternalProjectissimple:givenanexternalsource toa.tar executethesequenceofcommandsnecessarytobuildandinstallthatsoftwaresothatyoucanrefertoit(include,link,run)fromyourproject.#requirepx4moduleinterface #將變量 foreach(cmd${px4_required_interface}) 遍歷px4_required_interface if(NOTCOMMANDmessage(FATAL_ERROR"${config_module}mustimplement${cmd}")) 將變量 的值置為 #遍歷 if(NOTDEFINEDmessage(FATAL_ERROR"cmake/${config_module}mustdefine${conf}")#project##project(px4CXXC#本工程的工程名 px4,支持的語(yǔ)言c++,cif(NOT${CMAKE_VERSION}VERSION_LESS3.0.0) cmake_(SETCMP0045NEW)#erroronnon-existenttargetingetpropcmake_(SETCMP0046NEW)#nonon-existenttargetsasdependenciescmake_(SETCMP0025OLD)#stillreportAppleClangasClangif(NOT${CMAKE_VERSION}VERSION_LESScmake_(SETCMP0054NEW)#don'tdereferencequotedvariablesset(version_patchset(version #設(shè)置為

REQUIRED)#查找并加載外來(lái)的工程設(shè)置,如果沒(méi)有找到的化就終止Cmake過(guò)程cmake ## #為當(dāng)前及其下級(jí) 的Gtest可以用于C/C++代 下的Makefile文件,將提供的 sample文件替換為我們自己的 make生成可執(zhí)行的測(cè)試文件。)#checkrequiredtoolchainvariables #檢測(cè)工具鏈所需的變量是否存在,否則停止 foreach(var${required_variables})if(NOTmessage(FATAL_ERROR"Toolchain/configmustdefine${var}")#git px4_add_git_submodule(TARGETgit_genmsgPATH"Tools/genmsg")px4_add_git_submodule(TARGETgit_gencppPATH"Tools/gencpp") px4_add_git_submodule(TARGETgit_gtestPATH"unittets/gtest")px4_add_git_submodule(TARGETgit_uavcanPATH"src/modules/uavcan/libuavcan")px4_add_git_submodule(TARGETgit_nuttxPATH"NuttX")px4_add_git_submodule(TARGETgit_dspalPATH"src/lib/dspal")px4_add_git_submodule(TARGETgit_driverframeworkPATHpx4_add_git_submodule(TARGETgit_eclPATH"src/lib/ecl")px4_add_git_submodule(TARGETgit_jmavsimPATH"Tools/jMAVSim")px4_add_git_submodule(TARGETgit_gazeboPATH"Tools/sitl_gazebo")px4_add_git_submodule(TARGETgit_matrixPATH"src/lib/matrix")#添加 COMMANDgitsubmoduledeinit-f.COMMANDrm-rf.git/modules/* #在指定 下上述指#misctargets #創(chuàng)建目 #創(chuàng)建目 BOARDTHREADS${THREAD}#構(gòu)建所需的線程 #生 #buildflags BOARDC_FLAGSc_flagsINCLUDE_DIRSinclude_dirsLINK_DIRSlink_dirsDEFINITIONSdefinitions)#設(shè)置操作系統(tǒng)的缺省 px4_join(OUTCMAKE_EXE_LINKER_FLAGSLIST"${exe_linker_flags}"GLUE"px4_join(OUTCMAKE_C_FLAGSLIST"${c_flags}"GLUE"")px4_join(OUTCMAKE_CXX_FLAGSLIST"${cxx_flags}"GLUE"")#向目標(biāo)中添加一個(gè)帶有分隔符 (原型在

# # #提供設(shè) -D... sourcecode ##file(GLOB_RECURSEmsg_filesmsg/*.msg) #在msg路徑下匹配所有擴(kuò)展名為 MSG_FILES${msg_files}OS)px4_generate_parameters_xml(OUTparameters.xmlBOARD${BOARD})px4_generate_airframes_xml(OUTairframes.xmlBOARD${BOARD}) 和 可以 set(ep_base #為 賦值。set_property(DIRECTORYPROPERTYEP_BASE${ep_base}) 的對(duì)象EP_BASE #addexternalprojectinstallfoldersto ##addt

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論