]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix cmake 3.3 warning about code-gallery.h 2187/head
authorTimo Heister <timo.heister@gmail.com>
Sun, 14 Feb 2016 15:15:33 +0000 (10:15 -0500)
committerTimo Heister <timo.heister@gmail.com>
Sun, 14 Feb 2016 15:24:49 +0000 (10:24 -0500)
cmake 3.3 will warn about CMP0058 and is unable to compile the documentation
when using Ninja:

 This project specifies custom command DEPENDS on files in the build tree
  that are not specified as the OUTPUT or BYPRODUCTS of any
  add_custom_command or add_custom_target:

   doc/doxygen/code-gallery/code-gallery.h

We have to jump through a few hoops to make this work: Generating a
dependency to a source file generated in a subdirectory CMakeLists.txt
requires a custom command attached to a custom_target. Because ADD_DEPENDENCIES
only allows custom_targets not custom_commands, we have to add another dummy.

doc/doxygen/code-gallery/CMakeLists.txt

index a9494df710fc41c1065db07e9c109aa52f5c96c0..9c3048782214f1d2849fc7c5e421794a2a6322f0 100644 (file)
@@ -133,9 +133,17 @@ ELSE()
   MESSAGE(STATUS "Setting up code gallery documentation.")
   MESSAGE(STATUS "  Skipping as no code gallery exists in ${DEAL_II_CODE_GALLERY_DIRECTORY}.")
 
-  FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/no-code-gallery.h
-       DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-  FILE(RENAME ${CMAKE_CURRENT_BINARY_DIR}/no-code-gallery.h
-       ${CMAKE_CURRENT_BINARY_DIR}/code-gallery.h)
+  ADD_CUSTOM_COMMAND(
+    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/code-gallery.h
+    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/no-code-gallery.h ${CMAKE_CURRENT_BINARY_DIR}/code-gallery.h
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/no-code-gallery.h
+       )
+
+  # Make the custom command for code-gallery.h visible to the parent CMakeLists.txt by attaching to the code-gallery
+  # custom target:
+  ADD_CUSTOM_TARGET(build_code-gallery_h
+    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/code-gallery.h)
+  ADD_DEPENDENCIES(code-gallery build_code-gallery_h)
+
 ENDIF()
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.