diff --git "a/src/\345\215\242\347\221\237\346\227\245\347\273\217/C++ \345\214\205\347\256\241\347\220\206\357\274\214\347\274\226\350\257\221\346\236\204\345\273\272\351\205\215\347\275\256\347\255\211\351\227\256\351\242\230.md" "b/src/\345\215\242\347\221\237\346\227\245\347\273\217/C++ \345\214\205\347\256\241\347\220\206\357\274\214\347\274\226\350\257\221\346\236\204\345\273\272\351\205\215\347\275\256\347\255\211\351\227\256\351\242\230.md" index b68c8fa9..94fa25b3 100644 --- "a/src/\345\215\242\347\221\237\346\227\245\347\273\217/C++ \345\214\205\347\256\241\347\220\206\357\274\214\347\274\226\350\257\221\346\236\204\345\273\272\351\205\215\347\275\256\347\255\211\351\227\256\351\242\230.md" +++ "b/src/\345\215\242\347\221\237\346\227\245\347\273\217/C++ \345\214\205\347\256\241\347\220\206\357\274\214\347\274\226\350\257\221\346\236\204\345\273\272\351\205\215\347\275\256\347\255\211\351\227\256\351\242\230.md" @@ -11,16 +11,21 @@ root@Mq-B:/usr/local/include# which cmake /usr/bin/cmake ``` -如果是 window,可以使用 `Get-Command`: +如果是 windows,powershell 可以使用 `Get-Command`、`where.exe`: ```powershell -PS C:\Users\Administrator> Get-Command cmake +PS C:\Users\A1387> Get-Command cmake CommandType Name Version Source ----------- ---- ------- ------ -Application cmake.exe 3.30.0.0 D:\CMake\bin\cmake.exe +Application cmake.exe 3.25.2.0 D:\CLion 2023.1.4\bin\cmake\win\x64\bin\cmake.exe + +PS C:\Users\A1387> where.exe cmake +D:\CLion 2023.1.4\bin\cmake\win\x64\bin\cmake.exe ``` +> CMD 终端直接使用 **`where`** 即可。powershell 终端要强调 `.exe` 是因为 where 这个名字被用作另一个东西的别名了。 + ## `make` `make` 是一个自动化构建工具,通常与 Makefile 配合使用。Makefile 中定义了如何编译和链接程序的规则。通过运行 make 命令,make 命令会读取 Makefile,自动执行编译和链接的步骤。基本用法如下: @@ -428,9 +433,10 @@ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. 不过显然我们无需这样做,我们最好的做法是直接: ```shell -cmake .. -G "Ninja Multi-Config" +cmake .. -G Ninja cmake --build . --config Debug --parallel +cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. cmake --build . --config Release --parallel ``` -若不指定构建类型,则采用默认构建类型,一般为 Debug 。 +没办法,必须多次运行 `cmake..` 生成需要的 Ninja 文件,这点比较特殊。