MantisBT - CMake
View Issue Details
0012471CMakeCMakepublic2011-09-21 09:092012-02-06 06:07
Hauke Heibel 
Brad King 
normalminoralways
closedno change required 
Windows 7 Prof.
CMake 2.8.5 
 
0012471: CMake add_custom_command problem when triggering a FATAL_ERROR in MSVC
If have multiple custom commands which call

  message(FATAL_ERROR "Some message")

in case of errors. If you do this and encounter such a case MSVC generates many MSB3073 errors. I think this issue is somewhat related to http://public.kitware.com/Bug/view.php?id=11938. [^]

The problem is that the MSVC's error message hides the one generated by CMake. It were nice, if CMake could terminate the script without issuing multiple MSB3073 errors.
Create any custom command via

add_custom_command(TARGET FooCommand
  COMMAND ${CMAKE_COMMAND}
  -P BarScript.cmake
)

and call

message(FATAL_ERROR "Some message")

from within the BarScript.cmake
No tags attached.
txt msvc_error_output.txt (3,242) 2011-09-21 09:09
https://public.kitware.com/Bug/file/4058/msvc_error_output.txt
zip issue_12471.zip (989) 2011-09-22 02:42
https://public.kitware.com/Bug/file/4060/issue_12471.zip
Issue History
2011-09-21 09:09Hauke HeibelNew Issue
2011-09-21 09:09Hauke HeibelFile Added: msvc_error_output.txt
2011-09-21 16:39Brad KingNote Added: 0027466
2011-09-22 02:42Hauke HeibelFile Added: issue_12471.zip
2011-09-22 02:46Hauke HeibelNote Added: 0027467
2011-09-22 08:12Brad KingNote Added: 0027469
2011-09-22 08:17Brad KingNote Added: 0027470
2011-09-22 08:27Hauke HeibelNote Added: 0027471
2011-09-22 08:30Brad KingStatusnew => resolved
2011-09-22 08:30Brad KingResolutionopen => no change required
2011-09-22 08:30Brad KingAssigned To => Brad King
2012-02-06 06:07David ColeNote Added: 0028512
2012-02-06 06:07David ColeStatusresolved => closed

Notes
(0027466)
Brad King   
2011-09-21 16:39   
I cannot reproduce this. Please attach a source tarball/zip with a minimal example that reproduces this in a small source tree.

What CMake generator are you using?
(0027467)
Hauke Heibel   
2011-09-22 02:46   
I've added an example which I should have done it right away.

CMake version: 2.8.5
Generator: Visual Studio 10 Win64
Visual Studio: Version 10.0.40219.1 SP1Rel

HTH,
Hauke
(0027469)
Brad King   
2011-09-22 08:12   
I get this output:

2>------ Build started: Project: CopySatelliteDLLs, Configuration: Debug x64 ------
2>Build started 9/22/2011 8:05:11 AM.
2>InitializeBuildStatus:
2> Creating "x64\Debug\CopySatelliteDLLs\CopySatelliteDLLs.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>CustomBuild:
2> Copying satellite DLLs.
2> Building Custom Rule C:/.../issue_12471/CMakeLists.txt
2> CMake does not need to re-run because C:\...\issue_12471\b-vs10-64\CMakeFiles\generate.stamp is up-to-date.
2>PostBuildEvent:
2> CMake Error at C:/.../issue_12471/CopySatelliteDLLs.cmake:1 (message):
2> Triggering MSVC error.
2>
2>
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "setlocal
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -P "C:/.../issue_12471/CopySatelliteDLLs.cmake"
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :cmEnd
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :cmErrorLevel
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: exit /b %1
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :cmDone
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.24

It shows the error from the script and then reports the command that failed. What is wrong?
(0027470)
Brad King   
2011-09-22 08:17   
Even if I manually strip the post-build event down to _just_ the cmake -P invocation, I still get this:

2>------ Build started: Project: CopySatelliteDLLs, Configuration: Debug x64 ------
2>Build started 9/22/2011 8:15:41 AM.
2>InitializeBuildStatus:
2> Creating "x64\Debug\CopySatelliteDLLs\CopySatelliteDLLs.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>CustomBuild:
2> Copying satellite DLLs.
2>PostBuildEvent:
2> CMake Error at C:/.../issue_12471/CopySatelliteDLLs.cmake:1 (message):
2> Triggering MSVC error.
2>
2>
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command ""C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -P "C:/.../issue_12471/CopySatelliteDLLs.cmake"
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073:
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.12

It is VS that reports the MSB3073 errors, not CMake.
(0027471)
Hauke Heibel   
2011-09-22 08:27   
Ok, thanks for investigating this.

The more add_custom_command's I am adding to the same target the more errors I am seeing - basically 8 additional messages per DLL I am copying.

I was just hoping there was a way to suppress them on CMake's side.

- Hauke
(0028512)
David Cole   
2012-02-06 06:07   
Closing resolved issues that have not been updated in more than 4 months.