[CMake] How to add dependencies to ExternalProject_Add()
    Rolf Eike Beer 
    eike at sf-mail.de
       
    Mon Mar 28 10:37:38 EDT 2011
    
    
  
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
    
    
More information about the CMake
mailing list