changeset 60:0d20b470a75a

improved sdk lookup
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 14 Aug 2025 16:20:13 +0200
parents 1873eecbc592
children 97047be8435a
files Plugin/CMakeLists.txt README
diffstat 2 files changed, 57 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/CMakeLists.txt	Thu Aug 14 16:05:18 2025 +0200
+++ b/Plugin/CMakeLists.txt	Thu Aug 14 16:20:13 2025 +0200
@@ -52,9 +52,19 @@
 set(USE_SYSTEM_JNI ON CACHE BOOL "Use the system version of JsonCpp")
 set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for LSB and old versions of Visual Studio)")
 
-include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/JsonCppConfiguration.cmake)
+# Generate the documentation about the "ORTHANC_SDK_VERSION" option
+set(tmp "Version of the Orthanc plugin SDK to use, if not using the system version (can be")
+foreach(version IN LISTS ORTHANC_SDK_AVAILABLE_VERSIONS)
+  set(tmp "${tmp} ${version},")
+endforeach()
+set(tmp "${tmp} or \"path\")")
 
-include(${CMAKE_SOURCE_DIR}/../OrthancSDKVersion.cmake)
+set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system-wide version of the Orthanc plugin SDK")
+set(ORTHANC_SDK_VERSION "${ORTHANC_SDK_DEFAULT_VERSION}" CACHE STRING "${tmp}")
+set(ORTHANC_SDK_PATH "" CACHE STRING "Path to the orthanc/OrthancCPlugin.h file, if ORTHANC_SDK_VERSION is set to \"path\"")
+
+
+include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/JsonCppConfiguration.cmake)
 
 
 #####################################################################
@@ -101,10 +111,34 @@
 ## Find the Orthanc SDK
 #####################################################################
 
-include_directories(BEFORE
-  ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION}/
-  )
-set(ORTHANC_SDK ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION}/orthanc/OrthancCPlugin.h)
+if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
+  if (ORTHANC_SDK_VERSION STREQUAL "path")
+    include_directories(${ORTHANC_SDK_PATH})
+    set(ORTHANC_SDK ${ORTHANC_SDK_PATH}/orthanc/OrthancCPlugin.h)
+
+  else()
+    list(FIND ORTHANC_SDK_AVAILABLE_VERSIONS ${ORTHANC_SDK_VERSION} tmp)
+    if (tmp EQUAL -1)
+      message(FATAL_ERROR "The source distribution of this plugin does not contain Orthanc SDK ${ORTHANC_SDK_VERSION}")
+    endif()
+
+    include_directories(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION})
+    set(ORTHANC_SDK ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION}/orthanc/OrthancCPlugin.h)
+  endif()
+
+else()
+  find_path(ORTHANC_SDK_SYSTEM_DIR OrthancCPlugin.h
+    /usr/
+    /usr/local/
+    PATH_SUFFIXES include/orthanc
+    )
+
+  if (${ORTHANC_SDK_SYSTEM_DIR} STREQUAL "ORTHANC_SDK_SYSTEM_DIR-NOTFOUND")
+    message(FATAL_ERROR "Cannot locate the orthanc/OrthancCPlugin.h header")
+  endif()
+
+  set(ORTHANC_SDK ${ORTHANC_SDK_SYSTEM_DIR}/OrthancCPlugin.h)
+endif()
 
 
 #####################################################################
@@ -145,6 +179,15 @@
   ${AUTOGENERATED_SOURCES}
   )
 
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
+    CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+  # Don't report warnings about deprecated functions in the Orthanc SDK
+  set_source_files_properties(
+    ${AUTOGENERATED_DIR}/NativeSDK.cpp
+    COMPILE_FLAGS -Wno-deprecated-declarations
+    )
+endif()
+
 
 #####################################################################
 ## Build the plugin
--- a/README	Thu Aug 14 16:05:18 2025 +0200
+++ b/README	Thu Aug 14 16:20:13 2025 +0200
@@ -15,6 +15,14 @@
 Build and usage instructions are available in the Orthanc Book:
 https://orthanc.uclouvain.be/book/plugins/java.html
 
+Note that since version 2.0 of this plugin, the build process requires
+the Pystache module to be installed in the Python environment used by
+CMake:
+https://pypi.org/project/pystache/
+
+On Debian/Ubuntu environments, it is sufficient to install the
+"python3-pystache" package. This dependency is not needed at runtime.
+
 
 Licensing
 ---------