[cmake-developers] execute_process inconsitancy

David Cole david.cole at kitware.com
Mon Sep 3 18:58:26 EDT 2012


OK... Is hg.exe in the PATH? Do you get different results if you use
the full path to hg.exe rather than just "hg"?


On Mon, Sep 3, 2012 at 5:48 PM, J Decker <d3ck0r at gmail.com> wrote:
> dir "c:\Program Files\tortoisehg
>  Volume in drive C has no label.
>  Volume Serial Number is F05B-C5AF
>
>  Directory of c:\Program Files\tortoisehg
> ....
> 08/20/2012  10:47 PM            33,544 hg.exe
> ....
>
> I don't know what hy.py would be .....
>
> On Mon, Sep 3, 2012 at 2:37 PM, David Cole <david.cole at kitware.com> wrote:
>> On Mon, Sep 3, 2012 at 5:15 PM, J Decker <d3ck0r at gmail.com> wrote:
>>> On Mon, Sep 3, 2012 at 1:04 PM, Brad King <brad.king at kitware.com> wrote:
>>>> 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 )
>>>>>
>>>
>>> execute_process( COMMAND hg id -i WORKING_DIRECTORY
>>> ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE TMP_CURRENT_REPO_REVISION
>>> ERROR_VARIABLE TMP_CURRENT_REPO_REVISION2 )
>>> message( "1)" ${TMP_CURRENT_REPO_REVISION} )
>>> message( "1)" ${TMP_CURRENT_REPO_REVISION2} )
>>>
>>> both revision and revision2 are blank, (without cmd /c before)
>>>
>>>>> 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
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
>>
>>
>> On Windows, "hg" is not an executable file, so execute_process is
>> probably not even running it. If you instead say:
>>
>>   COMMAND C:/python26/python.exe C:/path/to/hg.py (... args ...)
>>
>> does that work?



More information about the cmake-developers mailing list