From: Modestas Vainius <modax@debian.org>
Subject: Fix a race condition between akonadi_nepomuk_*_feeder_automoc and ontology headers
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=596908
Forwarded: no
Last-Update: 2010-09-18

nepomuk*feeder headers source ontology class headers (nie.h etc.) that are
autogenerated at build time. This patch makes sure that
nepomuk_*_feeder_automoc targets are not built before niefast target (which
trigger generation of ontology class headers) or they both are never built at
the same time when building in parallel. The latter was a cause of weird
FTBFSes on ia64 (e.g. [1]) when moc-qt4 sourced incomplete nie.h and produced
bogus nepomukcontactfeeder.moc as a result.

[1] https://buildd.debian.org/fetch.cgi?pkg=kdepim-runtime;ver=4%3A4.4.5-1;arch=ia64;stamp=1280117387

--- a/agents/nepomuk_calendar_feeder/CMakeLists.txt
+++ b/agents/nepomuk_calendar_feeder/CMakeLists.txt
@@ -18,6 +18,11 @@ target_link_libraries(akonadi_nepomuk_ca
   ${KDEPIMLIBS_AKONADI_KCAL_LIBS}
   ${KDEPIMLIBS_KCAL_LIBS}
 )
+# akonadi_nepomuk_calendar_feeder_automoc depend on the presence of the
+# ontology class headers. We can be sure that they are present when niefast
+# target is built. This is needed to avoid a race condition when building in
+# parallel.
+add_dependencies( akonadi_nepomuk_calendar_feeder_automoc niefast )
 
 install(TARGETS akonadi_nepomuk_calendar_feeder ${INSTALL_TARGETS_DEFAULT_ARGS})
 install(FILES nepomukcalendarfeeder.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
--- a/agents/nepomuk_contact_feeder/CMakeLists.txt
+++ b/agents/nepomuk_contact_feeder/CMakeLists.txt
@@ -13,6 +13,11 @@ target_link_libraries(akonadi_nepomuk_co
   ${KDEPIMLIBS_KABC_LIBS}
   ${NEPOMUKFEEDER_SHARED_LIBS}
 )
+# akonadi_nepomuk_contact_feeder_automoc depends on the presence of the
+# ontology class headers. We can be sure that they are present when niefast
+# target is built. This is needed to avoid a race condition when building in
+# parallel.
+add_dependencies( akonadi_nepomuk_contact_feeder_automoc niefast )
 
 install(TARGETS akonadi_nepomuk_contact_feeder ${INSTALL_TARGETS_DEFAULT_ARGS})
 install(FILES nepomukcontactfeeder.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
