我运行cmake来生成一个VS2019项目:
> cmake -B Debug -S . --log-level=TRACE -G "Visual Studio 16 2019" -A Win32我建造它的时候:
> cmake --build Debug
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
<snip>我希望看到确切的命令行CMake正在执行,以实际启动构建引擎。
使用cmake --build Debug -v输出更多信息,但仍然没有显示构建引擎是如何启动的。
我也尝试过,但失败了:
>cmake --debug-output --trace --build Debug
Running with debug output on.
Running with trace output on.
CMake Error: Unknown argument --build
CMake Error: Run 'cmake --help' for all supported options.将--debug-output和--trace放在--build之后也失败了:
>cmake --build Debug --debug-output --trace
Unknown argument --debug-output
Usage: cmake --build <dir> [options] [-- [native-options]]
cmake --build --preset <preset> [options] [-- [native-options]]
Options:
<snip>如何让cmake --build输出用于构建的确切命令(exe和参数)?我又如何影响它呢?
发布于 2022-05-20 23:01:50
对于Visual生成器,CMake使用MSBuild (或者任何配置生成器的方法,实际上,我认为它是一种“实现定义”特性,不应该向用户公开)。
您可以找到MSBuild命令行选项这里的完整列表。为了向构建工具提供上述选项,请使用<build-tool-options> of CMake的--build命令。这里是(相当冗长的)日志记录:
cmake --build Debug -- -v:d如何使cmake输出用于构建的确切命令(exe和参数)?
正如我最初建议的,您最好使用CMake提供的抽象,但是您可能会发现一个有用的技巧(它的工作方式与构建工具无关),就是尝试为该工具指定一些garbarge选项,因此它会触发错误并公开一些细节:
cmake --build Debug -- garbarge在本例中,MSBuild实际上准确地打印了失败的命令(带有原始+ garbarge参数):
MSBUILD : error MSB1008: Only one project can be specified.
Full command line: '"C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m garbarge'https://stackoverflow.com/questions/72325125
复制相似问题