diff ViewerPlugin/CMakeLists.txt @ 0:4a7a53257c7d

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Oct 2016 21:48:33 +0200
parents
children 77b76c1a213f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ViewerPlugin/CMakeLists.txt	Sat Oct 22 21:48:33 2016 +0200
@@ -0,0 +1,203 @@
+cmake_minimum_required(VERSION 2.8)
+project(OrthancWSIPlugin)
+
+set(ORTHANC_WSI_VERSION "mainline")
+
+
+#####################################################################
+## Parameters of the build
+#####################################################################
+
+# Generic parameters
+SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
+SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
+
+# Advanced parameters to fine-tune linking against system libraries
+SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
+SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
+SET(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
+SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
+SET(USE_SYSTEM_OPENJPEG ON CACHE BOOL "Use the system version of OpenJpeg")
+SET(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
+SET(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
+
+# Parameters related to OpenLayers
+SET(USE_SYSTEM_OPENLAYERS OFF CACHE BOOL "Use the system version of OpenLayers")
+SET(OPENLAYERS_CSS "" CACHE FILEPATH "Path to the system version of OpenLayers CSS")
+SET(OPENLAYERS_JS "" CACHE FILEPATH "Path to the system version of OpenLayers JavaScript")
+
+
+#####################################################################
+## Configure mandatory third-party components
+#####################################################################
+
+SET(ORTHANC_WSI_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
+SET(ORTHANC_ROOT ${ORTHANC_WSI_DIR}/Framework/Orthanc)
+
+SET(USE_OPENJPEG_JP2 ON)
+
+include(CheckIncludeFiles)
+include(CheckIncludeFileCXX)
+include(CheckLibraryExists)
+include(FindPythonInterp)
+include(FindPkgConfig)
+
+include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/AutoGeneratedCode.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
+
+# Third-party components shipped with Orthanc
+include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/LibJpegConfiguration.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/LibPngConfiguration.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/ZlibConfiguration.cmake)
+
+include(${ORTHANC_WSI_DIR}/Resources/CMake/OpenJpegConfiguration.cmake)
+
+add_definitions(
+  -DORTHANC_ENABLE_BASE64=0
+  -DORTHANC_ENABLE_CURL=0
+  -DORTHANC_ENABLE_DCMTK=0
+  -DORTHANC_ENABLE_LOGGING=0
+  -DORTHANC_ENABLE_MD5=0
+  -DHAS_ORTHANC_EXCEPTION=1
+  )
+
+
+#####################################################################
+## Find the Orthanc SDK
+#####################################################################
+
+if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
+  include_directories(${ORTHANC_ROOT}/Sdk-1.0.0)
+else ()
+  CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H)
+  if (NOT HAVE_ORTHANC_H)
+    message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK")
+  endif()
+endif()
+
+
+#####################################################################
+## Platform-specific configuration
+#####################################################################
+
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
+    ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
+    ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+  link_libraries(rt)
+
+elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+  SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32")
+
+  execute_process(
+    COMMAND 
+    ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py
+    ${ORTHANC_WSI_VERSION} "OrthancWSI" OrthancWSI.dll "Whole-slide imaging plugin for Orthanc"
+    ERROR_VARIABLE Failure
+    OUTPUT_FILE ${AUTOGENERATED_DIR}/Version.rc
+    )
+
+  if (Failure)
+    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
+  endif()
+
+  list(APPEND AUTOGENERATED_SOURCES  ${AUTOGENERATED_DIR}/Version.rc)
+endif()
+
+if (APPLE)
+  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation")
+  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework CoreFoundation")
+endif()
+
+
+#####################################################################
+## Prepare OpenLayers
+#####################################################################
+
+if (STATIC_BUILD OR NOT USE_SYSTEM_OPENLAYERS)
+  DownloadPackage(
+    "77e57aad873c2d4deea8bb1446e9b87a"
+    "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/WSI/openlayers-3.19.0-dist.zip"
+    "v3.19.0-dist")
+  
+  set(OPENLAYERS_RESOURCES
+    OPENLAYERS_CSS  ${CMAKE_CURRENT_BINARY_DIR}/v3.19.0-dist/ol.css
+    OPENLAYERS_JS   ${CMAKE_CURRENT_BINARY_DIR}/v3.19.0-dist/ol.js
+    )
+
+else()
+  set(OPENLAYERS_RESOURCES
+    OPENLAYERS_CSS  ${OPENLAYERS_CSS}
+    OPENLAYERS_JS   ${OPENLAYERS_JS}
+    )  
+endif()
+
+EmbedResources(
+  ${OPENLAYERS_RESOURCES}
+  ORTHANC_EXPLORER  ${CMAKE_SOURCE_DIR}/OrthancExplorer.js
+  VIEWER_HTML       ${CMAKE_SOURCE_DIR}/viewer.html
+  VIEWER_JS         ${CMAKE_SOURCE_DIR}/viewer.js
+  )
+
+
+#####################################################################
+## Create the plugin
+#####################################################################
+
+add_library(OrthancWSI SHARED
+  Plugin.cpp
+
+  ${ORTHANC_WSI_DIR}/Framework/DicomToolbox.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Enumerations.cpp
+  ${ORTHANC_WSI_DIR}/Framework/ImageToolbox.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Inputs/DicomPyramid.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Inputs/DicomPyramidInstance.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Inputs/DicomPyramidLevel.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Inputs/PyramidWithRawTiles.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Jpeg2000Reader.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Jpeg2000Writer.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Messaging/IOrthancConnection.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Messaging/OrthancConnectionBase.cpp
+  ${ORTHANC_WSI_DIR}/Framework/Messaging/PluginOrthancConnection.cpp
+
+  ${ORTHANC_ROOT}/Core/ChunkedBuffer.cpp
+  ${ORTHANC_ROOT}/Core/Enumerations.cpp
+  ${ORTHANC_ROOT}/Core/Images/IImageWriter.cpp
+  ${ORTHANC_ROOT}/Core/Images/Image.cpp
+  ${ORTHANC_ROOT}/Core/Images/ImageAccessor.cpp
+  ${ORTHANC_ROOT}/Core/Images/ImageBuffer.cpp
+  ${ORTHANC_ROOT}/Core/Images/ImageProcessing.cpp
+  ${ORTHANC_ROOT}/Core/Images/JpegErrorManager.cpp
+  ${ORTHANC_ROOT}/Core/Images/JpegReader.cpp
+  ${ORTHANC_ROOT}/Core/Images/JpegWriter.cpp
+  ${ORTHANC_ROOT}/Core/Images/PngReader.cpp
+  ${ORTHANC_ROOT}/Core/Images/PngWriter.cpp
+  ${ORTHANC_ROOT}/Core/Logging.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/Semaphore.cpp
+  ${ORTHANC_ROOT}/Core/Toolbox.cpp
+
+  ${AUTOGENERATED_SOURCES}
+
+  # Mandatory components
+  ${BOOST_SOURCES}
+  ${JSONCPP_SOURCES}
+  ${ZLIB_SOURCES}
+  ${LIBPNG_SOURCES}
+  ${LIBJPEG_SOURCES}
+  ${OPENJPEG_SOURCES}
+  )
+
+message("Setting the version of the library to ${ORTHANC_WSI_VERSION}")
+add_definitions(-DORTHANC_WSI_VERSION="${ORTHANC_WSI_VERSION}")
+
+set_target_properties(OrthancWSI PROPERTIES 
+  VERSION ${ORTHANC_WSI_VERSION} 
+  SOVERSION ${ORTHANC_WSI_VERSION})
+
+install(
+  TARGETS OrthancWSI
+  RUNTIME DESTINATION lib    # Destination for Windows
+  LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
+  )