title: Build doxygen from CMake script
body: <p>I found on the Web a sample cmake file and put it in the <code>/doc</code> subdirectory of my project, where the file <code>myproject.doxgen</code> is also located, containing Doxygen configuration.</p>
  
  <p>I've tested that running <code>doxygen.exe myproject.doxygen</code> produces valid output. I only need to build this into the CMake process. So <code>/doc/CMakeLists.txt</code> is:</p>
  
  <pre><code>find_package(Doxygen)
  option(BUILD_DOCUMENTATION "Create and install the HTML based API        
  documentation (requires Doxygen)" ${DOXYGEN_FOUND})
  
  if(BUILD_DOCUMENTATION)
      if(NOT DOXYGEN_FOUND)
           message(FATAL_ERROR "Doxygen is needed to build the documentation.")
      endif()
  
      set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/../doc/myproject.doxygen)
      set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/doxyfile)
  
      configure_file(${doxyfile_in} ${doxyfile} @ONLY)
  
      message("Doxygen build started.")
  
      add_custom_target(doc
                        COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile_in}
                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc
                        COMMENT "Generating API documentation with Doxygen"
                        VERBATIM)
  
      #    install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION     share/doc)
  endif()
  </code></pre>
  
  <p>It doesn't work for me, it only copies the original config file into <code>/build/my/project/doc/</code> and does nothing more.</p>
  
  <p>What I want is to generate the doxygen documentation during my builds; ideally, only when building the Release configuration.</p>