view Resources/CMake/OrthancStone.cmake @ 39:9ee7e2f5f1a3

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 21 Dec 2016 14:19:38 +0100
parents bfce0add15f2
children 7207a407bcd8
line wrap: on
line source

# Version of the build, should always be "mainline" except in release branches
set(ORTHANC_STONE_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")
SET(STONE_SANDBOXED OFF CACHE BOOL "Whether Stone runs inside a sandboxed environment (such as Google NaCl)")

# Optional components
SET(ENABLE_CURL ON CACHE BOOL "Include support for libcurl")
SET(ENABLE_SSL OFF CACHE BOOL "Include support for SSL")
SET(ENABLE_SDL ON CACHE BOOL "Include support for SDL")
SET(ENABLE_LOGGING ON CACHE BOOL "Enable logging facilities from Orthanc")

# 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_ZLIB ON CACHE BOOL "Use the system version of ZLib")
SET(USE_SYSTEM_CAIRO ON CACHE BOOL "Use the system version of Cairo")
SET(USE_SYSTEM_PIXMAN ON CACHE BOOL "Use the system version of Pixman")
SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
SET(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
SET(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
SET(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
SET(USE_SYSTEM_SDL ON CACHE BOOL "Use the system version of SDL2")


#####################################################################
## Configure mandatory third-party components
#####################################################################

SET(ORTHANC_STONE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
SET(ORTHANC_ROOT ${ORTHANC_STONE_DIR}/Resources/Orthanc)

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)

include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/ZlibConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/LibPngConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/LibJpegConfiguration.cmake)

include(${CMAKE_CURRENT_LIST_DIR}/BoostExtendedConfiguration.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CairoConfiguration.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/PixmanConfiguration.cmake)

if (MSVC)
  # Remove some warnings on Visual Studio 2015
  add_definitions(-D_SCL_SECURE_NO_WARNINGS=1) 
endif()


#####################################################################
## Configure optional third-party components
#####################################################################

if (STONE_SANDBOXED)
  add_definitions(
    -DORTHANC_ENABLE_CURL=0
    -DORTHANC_ENABLE_LOGGING=0
    -DORTHANC_ENABLE_SDL=0
    -DORTHANC_ENABLE_SSL=0
    -DORTHANC_SANDBOXED=1
    )
else()
  list(APPEND ORTHANC_STONE_SOURCES
    ${ORTHANC_ROOT}/Core/HttpClient.cpp
    ${ORTHANC_ROOT}/Core/SystemToolbox.cpp
    ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancHttpConnection.cpp
    )

  add_definitions(
    -DORTHANC_SANDBOXED=0
    )

  if (ENABLE_LOGGING)
    add_definitions(-DORTHANC_ENABLE_LOGGING=1)
  else()
    add_definitions(-DORTHANC_ENABLE_LOGGING=0)
  endif()

  if (ENABLE_SDL)
    include(${CMAKE_CURRENT_LIST_DIR}/SdlConfiguration.cmake)  
    add_definitions(-DORTHANC_ENABLE_SDL=1)
  else()
    add_definitions(-DORTHANC_ENABLE_SDL=0)
  endif()

  if (ENABLE_CURL)
    add_definitions(-DORTHANC_ENABLE_CURL=1)
    include(${ORTHANC_ROOT}/Resources/CMake/LibCurlConfiguration.cmake)

    if (ENABLE_SSL)
      set(ENABLE_PKCS11 OFF)
      add_definitions(-DORTHANC_ENABLE_SSL=1)
      include(${ORTHANC_ROOT}/Resources/CMake/OpenSslConfiguration.cmake)
    else()
      add_definitions(-DORTHANC_ENABLE_SSL=0)
    endif()
  else()
    add_definitions(
      -DORTHANC_ENABLE_SSL=0
      -DORTHANC_ENABLE_CURL=0
      )
  endif()
endif()

add_definitions(
  -DHAS_ORTHANC_EXCEPTION=1
  -DORTHANC_ENABLE_MD5=0
  -DORTHANC_ENABLE_BASE64=1
  -DORTHANC_ENABLE_PUGIXML=0
  -DORTHANC_ENABLE_PKCS11=0
  )


#####################################################################
## Link the colormaps into the binaries
#####################################################################

EmbedResources(
  COLORMAP_HOT    ${ORTHANC_STONE_DIR}/Resources/Colormaps/hot.lut
  COLORMAP_JET    ${ORTHANC_STONE_DIR}/Resources/Colormaps/jet.lut
  COLORMAP_RED    ${ORTHANC_STONE_DIR}/Resources/Colormaps/red.lut
  COLORMAP_GREEN  ${ORTHANC_STONE_DIR}/Resources/Colormaps/green.lut
  COLORMAP_BLUE   ${ORTHANC_STONE_DIR}/Resources/Colormaps/blue.lut
  )


#####################################################################
## System-specific patches
#####################################################################

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND
    NOT MSVC AND
    ENABLE_SDL)
  # This is necessary when compiling EXE for Windows using MinGW
  link_libraries(mingw32)
endif()



#####################################################################
## All the source files required to build Stone of Orthanc
#####################################################################

list(APPEND ORTHANC_STONE_SOURCES
  ${ORTHANC_STONE_DIR}/Framework/Applications/BasicApplicationContext.cpp
  ${ORTHANC_STONE_DIR}/Framework/Applications/IBasicApplication.cpp
  ${ORTHANC_STONE_DIR}/Framework/Applications/Sdl/SdlBuffering.cpp
  ${ORTHANC_STONE_DIR}/Framework/Applications/Sdl/SdlEngine.cpp
  ${ORTHANC_STONE_DIR}/Framework/Applications/Sdl/SdlWindow.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/CircleMeasureTracker.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/ColorFrameRenderer.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/DicomStructureSetRendererFactory.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/FrameRenderer.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/GrayscaleFrameRenderer.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/LineLayerRenderer.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/LineMeasureTracker.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/RenderStyle.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/SeriesFrameRendererFactory.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/SiblingSliceLocationFactory.cpp
  ${ORTHANC_STONE_DIR}/Framework/Layers/SingleFrameRendererFactory.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/BinarySemaphore.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/DicomFrameConverter.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/DicomStructureSet.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/DownloadStack.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/GeometryToolbox.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/MessagingToolbox.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/OrthancSeriesLoader.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/ParallelSlices.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/ParallelSlicesCursor.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/SliceGeometry.cpp
  ${ORTHANC_STONE_DIR}/Framework/Toolbox/ViewportGeometry.cpp
  ${ORTHANC_STONE_DIR}/Framework/Viewport/CairoContext.cpp
  ${ORTHANC_STONE_DIR}/Framework/Viewport/CairoFont.cpp
  ${ORTHANC_STONE_DIR}/Framework/Viewport/CairoSurface.cpp
  ${ORTHANC_STONE_DIR}/Framework/Viewport/WidgetViewport.cpp
  ${ORTHANC_STONE_DIR}/Framework/Volumes/ImageBuffer3D.cpp
  ${ORTHANC_STONE_DIR}/Framework/Volumes/VolumeImage.cpp
  ${ORTHANC_STONE_DIR}/Framework/Volumes/VolumeImagePolicyBase.cpp
  ${ORTHANC_STONE_DIR}/Framework/Volumes/VolumeImageProgressivePolicy.cpp
  ${ORTHANC_STONE_DIR}/Framework/Volumes/VolumeImageSimplePolicy.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/CairoWidget.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/EmptyWidget.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/LayeredSceneWidget.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/LayoutWidget.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/TestCairoWidget.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/TestWorldSceneWidget.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/WidgetBase.cpp
  ${ORTHANC_STONE_DIR}/Framework/Widgets/WorldSceneWidget.cpp

  ${ORTHANC_ROOT}/Core/ChunkedBuffer.cpp
  ${ORTHANC_ROOT}/Core/Compression/DeflateBaseCompressor.cpp
  ${ORTHANC_ROOT}/Core/Compression/GzipCompressor.cpp
  ${ORTHANC_ROOT}/Core/Enumerations.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/PngReader.cpp
  ${ORTHANC_ROOT}/Core/Logging.cpp
  ${ORTHANC_ROOT}/Core/Toolbox.cpp
  ${ORTHANC_ROOT}/Core/WebServiceParameters.cpp
  ${ORTHANC_ROOT}/Resources/ThirdParty/base64/base64.cpp
  ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomDatasetReader.cpp
  ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomPath.cpp
  ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomTag.cpp
  ${ORTHANC_ROOT}/Plugins/Samples/Common/FullOrthancDataset.cpp
  ${ORTHANC_ROOT}/Plugins/Samples/Common/IOrthancConnection.cpp

  ${AUTOGENERATED_SOURCES}

  # Mandatory components
  ${BOOST_SOURCES}
  ${CAIRO_SOURCES}
  ${JSONCPP_SOURCES}
  ${PIXMAN_SOURCES}
  ${ZLIB_SOURCES}
  ${LIBPNG_SOURCES}
  ${LIBJPEG_SOURCES}

  # Optional components
  ${OPENSSL_SOURCES}
  ${CURL_SOURCES}
  ${SDL_SOURCES}
  )