[CMake] Redirect stdout from COMMAND in ADD_CUSTOM_COMMAND (CMake 2.6 RC8)

Eric Noulard eric.noulard at gmail.com
Tue Apr 22 02:17:31 EDT 2008


2008/4/21, Alejandro Morell Garcí­a <alejandro.morell at gmail.com>:
>
>  It's works. Thanks :)
>  I don't agree using no VERBATIM option, but it wouldn't be the first hack
> in computer science, hehehe.

Yep looks like a bug unless I miss something.
Would you please file a bug for this issue, in order to make CMake developer
look at it?
http://public.kitware.com/Bug/my_view_page.php

This would be wise since the ADD_CUSTOM_COMMAND says:
"In the future VERBATIM may
       be enabled by default.  The only reason it is an option is to preserve
       compatibility with older CMake code."

>  Support of cross-platform stdout redirecting would be a great feature in
> future versions of cmake. Maybe implementing all options of EXECUTE_PROCESS
> in ADD_CUSTOM_COMMAND.

You may well FILE(WRITE)  a custom CMake script which call EXECUTE_PROCESS,
this would be something like (not tested):

FILE(WRITE ${CMAKE_BINARY_DIR}/gst/genmarshal.cmake
       "# genmarshal cmake script wrapper
${CMAKE_COMMAND} -E copy gstmarshal.c.template gstmarshal.c
EXECUTE_PROCESS(COMMAND glib-genmarshal glib-genmarshal --body
--prefix=gst_marshal ${CMAKE_CURRENT_SOURCE_DIR}/gstmarshal.list
                                  OUTPUT_FILE gstmarshal.c
                                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gst/)
")

then execute the CMake script from within ADD_CUSTOM_COMMAND:

ADD_CUSTOM_COMMAND(OUTPUT gstmarshal.c
        COMMAND ${CMAKE_COMMAND} -P genmarshal.cmake
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gst/
        COMMENT "Generating flex and bison parsers"
        VERBATIM)

Or you may file feature request at:
http://public.kitware.com/Bug/my_view_page.php

-- 
Erk


More information about the CMake mailing list