CMake的荣誉的环境变量CC和CXX在检测到所述C和C++编译器使用.例如,如果这些变量指向clang,它将默认使用clang:
$ export CC=/usr/bin/clang
$ export CXX=/usr/bin/clang++
$ cmake ..
-- The C compiler identification is Clang
-- The CXX compiler identification is Clang
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
...
Run Code Online (Sandbox Code Playgroud)
您可以将这些定义为指向首选编译器的系统范围的环境变量,也可以编写一个小的shell包装脚本来测试多个编译器的可用性,并在调用cmake之前相应地设置变量.
| 归档时间: |
|
| 查看次数: |
5995 次 |
| 最近记录: |