Error messages are printed to different streams for different generators
In general, I would expect error-messages which occur during compilation/linking to be printed on stderr
. However, some generators instead print their error-messages to stdout
.
This complicates creating tests which try to match error-output against expected error-output generator-independent.
(This is true in particular for RunCMake
-tests of CMake itself.)
This also seems to have impact on the exit-code with which such a failing test returns.
For example, during development of !1524 (merged) the same error in the test-suite appeared on different platforms and generators on different streams:
OSX with Makefile generator (prints to stderr
) :
CMake Error at /Users/kitware/buildslave/cmake-moonshade-osx-release-makefiles with spaces/source/Tests/RunCMake/RunCMake.cmake:150 (message):
LinkObjRHSStatic2-build - FAILED:
Result is [2], not [0].
stderr does not match that expected.
Command was:
command> "/Users/kitware/buildslave/cmake-moonshade-osx-release-makefiles with spaces/build/bin/cmake" "--build" "."
Actual stdout:
actual-out> Scanning dependencies of target AnObjLib
actual-out> [ 20%] Building C object CMakeFiles/AnObjLib.dir/a.c.o
actual-out> [ 20%] Built target AnObjLib
actual-out> Scanning dependencies of target A
actual-out> [ 40%] Building C object CMakeFiles/A.dir/b.c.o
actual-out> [ 60%] Linking C static library libA.a
actual-out> [ 60%] Built target A
actual-out> Scanning dependencies of target exe
actual-out> [ 80%] Building C object CMakeFiles/exe.dir/exe.c.o
Expected stderr to match:
expect-err> ^$
Actual stderr:
actual-err> /Users/kitware/buildslave/cmake-moonshade-osx-release-makefiles with spaces/source/Tests/RunCMake/ObjectLibrary/exe.c:7:2: error: "REQUIRED needs to be defined"
actual-err> #error "REQUIRED needs to be defined"
actual-err> ^
actual-err> 1 error generated.
actual-err> make[2]: *** [CMakeFiles/exe.dir/exe.c.o] Error 1
actual-err> make[1]: *** [CMakeFiles/exe.dir/all] Error 2
actual-err> make: *** [all] Error 2
Call Stack (most recent call first):
/Users/kitware/buildslave/cmake-moonshade-osx-release-makefiles with spaces/source/Tests/RunCMake/RunCMake.cmake:164 (run_cmake)
/Users/kitware/buildslave/cmake-moonshade-osx-release-makefiles with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:22 (run_cmake_command)
/Users/kitware/buildslave/cmake-moonshade-osx-release-makefiles with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:42 (run_object_lib_build)
Linux with Makefile generator (prints to stderr
) :
CMake Error at /home/buildbot/buildbot-slave/cmake-hythloth-linux-debug-makefiles_sphinx/source/Tests/RunCMake/RunCMake.cmake:150 (message):
LinkObjRHSStatic2-build - FAILED:
Result is [2], not [0].
stderr does not match that expected.
Command was:
command> "/home/buildbot/buildbot-slave/cmake-hythloth-linux-debug-makefiles_sphinx/build/bin/cmake" "--build" "."
Actual stdout:
actual-out> Scanning dependencies of target AnObjLib
actual-out> [ 20%] Building C object CMakeFiles/AnObjLib.dir/a.c.o
actual-out> [ 20%] Built target AnObjLib
actual-out> Scanning dependencies of target A
actual-out> [ 40%] Building C object CMakeFiles/A.dir/b.c.o
actual-out> [ 60%] Linking C static library libA.a
actual-out> [ 60%] Built target A
actual-out> Scanning dependencies of target exe
actual-out> [ 80%] Building C object CMakeFiles/exe.dir/exe.c.o
actual-out> CMakeFiles/exe.dir/build.make:62: recipe for target 'CMakeFiles/exe.dir/exe.c.o' failed
actual-out> CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/exe.dir/all' failed
actual-out> Makefile:83: recipe for target 'all' failed
Expected stderr to match:
expect-err> ^$
Actual stderr:
actual-err> /home/buildbot/buildbot-slave/cmake-hythloth-linux-debug-makefiles_sphinx/source/Tests/RunCMake/ObjectLibrary/exe.c:7:2: error: #error "REQUIRED needs to be defined"
actual-err> #error "REQUIRED needs to be defined"
actual-err> ^~~~~
actual-err> make[2]: *** [CMakeFiles/exe.dir/exe.c.o] Error 1
actual-err> make[1]: *** [CMakeFiles/exe.dir/all] Error 2
actual-err> make: *** [all] Error 2
Call Stack (most recent call first):
/home/buildbot/buildbot-slave/cmake-hythloth-linux-debug-makefiles_sphinx/source/Tests/RunCMake/RunCMake.cmake:164 (run_cmake)
/home/buildbot/buildbot-slave/cmake-hythloth-linux-debug-makefiles_sphinx/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:22 (run_cmake_command)
/home/buildbot/buildbot-slave/cmake-hythloth-linux-debug-makefiles_sphinx/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:42 (run_object_lib_build)
OSX with Ninja generator (prints to stdout
) :
CMake Error at /Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/source/Tests/RunCMake/RunCMake.cmake:150 (message):
LinkObjRHSStatic2-build - FAILED:
Result is [1], not [0].
Command was:
command> "/Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/build/bin/cmake" "--build" "."
Actual stdout:
actual-out> [1/5] Building C object CMakeFiles/exe.dir/exe.c.o
actual-out> FAILED: CMakeFiles/exe.dir/exe.c.o
actual-out> /Applications/Xcode-9.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -isysroot /Applications/Xcode-9.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -MD -MT CMakeFiles/exe.dir/exe.c.o -MF CMakeFiles/exe.dir/exe.c.o.d -o CMakeFiles/exe.dir/exe.c.o -c '/Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/source/Tests/RunCMake/ObjectLibrary/exe.c'
actual-out> /Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/source/Tests/RunCMake/ObjectLibrary/exe.c:7:2: error: "REQUIRED needs to be defined"
actual-out> #error "REQUIRED needs to be defined"
actual-out> ^
actual-out> 1 error generated.
actual-out> [2/5] Building C object CMakeFiles/A.dir/b.c.o
actual-out> [3/5] Building C object CMakeFiles/AnObjLib.dir/a.c.o
actual-out> ninja: build stopped: subcommand failed.
Actual stderr:
actual-err>
Call Stack (most recent call first):
/Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/source/Tests/RunCMake/RunCMake.cmake:164 (run_cmake)
/Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:22 (run_cmake_command)
/Users/kitware/buildslave/cmake-moonshade-osx-debug-ninja with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:42 (run_object_lib_build)
Windows with Ninja generator (prints to stdout
) :
CMake Error at C:/bbd/cmake-dash3win7-windows-release-ninja with spaces/source/Tests/RunCMake/RunCMake.cmake:150 (message):
LinkObjRHSStatic2-build - FAILED:
Result is [1], not [0].
Command was:
command> "C:/bbd/cmake-dash3win7-windows-release-ninja with spaces/build/bin/cmake.exe" "--build" "."
Actual stdout:
actual-out> [3/5] Building C object CMakeFiles\A.dir\b.c.obj
actual-out> [3/5] Building C object CMakeFiles\exe.dir\exe.c.obj
actual-out> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe /nologo /DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\exe.dir\exe.c.obj /FdCMakeFiles\exe.dir\ /FS -c "C:\bbd\cmake-dash3win7-windows-release-ninja with spaces\source\Tests\RunCMake\ObjectLibrary\exe.c"
actual-out> C:\bbd\cmake-dash3win7-windows-release-ninja with spaces\source\Tests\RunCMake\ObjectLibrary\exe.c(7): fatal error C1189: #error: "REQUIRED needs to be defined"
actual-out> [3/5] Building C object CMakeFiles\AnObjLib.dir\a.c.obj
actual-out> ninja: build stopped: subcommand failed.
Actual stderr:
actual-err>
Call Stack (most recent call first):
C:/bbd/cmake-dash3win7-windows-release-ninja with spaces/source/Tests/RunCMake/RunCMake.cmake:164 (run_cmake)
C:/bbd/cmake-dash3win7-windows-release-ninja with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:22 (run_cmake_command)
C:/bbd/cmake-dash3win7-windows-release-ninja with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:42 (run_object_lib_build)
Windows with VS2017 generator (prints to stdout
) :
CMake Error at C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/RunCMake.cmake:150 (message):
LinkObjRHSStatic2-build - FAILED:
Result is [1], not [0].
Command was:
command> "C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/build/bin/Release/cmake.exe" "--build" "."
Actual stdout:
actual-out> Microsoft (R) Build Engine version 15.5.179.9764 for .NET Framework
actual-out> Copyright (C) Microsoft Corporation. All rights reserved.
actual-out>
actual-out> Build started 1/8/2018 3:40:40 PM.
actual-out> Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ALL_BUILD.vcxproj" on node 1 (default targets).
actual-out> Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ALL_BUILD.vcxproj" (1) is building "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
actual-out> PrepareForBuild:
actual-out> Creating directory "x64\Debug\ZERO_CHECK\".
actual-out> Creating directory "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\".
actual-out> InitializeBuildStatus:
actual-out> Creating "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
actual-out> CustomBuild:
actual-out> Checking Build System
actual-out> CMake does not need to re-run because C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/build/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2-build/CMakeFiles/generate.stamp is up-to-date.
actual-out> FinalizeBuildStatus:
actual-out> Deleting file "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
actual-out> Touching "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
actual-out> Done Building Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ZERO_CHECK.vcxproj" (default targets).
actual-out> Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ALL_BUILD.vcxproj" (1) is building "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\A.vcxproj" (3) on node 1 (default targets).
actual-out> Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\A.vcxproj" (3) is building "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\AnObjLib.vcxproj" (4) on node 1 (default targets).
actual-out> PrepareForBuild:
actual-out> Creating directory "AnObjLib.dir\Debug\".
actual-out> Creating directory "AnObjLib.dir\Debug\AnObjLib.tlog\".
actual-out> InitializeBuildStatus:
actual-out> Creating "AnObjLib.dir\Debug\AnObjLib.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
actual-out> CustomBuild:
actual-out> Building Custom Rule C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/ObjectLibrary/CMakeLists.txt
actual-out> CMake does not need to re-run because C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/build/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2-build/CMakeFiles/generate.stamp is up-to-date.
actual-out> ClCompile:
actual-out> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"AnObjLib.dir\Debug\\" /Fd"AnObjLib.dir\Debug\AnObjLib.pdb" /Gd /TC /errorReport:queue "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\source\Tests\RunCMake\ObjectLibrary\a.c"
actual-out> a.c
actual-out> Lib:
actual-out> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\Lib.exe /OUT:"AnObjLib.dir\Debug\AnObjLib.lib" /NOLOGO /MACHINE:X64 /machine:x64 AnObjLib.dir\Debug\a.obj
actual-out> AnObjLib.vcxproj -> C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\AnObjLib.dir\Debug\AnObjLib.lib
actual-out> FinalizeBuildStatus:
actual-out> Deleting file "AnObjLib.dir\Debug\AnObjLib.tlog\unsuccessfulbuild".
actual-out> Touching "AnObjLib.dir\Debug\AnObjLib.tlog\AnObjLib.lastbuildstate".
actual-out> Done Building Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\AnObjLib.vcxproj" (default targets).
actual-out> PrepareForBuild:
actual-out> Creating directory "A.dir\Debug\".
actual-out> Creating directory "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\Debug\".
actual-out> Creating directory "A.dir\Debug\A.tlog\".
actual-out> InitializeBuildStatus:
actual-out> Creating "A.dir\Debug\A.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
actual-out> CustomBuild:
actual-out> Building Custom Rule C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/ObjectLibrary/CMakeLists.txt
actual-out> CMake does not need to re-run because C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/build/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2-build/CMakeFiles/generate.stamp is up-to-date.
actual-out> ClCompile:
actual-out> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D REQUIRED /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"A.dir\Debug\\" /Fd"A.dir\Debug\A.pdb" /Gd /TC /errorReport:queue "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\source\Tests\RunCMake\ObjectLibrary\b.c"
actual-out> b.c
actual-out> Lib:
actual-out> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\Lib.exe /OUT:"C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\Debug\A.lib" /NOLOGO /MACHINE:X64 /machine:x64 A.dir\Debug\b.obj
actual-out> "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\AnObjLib.dir\Debug\a.obj"
actual-out> A.vcxproj -> C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\Debug\A.lib
actual-out> CopyFilesToOutputDirectory:
actual-out> Copying file from "A.dir\Debug\A.pdb" to "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\Debug\A.pdb".
actual-out> FinalizeBuildStatus:
actual-out> Deleting file "A.dir\Debug\A.tlog\unsuccessfulbuild".
actual-out> Touching "A.dir\Debug\A.tlog\A.lastbuildstate".
actual-out> Done Building Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\A.vcxproj" (default targets).
actual-out> Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ALL_BUILD.vcxproj" (1) is building "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\exe.vcxproj" (5) on node 1 (default targets).
actual-out> PrepareForBuild:
actual-out> Creating directory "exe.dir\Debug\".
actual-out> Creating directory "exe.dir\Debug\exe.tlog\".
actual-out> InitializeBuildStatus:
actual-out> Creating "exe.dir\Debug\exe.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
actual-out> CustomBuild:
actual-out> Building Custom Rule C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/ObjectLibrary/CMakeLists.txt
actual-out> CMake does not need to re-run because C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/build/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2-build/CMakeFiles/generate.stamp is up-to-date.
actual-out> ClCompile:
actual-out> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"exe.dir\Debug\\" /Fd"exe.dir\Debug\vc141.pdb" /Gd /TC /errorReport:queue "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\source\Tests\RunCMake\ObjectLibrary\exe.c"
actual-out> exe.c
actual-out> C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\source\Tests\RunCMake\ObjectLibrary\exe.c(7): fatal error C1189: #error: "REQUIRED needs to be defined" [C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\exe.vcxproj]
actual-out> Done Building Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\exe.vcxproj" (default targets) -- FAILED.
actual-out> Done Building Project "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ALL_BUILD.vcxproj" (default targets) -- FAILED.
actual-out>
actual-out> Build FAILED.
actual-out>
actual-out> "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\ALL_BUILD.vcxproj" (default target) (1) ->
actual-out> "C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\exe.vcxproj" (default target) (5) ->
actual-out> (ClCompile target) ->
actual-out> C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\source\Tests\RunCMake\ObjectLibrary\exe.c(7): fatal error C1189: #error: "REQUIRED needs to be defined" [C:\bbd\cmake-terfin-windows-release-vs2017 with spaces\build\Tests\RunCMake\ObjectLibrary\LinkObjRHSStatic2-build\exe.vcxproj]
actual-out>
actual-out> 0 Warning(s)
actual-out> 1 Error(s)
actual-out>
actual-out> Time Elapsed 00:00:04.39
Actual stderr:
actual-err>
Call Stack (most recent call first):
C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/RunCMake.cmake:164 (run_cmake)
C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:22 (run_cmake_command)
C:/bbd/cmake-terfin-windows-release-vs2017 with spaces/source/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake:42 (run_object_lib_build)