diff Applications/StoneWebViewer/WebAssembly/CMakeLists.txt @ 2055:d4e769a0961f deep-learning

automating invokation of protobuf in deep-learning
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 18 Apr 2023 10:53:09 +0200
parents 85ab86f10d01
children 5956d7357098
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt	Thu Mar 30 17:20:26 2023 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt	Tue Apr 18 10:53:09 2023 +0200
@@ -24,8 +24,6 @@
 project(OrthancStone)
 include(${CMAKE_SOURCE_DIR}/../Version.cmake)
 
-include(${CMAKE_SOURCE_DIR}/deep-learning/WebAssembly/Protobuf.cmake)  # TODO
-
 set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../wasm-binaries/StoneWebViewer" CACHE PATH "Where to put the WebAssembly binaries")
 
 
@@ -63,6 +61,8 @@
 SET(ENABLE_LOCALE ON)  # Necessary for text rendering
 SET(ENABLE_PUGIXML ON) # Necessary for OsiriX annotations
 SET(ORTHANC_SANDBOXED ON)
+SET(ENABLE_PROTOBUF ON)           # Necessary for deep learning
+SET(ENABLE_PROTOBUF_COMPILER ON)  # Necessary for deep learning
 
 # this will set up the build system for Stone of Orthanc and will
 # populate the ORTHANC_STONE_SOURCES CMake variable
@@ -120,9 +120,21 @@
   ${STONE_WRAPPER}
   )
 
-add_custom_target(StoneWrapper
+add_custom_command(
+  OUTPUT
+  ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.h
+  ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.cc
+  COMMAND ${PROTOC_EXECUTABLE} --cpp_out=${AUTOGENERATED_DIR} -I${CMAKE_SOURCE_DIR}
+  ${CMAKE_SOURCE_DIR}/DeepLearningWorker.proto
+  DEPENDS
+  ${CMAKE_SOURCE_DIR}/DeepLearningWorker.proto
+  ProtobufCompiler
+  )
+
+add_custom_target(AutogeneratedFiles
   DEPENDS
   ${STONE_WRAPPER}
+  ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.cc
   )  
 
 
@@ -135,9 +147,8 @@
 
 add_executable(StoneWebViewer
   ${ORTHANC_STONE_SOURCES}
-  ${AUTOGENERATED_SOURCES}
-  ${PROTOBUF_SOURCES}  # TODO
-  ${CMAKE_SOURCE_DIR}/Worker.pb.cc  # TODO
+  ${AUTOGENERATED_SOURCES}  # Populated by "EmbedResources()"
+  ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.cc
   StoneWebViewer.cpp
   )
 
@@ -148,7 +159,7 @@
   )
 
 # Make sure to have the wrapper generated
-add_dependencies(StoneWebViewer StoneWrapper)
+add_dependencies(StoneWebViewer AutogeneratedFiles)
 
 
 # Declare installation files for the module