[CMake] can't pipe cl.exe in a custom command
Brandon Van Every
bvanevery at gmail.com
Tue Nov 6 01:09:37 EST 2007
I'm trying to grab the cl.exe banner so I can determine the MSVC
version number. If cl.exe is in the path, then the following works at
a Windows Command Prompt. This gives a short banner with the VC
version number and copyright.
cl /? 2> banner.txt
But when I try to do it in a custom command, I can't get it to pipe to
a file. I see the output go by in the Visual Studio output window,
with 1> prefixed in front of all the lines, and it is saved in
BuildLog.htm, but cbanner.txt has 0 length no matter whether I use >
1> 2> as the pipe. Does MSVC simply not have a notion of piping or
something? Do I have to do something MSVC-specific to capture the
output or the error?
IF(MSVC)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/cbanner.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_C_COMPILER} /? 2> cbanner.txt
)
ADD_CUSTOM_TARGET(cbanner ALL
DEPENDS ${CMAKE_BINARY_DIR}/cbanner.txt
)
ENDIF(MSVC)
Cheers,
Brandon Van Every
More information about the CMake
mailing list