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

时间:2018-01-19 15:30:42

标签: c++ cmake msbuild 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).

1 个答案:

答案 0 :(得分:8)

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