{"title": "cmake\u5e38\u7528\u7b14\u8bb0", "update_time": "2022-04-18 22:40:00", "tags": "cmake", "pid": "361", "icon": "linux.png"}
### 一般编译过程 ``` mkdir build cmake .. make make install ``` ### 指定安装目录 ``` mkdir build cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. make make install ``` ### 指定gcc ``` export CC=/path-to-gcc export CXX=/path-to-g++ mkdir build cmake .. make make install ``` ### 为vscode生成 compile_commands.json ``` mkdir build cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. ``` 配置vscode, 编辑`.vscode/c_cpp_properties.json`, 主要是compileCommands配置,指向生成的 `compile_commands.json` ``` { "configurations": [ { "name": "gcc", "includePath": [], "defines": [], "compilerPath": "/usr/bin/g++", "cStandard": "gnu11", "cppStandard": "gnu++11", "intelliSenseMode": "gcc-x64", "compileCommands": "${workspaceFolder}/build/compile_commands.json" } ] } ```