diff --git a/cmake/modules/DuneDoc.cmake b/cmake/modules/DuneDoc.cmake
index c552c69eba1762d2a703b31f25bc2127c26405ad..093e2c0b8dde01ff1919c7f75ac21738b6889d00 100644
--- a/cmake/modules/DuneDoc.cmake
+++ b/cmake/modules/DuneDoc.cmake
@@ -15,6 +15,7 @@
 # If DEPENDENCY is specified, this is a dependency for
 # the installation. Otherwise FILENAME becomes the dependency
 #
+# dune_add_latex_document()
 
 FIND_PACKAGE(LATEX)
 FIND_PROGRAM(IMAGEMAGICK_CONVERT convert
@@ -50,7 +51,14 @@ add_custom_target(doc)
 MACRO(create_doc_install filename targetdir)
   dune_common_script_dir(SCRIPT_DIR)
   get_filename_component(targetfile ${filename} NAME)
-  set(install_command ${CMAKE_COMMAND} -D FILES=${filename} -D DIR=${CMAKE_INSTALL_PREFIX}/${targetdir} -P ${SCRIPT_DIR}/InstallFile.cmake)
+  # The doc file might be in CMAKE_CURRENT_<SOURCE|BINARY>_DIR
+  # Depending on whether this is a tarball or not
+  set(_src_file _src_file-NOTFOUND)
+  find_file(_src_file ${targetfile} ${CMAKE_CURRENT_SOURCE_DIR})
+  if(NOT _src_file)
+    set(_src_file ${filename})
+  endif(NOT _src_file)
+  set(install_command ${CMAKE_COMMAND} -D FILES=${_src_file} -D DIR=${CMAKE_INSTALL_PREFIX}/${targetdir} -P ${SCRIPT_DIR}/InstallFile.cmake)
   # create a custom target for the installation
   if("${ARGC}" EQUAL "3")
     set(_depends ${ARGV2})
@@ -65,5 +73,20 @@ MACRO(create_doc_install filename targetdir)
             LIST(APPEND CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_PREFIX}/${targetdir}/${targetfile})")
 ENDMACRO(create_doc_install)
 
+
+MACRO(dune_add_latex_document tex_file)
+  # We assume that we always generate a PDF file.
+  # If the corresponding pdf file already exists in the source tree
+  # we do not add a rule to build it.
+  string(REGEX REPLACE "(.+).tex" "\\1.pdf" file ${tex_file})
+  string(REGEX REPLACE "/" "_" "${CMAKE_CURRENT_SOURCE_DIR}/${file}" filevar ${file})
+  set(filevar "filevar-NOTFOUND")
+  find_file(filevar ${file} ${CMAKE_CURRENT_SOURCE_DIR})
+  if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} OR NOT filevar)
+    # add rule to create latex document
+    dune_add_latex_document(tex_file ${ARGN})
+  endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} OR NOT filevar)
+ENDMACRO(dune_add_latex_document tex_file)
+
 # Support building documentation with doxygen.
 include(DuneDoxygen)
diff --git a/doc/buildsystem/CMakeLists.txt b/doc/buildsystem/CMakeLists.txt
index 2fc371c63d404f4d543162fdec2dc1f4177ac650..dcac6197de5a8ad218a03eae7029ea6513b03a46 100644
--- a/doc/buildsystem/CMakeLists.txt
+++ b/doc/buildsystem/CMakeLists.txt
@@ -1,4 +1,4 @@
 if(LATEX_USABLE)
-  ADD_LATEX_DOCUMENT(buildsystem.tex FATHER_TARGET doc DEFAULT_PDF INPUTS ../Makefile.am ../../configure.ac ../example.opts)
+  dune_add_latex_document(buildsystem.tex FATHER_TARGET doc DEFAULT_PDF INPUTS ../Makefile.am ../../configure.ac ../example.opts)
   create_doc_install(${CMAKE_CURRENT_BINARY_DIR}/buildsystem.pdf ${CMAKE_INSTALL_DOCDIR}/buildsystem)
 endif(LATEX_USABLE)
diff --git a/doc/comm/CMakeLists.txt b/doc/comm/CMakeLists.txt
index 2565993cc6d928d13c02600c5fc4405134c878d6..f4571eefc43d470d738d742585ea4af223b562f1 100644
--- a/doc/comm/CMakeLists.txt
+++ b/doc/comm/CMakeLists.txt
@@ -6,7 +6,7 @@ add_executable(indexset "indexset.cc")
 target_link_libraries(indexset "dunecommon")
 add_dune_mpi_flags("poosc08;poosc08_test;indexset")
 if(LATEX_USABLE)
-  ADD_LATEX_DOCUMENT(communication.tex FATHER_TARGET doc
+  dune_add_latex_document(communication.tex FATHER_TARGET doc
     BIBFILES communication.bib DEFAULT_SAFEPDF INPUTS poosc08_test.cc
     IMAGE_DIRS figures)
   create_doc_install(${CMAKE_CURRENT_BINARY_DIR}/communication.pdf ${CMAKE_INSTALL_DOCDIR}/comm communication_safepdf)