[CMake] Running shell scripts...

Benjamen R. Meyer bm_witness at yahoo.com
Mon Feb 4 19:51:06 EST 2008


Bill Hoffman wrote:
> Benjamen R. Meyer wrote:
>> Brandon Van Every wrote:
>>> On Feb 3, 2008 7:16 PM, Benjamen R. Meyer <bm_witness at yahoo.com> wrote:
>>>> I wrote a bash shell script to get the SVN global revision information
>>>> (e-mail me privately if you want a copy) to put into a header file
>>>> under
>>>> POSIX systems. The script is located at ${CMAKE_ROOT}; however, I am
>>>> having difficulty getting it to appear in the Makefile. Below is the
>>>> syntax from top-most CMakeLists.txt:
>>>>
>>>> IF (WIN32)
>>>>         # Execute Win32 Specific commands - none yet.
>>>> ELSE (WIN32)
>>>>         # Execute commands for other platforms
>>>>         ADD_CUSTOM_COMMAND(
>>>>                 OUTPUT SVN_REVISION
>>>>                 COMMAND ${CMAKE_ROOT}/getSVNversion.sh
>>>>                 WORKING_DIRECTORY ${CMAKE_ROOT}
>>>>                 COMMENT "Creates/updates header SVN Revision Header"
>>>>                 )
>>>> ENDIF (WIN32)
>>> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SVN_REVISION
>>> Otherwise an out of source build fails.
>>
>>
>> Ok, makes sense...but it still isn't showing up in the Makefile. Running
>> the following command in Bash still doesn't yield any results:
>>
>> builddir $ for FILE in `find|grep Makefile`; do grep getSVNversion\.sh
>> ${FILE}; done;
>>
> 
> You need a custom target or some other target that uses the output of
> the custom command.  Otherwise, cmake will not have any reason to
> produce the rule for this, as it would never be run anyway.  I think
> there is some stuff about this on the wiki...

Thanks that did the trick!

Ben


More information about the CMake mailing list