View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013608CMakeCMakepublic2012-10-25 11:262013-03-04 08:38
ReporterDerek Bruening 
Assigned ToDavid Cole 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformVisual Studio 2008OSWindowsOS Version
Product VersionCMake 2.8.9 
Target VersionCMake 2.8.10Fixed in VersionCMake 2.8.10 
Summary0013608: execute_process() run from add_custom_command() via cmake -P fails to capture output for VS2008
Descriptionin my project I have a post-build custom command:

      add_custom_command(TARGET dynamorio POST_BUILD
        COMMAND ${CMAKE_COMMAND}
        ARGS -D lib=${drout}
             -D DUMPBIN_EXECUTABLE=${DUMPBIN_EXECUTABLE}
             -P ${CMAKE_CURRENT_SOURCE_DIR}/CMake_checkdeps.cmake
             VERBATIM)

where CMake_checkdeps.cmake is:

--------------------------------
execute_process(COMMAND
  ${DUMPBIN_EXECUTABLE} /dependents "${lib}"
  RESULT_VARIABLE deps_result
  ERROR_VARIABLE deps_error
  OUTPUT_VARIABLE deps_out
  )
if (deps_result OR deps_error)
  message(FATAL_ERROR "*** ${DEPS_EXECUTABLE} failed: ***\n${deps_error}")
endif (deps_result OR deps_error)
string(REGEX MATCH "following dependencies:.*Summary" dlls "${deps_out}")
string(REGEX REPLACE "\r?\n" "" dlls "${dlls}")
string(REGEX REPLACE "following dependencies: *" "" dlls "${dlls}")
string(REGEX REPLACE " *Summary" "" dlls "${dlls}")
if (NOT dlls MATCHES "^ntdll.dll$")
  message(FATAL_ERROR "*** Error: ${lib} depends on more than ntdll.dll: ${dlls}")
endif ()
----------------------------

This all works fine with VS2010. However, with VS2008, the output of dumpbin.exe is not captured and is instead printed out to the console/shell. The deps_error and deps_out variables are both empty.

If I run this custom_command at config time, it works fine. If I run the script through cmake -P it works fine whether from cmd or a cygwin rxvrt shell:

% cmake.exe -D lib=C:/src/dr/git/build_x86_dbg/lib32/debug/dynamorio.dll -D "DUMPBIN_EXECUTABLE=C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/dumpbin.exe" -P C:/src/dr/git/src/core/CMake_checkdeps.cmake

But when VS2008 runs the command, it fails due to not capturing the output.

The line in the .vcproj file is:

                        <Tool
                                Name="VCPostBuildEventTool"
CommandLine="C:\PROGRA~2\CMAKE2~1.8\bin\cmake.exe -D lib=C:/src/dr/git/build_x86_dbg/lib32/debug/dynamorio.dll -D "DUMPBIN_EXECUTABLE=C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/dumpbin.exe" -P C:/src/dr/git/src/core/CMake_checkdeps.cmake&#x0D;&#x0A;if errorlevel 1 goto :VCReportError"/>

If I substitute "cl.exe /help" for "dumpbin.exe ..." the same problem is there: the output is not captured.
Tagsclosed, resolved
Attached Files

 Relationships

  Notes
(0031324)
Brad King (manager)
2012-10-25 11:51

Add

 set(ENV{vsconsoleoutput} 1)

to prevent VS from redirecting its tool output.
(0031325)
David Cole (manager)
2012-10-25 11:53

Try adding this line before execute_process in your script:

  set(ENV{VS_UNICODE_OUTPUT} "")

Google for it, and read things like this:

  http://stackoverflow.com/questions/5298428/capture-build-output-within-visual-studio-2010 [^]

Not a CMake bug, I don't think... Just "silly" Microsoft tools behaviors.
(0031326)
Derek Bruening (reporter)
2012-10-25 12:32

Your suggestion does the trick:
  set(ENV{VS_UNICODE_OUTPUT} "")

Resolving.
(0031327)
Derek Bruening (reporter)
2012-10-25 12:35

I suppose one of you needs to resolve as the only thing in my interface is a "tag" which doesn't seem to do it.
(0031328)
David Cole (manager)
2012-10-25 12:43

Not really a CMake bug. See all the notes.
(0032488)
Robert Maynard (manager)
2013-03-04 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-10-25 11:26 Derek Bruening New Issue
2012-10-25 11:51 Brad King Note Added: 0031324
2012-10-25 11:53 David Cole Note Added: 0031325
2012-10-25 12:32 Derek Bruening Note Added: 0031326
2012-10-25 12:33 Derek Bruening Tag Attached: closed
2012-10-25 12:33 Derek Bruening Tag Attached: resolved
2012-10-25 12:35 Derek Bruening Note Added: 0031327
2012-10-25 12:43 David Cole Assigned To => David Cole
2012-10-25 12:43 David Cole Status new => assigned
2012-10-25 12:43 David Cole Note Added: 0031328
2012-10-25 12:43 David Cole Status assigned => resolved
2012-10-25 12:43 David Cole Fixed in Version => CMake 2.8.10
2012-10-25 12:43 David Cole Resolution open => no change required
2012-10-25 12:43 David Cole Target Version => CMake 2.8.10
2012-10-25 12:43 David Cole Description Updated
2013-03-04 08:38 Robert Maynard Note Added: 0032488
2013-03-04 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team