下面是一个 C++ 项目结构示例:
- {root}
- CMakeLists.txt
- build/
- compile_commands.json <-- This file gets generated
- src/
- CMakeLists.txt
- files here
- compile_commands.json <-- This is where I want compile_commands.json to be built to
Run Code Online (Sandbox Code Playgroud)
如果我构建项目,它会在“build”文件夹中创建一个“compile_commands.json”文件。但我实际上想要它在“{root}”下面。有没有办法指定compile_commands.json的位置?或者我必须手动复制它?
这些是我通常用来构建项目的命令
(如果 cd 进入 {root})
cmake . -B build
替代方案:
cd {root}/build && cmake ..
在这两种情况下,compile_commands.json 都会添加到构建文件夹中
有没有办法指定compile_commands.json的位置?
不可能。我相信设置CMAKE_EXPORT_COMPILE_COMMANDScompile_commands.json时生成的路径被硬编码为inside。 CMAKE_BINARY_DIR
只需创建一个符号链接compile_commands.json -> ./build/compile_commands.json。
| 归档时间: |
|
| 查看次数: |
5501 次 |
| 最近记录: |