Browse Source

CMake: Fix Interrogate's dependency on the *_composite#.cxx files by creating an explicit target that can be used to do composite generation.

Sam Edwards 12 years ago
parent
commit
fd9aec6ee7
2 changed files with 15 additions and 1 deletions
  1. 7 1
      cmake/macros/CompositeSources.cmake
  2. 8 0
      cmake/macros/Interrogate.cmake

+ 7 - 1
cmake/macros/CompositeSources.cmake

@@ -84,7 +84,7 @@ function(composite_sources target sources_var)
               -DCOMPOSITE_FILE="${composite_file}"
               -DCOMPOSITE_SOURCES="${composite_sources}"
               -P "${COMPOSITE_GENERATOR}"
-            DEPENDS ${composite_sources})          
+            DEPENDS ${composite_sources})
 
           # Reset for the next composite file.
           set(composite_sources "")
@@ -93,6 +93,12 @@ function(composite_sources target sources_var)
     endif()
   endwhile()
 
+  # This exists for Interrogate's benefit, which needs the composite files to
+  # exist before it can run. Unfortunately, CMake does not expose the
+  # add_custom_command outputs as targets outside of the directory, so we have
+  # to create our own pseudotarget that gets exposed.
+  add_custom_target(${target}_composite DEPENDS ${composite_files})
+
   #set_source_files_properties(${composite_files} PROPERTIES GENERATED YES)
 
   # The new files are added to the existing files, which means the old files

+ 8 - 0
cmake/macros/Interrogate.cmake

@@ -173,6 +173,14 @@ function(interrogate_sources target output database module)
       list(APPEND define_flags "-DNDEBUG")
     endif()
 
+    # CMake offers no way to directly depend on the composite files from here,
+    # because the composite files are created in a different directory from
+    # where CMake itself is run. Therefore, we need to depend on the
+    # TARGET_composite target, if it exists.
+    if(TARGET ${target}_composite)
+      set(sources ${target}_composite ${sources})
+    endif()
+
     add_custom_command(
       OUTPUT "${output}" "${database}"
       COMMAND interrogate