這兩天學習了CMakeLists.txt的規則和寫法
先給大家發幾個CMakeLists.txt的學習網址和官網doc
https://cmake.org/cmake-tutorial/ 【入門學習步驟】
http://blog.csdn.net/sunbaigui/article/details/6625547 【簡單示例】
https://cmake.org/Wiki/CMake_Useful_Variables 【常用變量名】
https://github.com/carl-wang-cn/demo/tree/master/cmake 【大量有實用價值的demo】
ok現在開始看openwrt下的cmakelists.txt,其實完全沒啥不一樣的,就幾行代碼就可以搞定了。。。
首先helloworld的makefile相比以前的有些變化
package/helloworld/Makefile
添加一行
Shell1 | include $(INCLUDE_DIR)/cmake.mk |
然后在src下沒有了makefile,而是CMakeLists.txt,注意文件的名的大小寫,出錯了就認不得了。。
#vim package/helloworld/src/CMakeLists.txt
Shell12345678 | cmake_minimum_required(VERSION2.6) #要求的最低cmake版本號PROJECT(hello_world) #項目名稱 SET(SOURCEShello_world.c) #設置變量SOURCES所指定的C文件ADD_EXECUTABLE(hello_world${SOURCES}) #設置最終生成的可執行文件名 INSTALL(TARGETShello_worldRUNTIMEDESTINATIONbin) #最后的install,必要的 |
把整體的源碼也貼出來吧!
hello_world.zip
歡迎任何人在此代碼的基礎上修改成自己的軟件包!
新聞熱點
疑難解答