I have an external project that should depend on a library I build in my
usual project. I do an export(TARGETS) on that library and pass that file
into the build of the external project and all goes fine.

But when I go to our build machine which will do "make -j 5" it breaks
because the external project get's build before the internal library.
Silly me ;)

So I did

        ExternalProject_Add(external
                        DEPENDS mylib
   PREFIX "${CMAKE_CURRENT_BINARY_DIR}/build_external"
  ...
 )

Which of course doesn't work:

make[2]: *** No rule to make target `/mylib-done', needed by
`build_external/src/exernal-stamp/external-configure'.  Stop.

I wonder what is the supposed way to pass this sort of dependencies? Looks
like that one only works if the DEPENDS is itself an external project?

I came up with this simple diff which makes everything work smoothly for me:

diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 3de6b7e..e4b7121 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1261,8 +1261,12 @@ function(_ep_add_configure_command name)
   set(file_deps)
   get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
   foreach(dep IN LISTS deps)
-    get_property(dep_stamp_dir TARGET ${dep} PROPERTY _EP_STAMP_DIR)
-    list(APPEND file_deps ${dep_stamp_dir}${cfgdir}/${dep}-done)
+    if(TARGET ${dep})
+      list(APPEND file_deps ${dep})
+    else(TARGET ${dep})
+      get_property(dep_stamp_dir TARGET ${dep} PROPERTY _EP_STAMP_DIR)
+      list(APPEND file_deps ${dep_stamp_dir}${cfgdir}/${dep}-done)
+    endif(TARGET ${dep})
   endforeach()

   get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET)

Am I getting something totally wrong here? Should I open a bug report with
a properly annotated patch for inclusion?

Eike
_______________________________________________
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

Reply via email to