diff CMakeLists.txt @ 46:9b2a2fcc9878 nexus

added option to disable Nexus support
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Apr 2024 07:49:45 +0200
parents 967f947014ac
children 0a408a81fb15
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Apr 09 22:13:01 2024 +0200
+++ b/CMakeLists.txt	Wed Apr 10 07:49:45 2024 +0200
@@ -58,6 +58,9 @@
 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"")
 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"")
 
+# New in release 2.0
+set(ENABLE_NEXUS OFF CACHE BOOL "Include support for Nexus 3D models")
+
 # Advanced parameters to fine-tune linking against system libraries
 SET(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
 
@@ -168,31 +171,57 @@
 ## Create the autogenerated files
 #####################################################################
 
-EmbedResources(
+set(EMBEDDED_RESOURCES
   THREE_HTML         ${CMAKE_SOURCE_DIR}/WebApplications/three.html
   THREE_JS           ${CMAKE_SOURCE_DIR}/WebApplications/three.js
   O3DV_HTML          ${CMAKE_SOURCE_DIR}/WebApplications/o3dv.html
   O3DV_JS            ${CMAKE_SOURCE_DIR}/WebApplications/o3dv.js
   ORTHANC_EXPLORER   ${CMAKE_SOURCE_DIR}/Sources/OrthancExplorer.js
+  )
 
-  NEXUS_HTML           ${CMAKE_SOURCE_DIR}/Resources/Nexus/threejs.html
-  NEXUS_JS             ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/nexus.js
-  NEXUS_MECO_JS        ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/meco.js
-  NEXUS_THREE_JS       ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/nexus_three.js
-  NEXUS_TRACKBALL_JS   ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/TrackballControls.js
+set(STATIC_ASSETS
+  ${CMAKE_SOURCE_DIR}/JavaScriptLibraries/dist
   )
 
+if (ENABLE_NEXUS)
+  set(NEXUS_ASSETS_DIR ${AUTOGENERATED_DIR}/nexus)
+  file(MAKE_DIRECTORY ${NEXUS_ASSETS_DIR})
+
+  DownloadCompressedFile(
+    "df21a4a192c0952a1189125609cc76f9"
+    "https://orthanc.uclouvain.be/downloads/third-party-downloads/STL/three-84.js.gz"
+    "${NEXUS_ASSETS_DIR}/three-84.js")
+
+  list(APPEND EMBEDDED_RESOURCES
+    NEXUS_HTML           ${CMAKE_SOURCE_DIR}/Resources/Nexus/threejs.html
+    NEXUS_JS             ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/nexus.js
+    NEXUS_MECO_JS        ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/meco.js
+    NEXUS_THREE_JS       ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/nexus_three.js
+    NEXUS_TRACKBALL_JS   ${CMAKE_SOURCE_DIR}/Resources/Nexus/js/TrackballControls.js
+    )
+
+  list(APPEND STATIC_ASSETS
+    ${NEXUS_ASSETS_DIR}
+    )
+
+  add_definitions(-DORTHANC_ENABLE_NEXUS=1)
+else()
+  add_definitions(-DORTHANC_ENABLE_NEXUS=0)
+endif()
+
+EmbedResources(${EMBEDDED_RESOURCES})
+
 add_custom_command(
   OUTPUT
   ${AUTOGENERATED_DIR}/StaticAssets.cpp
   COMMAND
   ${PYTHON_EXECUTABLE}
   ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py
-  ${CMAKE_SOURCE_DIR}/JavaScriptLibraries/dist
   ${AUTOGENERATED_DIR}/StaticAssets.cpp
+  ${STATIC_ASSETS}
   DEPENDS
-  ${CMAKE_SOURCE_DIR}/JavaScriptLibraries/dist
   ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py
+  ${STATIC_ASSETS}
   )
 
 list(APPEND AUTOGENERATED_SOURCES