[cmake-developers] execute_process inconsitancy
Brad King
brad.king at kitware.com
Mon Sep 3 16:04:20 EDT 2012
On 09/03/2012 03:04 PM, J Decker wrote:
> I use this command to get the current repository version number.
>
> Under windows I have to use 'cmd /c ...'
> under linux or I obviously can't use that.
>
> Is there a test I can do in a cmakelists to test the shell processor?
>
> Is there something I can do to make this the same command?
>
> Under windows, without cmd /c .... the output variable is blank.
>
>
> if( WIN32 )
>
> execute_process( COMMAND cmd /c hg id -i WORKING_DIRECTORY
> ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE TMP_CURRENT_REPO_REVISION )
>
> else( WIN32 )
>
> execute_process( COMMAND hg id -i WORKING_DIRECTORY
> ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE TMP_CURRENT_REPO_REVISION )
>
> endif( WIN32 )
The command operates the same way on both platforms.
My guess is that "hg" is printing to stderr on Windows.
Try this:
execute_process(
COMMAND hg id -i
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE TMP_CURRENT_REPO_REVISION
ERROR_VARIABLE TMP_CURRENT_REPO_REVISION
)
-Brad
More information about the cmake-developers
mailing list