changeset 4037:5e26d004838c

adding option "system" to DownloadOrthancFramework.cmake
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 12:18:21 +0200
parents 78ee0155ec67
children e072b4e33600
files Core/FileStorage/FilesystemStorage.h Core/IDynamicObject.h Core/MultiThreading/SharedMessageQueue.h Plugins/Samples/ConnectivityChecks/CMakeLists.txt Resources/DownloadOrthancFramework.cmake
diffstat 5 files changed, 86 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Core/FileStorage/FilesystemStorage.h	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/FileStorage/FilesystemStorage.h	Wed Jun 10 12:18:21 2020 +0200
@@ -51,7 +51,7 @@
 
 namespace Orthanc
 {
-  class FilesystemStorage : public IStorageArea
+  class ORTHANC_PUBLIC FilesystemStorage : public IStorageArea
   {
     // TODO REMOVE THIS
     friend class FilesystemHttpSender;
--- a/Core/IDynamicObject.h	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/IDynamicObject.h	Wed Jun 10 12:18:21 2020 +0200
@@ -33,6 +33,8 @@
 
 #pragma once
 
+#include "OrthancFramework.h"
+
 #include <boost/noncopyable.hpp>
 
 namespace Orthanc
@@ -43,7 +45,7 @@
    * Being a child of IDynamicObject only implies the existence of a
    * virtual destructor.
    **/
-  class IDynamicObject : public boost::noncopyable
+  class ORTHANC_PUBLIC IDynamicObject : public boost::noncopyable
   {
   public:
     virtual ~IDynamicObject()
--- a/Core/MultiThreading/SharedMessageQueue.h	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/MultiThreading/SharedMessageQueue.h	Wed Jun 10 12:18:21 2020 +0200
@@ -41,7 +41,7 @@
 
 namespace Orthanc
 {
-  class SharedMessageQueue : public boost::noncopyable
+  class ORTHANC_PUBLIC SharedMessageQueue : public boost::noncopyable
   {
   private:
     typedef std::list<IDynamicObject*>  Queue;
--- a/Plugins/Samples/ConnectivityChecks/CMakeLists.txt	Wed Jun 10 10:14:15 2020 +0200
+++ b/Plugins/Samples/ConnectivityChecks/CMakeLists.txt	Wed Jun 10 12:18:21 2020 +0200
@@ -27,6 +27,7 @@
 endif()  
 
 EmbedResources(
+  --framework-path=${CMAKE_CURRENT_SOURCE_DIR}/../../../Core
   WEB_RESOURCES  ${CMAKE_CURRENT_SOURCE_DIR}/WebResources
   LIBRARIES      ${JAVASCRIPT_LIBS_DIR}
   )
--- a/Resources/DownloadOrthancFramework.cmake	Wed Jun 10 10:14:15 2020 +0200
+++ b/Resources/DownloadOrthancFramework.cmake	Wed Jun 10 12:18:21 2020 +0200
@@ -35,11 +35,12 @@
 ##
 
 if (NOT DEFINED ORTHANC_FRAMEWORK_SOURCE OR
-    (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" AND
+    (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system" AND
+     NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" AND
      NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "web" AND
      NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" AND
      NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "path"))
-  message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_SOURCE must be set to \"hg\", \"web\", \"archive\" or \"path\"")
+  message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_SOURCE must be set to \"system\", \"hg\", \"web\", \"archive\" or \"path\"")
 endif()
 
 
@@ -371,3 +372,80 @@
     endif()
   endif()
 endif()
+
+
+
+##
+## Case of the Orthanc framework installed as a shared library in a
+## GNU/Linux distribution (typically Debian)
+##
+
+if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
+  set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "")
+
+  include(CheckIncludeFileCXX)
+  include(FindPythonInterp)
+  include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
+  include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
+  include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
+  set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
+
+  # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
+  find_path(JSONCPP_INCLUDE_DIR json/reader.h
+    /usr/include/jsoncpp
+    /usr/local/include/jsoncpp
+    )
+
+  message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
+  include_directories(${JSONCPP_INCLUDE_DIR})
+  link_libraries(jsoncpp)
+
+  CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
+  if (NOT HAVE_JSONCPP_H)
+    message(FATAL_ERROR "Please install the libjsoncpp-dev package")
+  endif()
+
+  # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
+  include(FindBoost)
+  find_package(Boost COMPONENTS filesystem thread system date_time regex)
+
+  if (NOT Boost_FOUND)
+    message(FATAL_ERROR "Unable to locate Boost on this system")
+  endif()
+  
+  include_directories(${Boost_INCLUDE_DIRS})
+  link_libraries(${Boost_LIBRARIES})
+
+  # Look for Orthanc framework shared library
+  include(CheckCXXSymbolExists)
+
+  find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
+    /usr/include/orthanc-framework
+    /usr/local/include/orthanc-framework
+    ${ORTHANC_FRAMEWORK_ROOT}
+    )
+  
+  message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
+  include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
+  
+  set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
+
+  if (NOT "${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
+    set(CMAKE_REQUIRED_LIBRARIES "-L${ORTHANC_FRAMEWORK_LIBDIR} -lOrthancFramework")
+  else()
+    set(CMAKE_REQUIRED_LIBRARIES "OrthancFramework")
+  endif()
+  
+  check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
+  if(NOT HAVE_ORTHANC_FRAMEWORK)
+    message(FATAL_ERROR "Cannot find the Orthanc framework")
+  endif()
+
+  if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "")
+    include_directories(${ORTHANC_FRAMEWORK_ROOT})
+  endif()
+
+  if (NOT "${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
+    link_directories(${ORTHANC_FRAMEWORK_LIBDIR})
+  endif()
+endif()