如何将CMAKE生成的Makefile与Echo编译器的命令线进行?
在Linux上,我可以使用CMAKE构建一个C ++项目,例如:
$ mkdir build
$ cd build
$ cmake ../myproject
$ make
[ ] Building CXX object ...
是否有一种方法可以通过选项进行CMAKE或制造,以便它将打印完整的命令线(以及所有选项),它传递给C ++编译器以编译每个命令。对象文件?
(我尝试过:
$ make V=1
但是它似乎不起作用。我猜Cmake生成的Makefile不能适合该选项吗?)
On Linux I can build a C++ project with cmake like:
$ mkdir build
$ cd build
$ cmake ../myproject
$ make
[ ] Building CXX object ...
Is there a way to pass an option to cmake or make so that it will print the full command-lines (and all the options) it is passing to the C++ compiler to compile each object file?
(I tried:
$ make V=1
but it doesn't seem to work. I guess the cmake-generated Makefile doesn't work with that option?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按照此链接有三个选择(在HolyblackCat的答案中找到+1额外):
1
如果您可以 /要修改
cmakelists.txt < / code>,您只需添加
这必须在您的项目中的每个中完成每个 cmakelists.txt文件,因此,如果您想为整个项目启用它,可能会有些麻烦。
2
要将详细的更改直接更改为makefile,您可以运行CMAKE命令,该命令使用附加标志生成Make File:
并且您猜对了,要将其禁用,您需要再次运行它:
3
最后,如果您构建构建您的项目通过调用
制作
,并且不使用cmake -build ./path
或cmake -build -build ./ path -target target
命令,您可以将其作为选项直接传递给make
:尽管我不推荐它,因为它们的整个cmake的目的是不必再使用Make(尽管它仍然在幕后被调用) 。
As per this link There are three options (+1 extra found in the answer of HolyBlackCat):
1
If you can / want to modify the
CMakeLists.txt
, you can just addThis has to be done in every CMakeLists.txt file in your project though, so it might be a bit cumbersome, if you want to enable it for the entire project.
2
To write the verbose changes directly to the makefile, you can run the cmake command which generates the make file with an additional flag:
And, you guessed it, to disable it, you need to run it again:
3
Finally, if you build your project by calling
make
and do not use thecmake --build ./path
orcmake --build ./path --target target
commands, you can pass it as an option tomake
directly:Although I would not recommend it, because they whole point of cmake is to not have to use make anymore (although it's still called behind the scenes).
使用
make verbose = 1
或cmake -build&lt; path&gt; - Verbose
自动调用使用的生成器的正确命令。Use either
make VERBOSE=1
, orcmake --build <path> --verbose
which automatically invokes the right command for the generator you used.