[cmake-developers] [CMake 0013608]: execute_process() run from add_custom_command() via cmake -P fails to capture output for VS2008

Mantis Bug Tracker mantis at public.kitware.com
Thu Oct 25 11:26:46 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13608 
====================================================================== 
Reported By:                Derek Bruening
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13608
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-10-25 11:26 EDT
Last Modified:              2012-10-25 11:26 EDT
====================================================================== 
Summary:                    execute_process() run from add_custom_command() via
cmake -P fails to capture output for VS2008
Description: 
in 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.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-10-25 11:26 Derek Bruening New Issue                                    
======================================================================




More information about the cmake-developers mailing list