6

I've got a cmake project that successfully does everything that I want. But I've got about 100 files, and I tire of seeing the huge output that is generated, 30 lines per file every time when I only need to recompile a single file.

To be clear, I'm compiling cmake --build . to get this result.

What is the parameter that I need to pass to the compiler (or MSBuild) to skip the printing that it checked the unchanged files? Compiling the project inside Visual Studio doesn't create all of this visual garbage.

This is the output that I'm getting for every unchanged file:

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).
PfunnyGuy
  • 750
  • 9
  • 22
  • any reason you're using the `--build .`? The CMakeCache should hold all the information it needs; and what arguments did you use to create the VS project in the first place? – UKMonkey Jan 19 '18 at 15:47
  • I'm using `--build .` to build use cmake in "Build Tool Mode" on the project in my currently directory. I'm on Windows, so I can't use `make`. – PfunnyGuy Jan 19 '18 at 16:36
  • @UKMonkey: I'm not sure I understand your second question. The only thing I've done as far as Visual Studio specs is: `set( CMAKE_GENERATOR "Visual Studio 15 2017 Win64" CACHE INTERNAL "" FORCE )` – PfunnyGuy Jan 19 '18 at 16:39

1 Answers1

11

You can pass additional arguments to the platfom specific build tool (MSBuild in this case) after the -- (see https://cmake.org/cmake/help/v3.10/manual/cmake.1.html for detailed description of --build and build-tool-options). I use the following command in my local build script cmake --build . --target INSTALL --config Debug -- /nologo /verbosity:minimal /l:FileLogger,Microsoft.Build.Engine;logfile=%CWD%\MSBuild_%BUILD_NAME%_%PLATFORM%_Debug.log for an almost quiet build.

vre
  • 6,041
  • 1
  • 25
  • 39
  • YES! I don't care to specify the log file, Debug is the default config, so I just did `cmake --build . -- /nologo /verbosity:minimal` and my build completed in one tenth of the time! – PfunnyGuy Jan 19 '18 at 18:42
  • Thanks for this! Is there a way to do this programmatically (i.e., within the CMakeLists.txt files), so that I don't have to type it at the command line every time? – qdin Apr 18 '18 at 06:16
  • @qdin I think there is but haven't tried that before. – vre Apr 18 '18 at 06:26
  • @qdin simply use `add_definitions(/nologo /verbosity:minimal)` – Mizux Apr 07 '20 at 13:24
  • 2
    @Mizux That won't work as those definitions are not passed to the native build tool - MSBuild in this case. Only the options given after `--` are passed to the build tool. See https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project `-- Pass remaining options to the native tool.` – vre Apr 07 '20 at 13:38