[CMake] execute_process() and writing output to a file

Michael Jackson mike.jackson at bluequartz.net
Thu Mar 26 15:45:51 EDT 2009


Sorry, didn't quite communicate what I was doing:

If you remember from a previous post I have the following:

option(MXA_BUILD_API_DOCS "Use Doxygen to create the HTML based API  
documentation" OFF)
if(MXA_BUILD_API_DOCS)
   FIND_PACKAGE(Doxygen)
   if (NOT DOXYGEN_FOUND)
     message(FATAL_ERROR "Doxygen is needed to build the  
documentation. Please install it correctly")
   endif()
   configure_file(${MXA_RESOURCES_DIR}/MXADataModel.doxyfile.in
                  ${MXADataModel_BINARY_DIR}/MXADataModel.doxyfile   
@ONLY IMMEDIATE)
   add_custom_command(TARGET ${MXADATAMODEL_LIB_NAME}
                      POST_BUILD COMMAND ${DOXYGEN_EXECUTABLE} $ 
{MXADataModel_BINARY_DIR}/MXADataModel.doxyfile)

endif(MXA_BUILD_API_DOCS)

I already have the file "MXADataModel.doxyfile.in" residing in my  
project. If you look through that file you will see various elements  
in the form "@SOME_CMAKE_VALUE@". The MXADataModel.doxyfile.in file is  
fed into the "configure_file" command which substitutes the actual  
values for every CMake variable that is found in that file then writes  
out a _new_ file called MXADataModel.doxyfile. _That_ file is then fed  
to doxygen as a argument in the add_custom_command cmake command. So  
in my case I don't need to pick up or set any environment variables as  
everything is set through cmake although I _could_ pick up environment  
variables during CMake and then set CMake variables that would then  
get filtered into the configure_file command and eventually wind up in  
the new MXADataModel.doxyfile file. Make sense?


---
Mike Jackson                 www.bluequartz.net



On Mar 26, 2009, at 3:39 PM, Robert Dailey wrote:

> I'm not at all familiar with this feature of Doxygen. Could you  
> provide an example of a doxygen command-line evocation that utilizes  
> this feature? For example, if I wanted to set the project name  
> programmatically (i.e. via command line), how would I do this  
> through your method?
>
> On Thu, Mar 26, 2009 at 2:31 PM, Michael Jackson <mike.jackson at bluequartz.net 
> > wrote:
> What I ended up doing was creating a "template" .dox file that I  
> then use CMake to "Configure" with configure_file which then fills  
> in the appropriate values for the project (like the project name,  
> where to build the docs.. ). Seems to work for me and my projects.
>
> Here is a link to my template file:
>
> <http://www.bluequartz.net/cgi-bin/gitweb/gitweb.cgi?p=MXADataModel.git;a=blob_plain;f=Resources/MXADataModel.doxyfile.in;hb=HEAD 
> >
>
> That is how I did it..
>
> ---
> Mike Jackson                 www.bluequartz.net
>
>
>
>
> On Mar 26, 2009, at 2:38 PM, Robert Dailey wrote:
>
> I like the idea of making it a post build event, however I'm doing  
> certain things that you are not that will be more difficult to  
> support outside of CMake.
>
> For example, I set certain environment variables that are accessed  
> by the Doxyfile (This is legal in Doxygen). I'm currently doing this  
> above my call to execute_process():
>
>    set( ENV{project_name} ${project_name} )
>    set( ENV{include_dir} ${include_path} )
>    set( ENV{source_dir} ${source_path} )
>    set( ENV{dot_path} "${CMAKE_SOURCE_DIR}/tools/dot" )
>    set( ENV{UNCOMMON_STRIP_PATH} ${CMAKE_SOURCE_DIR} )
>
> How am I supposed to do this? Would I have one add_custom_command()  
> for each, and invoke ${CMAKE_COMMAND} with "-E environment"? What  
> would you recommend? Note that these environment variables aren't  
> permanent. They only last the lifetime of the executing process and  
> are available to any child processes (i.e. available to the doxygen  
> child process. Visual Studio would be the parent process).
>
>
> On Thu, Mar 26, 2009 at 11:31 AM, Michael Jackson <mike.jackson at bluequartz.net 
> > wrote:
> option(MXA_BUILD_API_DOCS "Use Doxygen to create the HTML based API  
> documentation" OFF)
> if(MXA_BUILD_API_DOCS)
>  FIND_PACKAGE(Doxygen)
>  if (NOT DOXYGEN_FOUND)
>   message(FATAL_ERROR "Doxygen is needed to build the documentation.")
>  endif()
>  configure_file(${MXA_RESOURCES_DIR}/MXADataModel.doxyfile.in
>                ${MXADataModel_BINARY_DIR}/MXADataModel.doxyfile   
> @ONLY IMMEDIATE)
>  add_custom_command(TARGET ${MXADATAMODEL_LIB_NAME}
>                    POST_BUILD
>                    COMMAND ${DOXYGEN_EXECUTABLE} $ 
> {MXADataModel_BINARY_DIR}/MXADataModel.doxyfile)
>
> endif(MXA_BUILD_API_DOCS)
>
>
> The above is how I invoke doxygen.
> _________________________________________________________
> Mike Jackson                  mike.jackson at bluequartz.net
> BlueQuartz Software                    www.bluequartz.net
> Principal Software Engineer                  Dayton, Ohio
>
>
>
>
> On Mar 26, 2009, at 12:23 PM, Robert Dailey wrote:
>
> Hi,
>
> I've currently been running doxygen through execute_process() in  
> CMAKE. I've set it up like this:
>
>
>       find_package( Doxygen REQUIRED )
>
>       execute_process(
>           COMMAND "${DOXYGEN_EXECUTABLE}" "${cmake_includes}/ 
> project.dox"
>           WORKING_DIRECTORY "${documentation_dir}"
>           OUTPUT_FILE "${documentation_dir}/doxygen_log.txt"
>           ERROR_FILE "${documentation_dir}/doxygen_log.txt"
>       )
>
> However, this does not work. Doxygen is never run and the  
> doxygen_log.txt file has no contents. When I make OUTPUT_FILE and  
> ERROR_FILE reference 2 different file names, it works fine. However,  
> I want stderr and stdout to both output to the same file in the  
> proper order. It is important that I see what "output" occurred  
> before a specific "error", and I cannot do this if they are in 2  
> different files.
>
> How can I make this work?
> _______________________________________________
> 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://www.cmake.org/mailman/listinfo/cmake
>
>
>
> _______________________________________________
> 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://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list