如何将CMAKE生成的Makefile与Echo编译器的命令线进行?

发布于 2025-02-14 02:02:41 字数 320 浏览 3 评论 0原文

在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长不大的小祸害 2025-02-21 02:02:41

按照此链接有三个选择(在HolyblackCat的答案中找到+1额外):

1

如果您可以 /要修改cmakelists.txt < / code>,您只需添加

set(CMAKE_VERBOSE_MAKEFILE ON)

这必须在您的项目中的每个中完成每个 cmakelists.txt文件,因此,如果您想为整个项目启用它,可能会有些麻烦。

2

要将详细的更改直接更改为makefile,您可以运行CMAKE命令,该命令使用附加标志生成Make File:

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ./path

并且您猜对了,要将其禁用,您需要再次运行它:

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF ./path

3

最后,如果您构建构建您的项目通过调用制作,并且不使用cmake -build ./pathcmake -build -build ./ path -target target命令,您可以将其作为选项直接传递给make

make VERBOSE=1;

尽管我不推荐它,因为它们的整个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 add

set(CMAKE_VERBOSE_MAKEFILE ON)

This 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:

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ./path

And, you guessed it, to disable it, you need to run it again:

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF ./path

3

Finally, if you build your project by calling make and do not use the cmake --build ./path or cmake --build ./path --target target commands, you can pass it as an option to make directly:

make VERBOSE=1;

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).

冷血 2025-02-21 02:02:41

使用make verbose = 1cmake -build&lt; path&gt; - Verbose自动调用使用的生成器的正确命令。

Use either make VERBOSE=1, or cmake --build <path> --verbose which automatically invokes the right command for the generator you used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文