changeset 264:38e9bb57f761

avoid race condition in CMake
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 06 Jun 2020 11:37:56 +0200
parents 87ed513fff9d
children af7108b06b4d
files CMakeLists.txt
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Jun 05 19:18:24 2020 +0200
+++ b/CMakeLists.txt	Sat Jun 06 11:37:56 2020 +0200
@@ -122,6 +122,15 @@
 endif()
 
 
+# As the "EmbeddedResources.(h|cpp)" are shared by both the
+# "UnitTests" and the "OrthancWebViewer" targets, avoid race
+# conditions in the code generation by adding a target between them
+add_custom_target(
+  AutogeneratedTarget
+  DEPENDS 
+  ${AUTOGENERATED_SOURCES}
+  )
+          
 set(CORE_SOURCES
   ${CMAKE_SOURCE_DIR}/Plugin/Cache/CacheManager.cpp
   ${CMAKE_SOURCE_DIR}/Plugin/Cache/CacheScheduler.cpp
@@ -141,6 +150,8 @@
   ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
   )
 
+add_dependencies(OrthancWebViewer AutogeneratedTarget)
+
 
 message("Setting the version of the library to ${ORTHANC_PLUGIN_VERSION}")
 
@@ -163,4 +174,6 @@
   UnitTestsSources/UnitTestsMain.cpp
   )
 
+add_dependencies(UnitTests AutogeneratedTarget)
+
 target_link_libraries(UnitTests ${GOOGLE_TEST_LIBRARIES})