CMake&Visual Studio:如何快速,安静的命令行构建?

Pfu*_*Guy 4 c++ msbuild cmake visual-studio-2017

我有一个cmake项目,成功完成了我想要的一切.但我有大约100个文件,我厌倦了看到生成的巨大输出,每次只需要重新编译单个文件时每个文件30行.

要清楚,我正在编译cmake --build . 以获得此结果.

我需要传递给编译器(或MSBuild)以跳过它检查未更改文件的打印的参数是什么?在Visual Studio中编译项目不会创建所有这些可视垃圾.

这是我为每个未更改的文件获取的输出:

Project "C:\noscan\working\proj\build\ALL_BUILD.vcxproj" (1) is building "C:\noscan\working\proj\build\os\src\oslib.vcxproj" (54) on node 1 (default targets).
InitializeBuildStatus:
  Creating "oslib.dir\Debug\oslib.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
PreBuildEvent:
  Description: Automatic MOC for target oslib
  setlocal
  cd C:\noscan\working\tadet\build\os\src
  if %errorlevel% neq 0 goto :cmEnd
  C:
  if %errorlevel% neq 0 goto :cmEnd
  C:\cmake\bin\cmake.exe -E cmake_autogen     C:/noscan/working/tadet/build/os/src/CMakeFiles/oslib_autogen.dir Debug
  if %errorlevel% neq 0 goto :cmEnd
  :cmEnd
  endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
  :cmErrorLevel
  exit /b %1
  :cmDone
  if %errorlevel% neq 0 goto :VCEnd
  :VCEnd
CustomBuild:
  All outputs are up-to-date.
ClCompile:
  All outputs are up-to-date.
Lib:
  All outputs are up-to-date.
  oslib.vcxproj -> C:\noscan\working\proj\build\os\src\oslib.dir\Debug\oslib.lib
FinalizeBuildStatus:
  Deleting file "oslib.dir\Debug\oslib.tlog\unsuccessfulbuild".
  Touching "oslib.dir\Debug\oslib.tlog\oslib.lastbuildstate".
Done Building Project "C:\noscan\working\proj\build\os\src\oslib.vcxproj" (default targets).
Run Code Online (Sandbox Code Playgroud)

vre*_*vre 9

您可以在--(请参阅https://cmake.org/cmake/help/v3.10/manual/cmake.1.html以获取详细说明--buildbuild-tool-options)之后将其他参数传递给platfom特定构建工具(本例中为MSBuild ). .我在本地构建脚本中使用以下命令cmake --build . --target INSTALL --config Debug -- /nologo /verbosity:minimal /l:FileLogger,Microsoft.Build.Engine;logfile=%CWD%\MSBuild_%BUILD_NAME%_%PLATFORM%_Debug.log进行几乎安静的构建.

  • @Mizux 这不会起作用,因为这些定义不会传递给本机构建工具 - 在这种情况下为 MSBuild。只有“--”之后给出的选项才会传递给构建工具。请参阅 https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project `-- 将剩余选项传递给本机工具。` (2认同)