【发布时间】:2020-02-07 02:39:37
【问题描述】:
我正在尝试使用 cmake 构建为 google-cloud-cpp 项目生成 compile_commands.json。我试过这个:
$ cmake -DBUILD_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -Hsuper -Bcmake-out
-- The CXX compiler identification is AppleClang 10.0.1.10010046
.....
.....
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_TESTING
$ cmake --build cmake-out -- -j 4
.....
.....
[ 98%] Performing test step for 'google_cloud_cpp_project'
Start 1: bucket_access_control_test
1/143 Test #1: bucket_access_control_test ................................ Passed 0.02 sec
.....
.....
100% tests passed, 0 tests failed out of 143
Total Test time (real) = 19.13 sec
[100%] Completed 'google_cloud_cpp_project'
[100%] Built target google_cloud_cpp_project
有一件事是 BUILD_TESTING 似乎被忽略了 - 它在生成构建文件并运行所有测试时产生一条消息。对我来说更直接的事情是即使设置了标志也不会产生 compile_commands.json 。这两个设置都显示在 cmake-out/CMakeCache.txt
$ grep -E 'BUILD_TESTING|COMPILE_C' cmake-out/CMakeCache.txt
BUILD_TESTING:UNINITIALIZED=OFF
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON
//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
我错过了什么吗?我应该做其他事情吗?任何帮助表示赞赏。
【问题讨论】:
标签: c++