Clion是一款跨平台的C/C++编译工具,它在2020版本之前只支持Cmake项目,在2020版后增加了对compilation database projects的支持,所以我们将Makefile项目转换为compilation database projects,就可以用clion进行编译调试。下面详细记录下用2020版Clion编译调试Makefile项目的过程。
1. 将Makefile项目转为compilation database项目
安装compiledb工具:pip install compiledb
将makefile转换为compile_commands.json文件:compiledb -nf make
用clion打开生成的compile_commands.json文件,并选择Open as Project
![eeb5db4e3cfcdef63adb096072385274.png](https://img-blog.csdnimg.cn/img_convert/eeb5db4e3cfcdef63adb096072385274.png)
2. 配置clion的编译调试参数
打开Settings / Preferences | Build, Execution, Deployment | Custom Build Targets,创建一个targets,例如取名为wt10,点击下面Build和Clean右边的...按钮