Cmake json question === #### 測試紀錄 Q :是否需要一定使用 main.cpp 當作主程式? A:不需要-->可以隨便取檔名 檔名間有空隔也行 #### 關於 Cmake ,make,gcc和clang gcc和clang 是兩個不同的編譯器,而make和cmake是搭配編譯器來方便用戶進行多文件編譯而發明的工具--> gcc clang g++ 都是編譯器,但若要編輯比較大型的include 檔案 則需要每一個 source 檔案都編譯一次,所以會借助 Makefile 和 CMakeList.txt 來編譯,Cmake 會生成makefile 而 makefile 則可以編出執行檔 在終端機則需要執行 (cmake ..)(.. 是必須寫的) 再執行make 來源: https://zhuanlan.zhihu.com/p/64373941 #### 關於json 1. 都置於 .vscode 資料夾內 2. launch.json #### 關於Debugger 的設定 ${cwd} the task runner's current working directory on startup https://jeasonstudio.gitbooks.io/vscode-cn-doc/content/md/%E7%BC%96%E8%BE%91%E5%99%A8/%E4%BB%BB%E5%8A%A1.html #### task.jason 關於task 的內容 task 可以由ctrl + shift + P 呼叫 Task : Run Task label 設定 Task 的名稱 ``` "kind" : "build" "isDefault" : true --> ctrl + shift + B 原生快捷鍵 "key" : "ctrl+u" --> ctrl + U 為自訂快捷鍵 "commend" "", 為再終端機中要下的指令 "dependsOrder": "sequence", 可以將許多指令包在一起執行 有分串聯和並聯 "dependsOn":[ "cmake", "make", "Run_code" ] ``` --> 依照上下順序 逐依執行 Variable substitution ``` ${workspaceRoot} VS Code中打开的文件夹的路径 ${workspaceRoot} the path of the folder opened in VS Code ${file} 当前打开的文件路径 ${file} the current opened file ${relativeFile} 当前打开的文件相对于workspaceRoot的路径 ${relativeFile} the current opened file relative to workspaceRoot ${fileBasename} 当前打开的文件的basename ${fileBasename} the current opened file's basename ${fileDirname} 当前打开的文件的文件夹名 ${fileDirname} the current opened file's dirname ${fileExtname} 当前打开的文件扩展名 ${fileExtname} the current opened file's extension ${cwd} 任务运行器启动时的当前路径 ${cwd} the task runner's current working directory on startup ``` #### 關於 CMakeList.txt 1. 關於cmake路經 --> cmake 指令再尋找 CMakeList.txt 所以指令下下去,是依照目前所在的資料夾和CMakeList.txt 所在的相對關係 cmake . 表示CMakeList.txt 在cwd 中 cmake .. 表示再上一層目錄 https://stackoverflow.com/questions/29792540/what-is-the-meaning-of-cmake-command-lines 1. 基本單個檔案 ``` # CMake 最低版本需求 cmake_minimum_required (VERSION 2.8) # project 名稱--> 可以自取 project (Demo2) # 查找當前目錄下的所有源文件 # 並將名稱保存到 DIR_SRCS 變量 --> DIR_SRCS 變量名稱是可以自取的 aux_source_directory(. DIR_SRCS) # 指定生成目標 add_executable(Demo ${DIR_SRCS}) ``` 2. 多個檔案再不同的目錄 https://www.hahack.com/codes/cmake/#%E6%94%AF%E6%8C%81-gdb 3. 其餘基礎用法 https://www.hahack.com/codes/cmake/#%E6%94%AF%E6%8C%81-gdb
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up