view CMakeLists.txt @ 20:a2c57c351627 OrthancGoogleCloudPlatform-1.0

add windows resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 Jun 2019 15:53:09 +0200
parents e7ea54d8c16c
children 17f371dc120d
line wrap: on
line source

cmake_minimum_required(VERSION 2.8)

project(GoogleCloudPlatform)

set(GCP_PLUGIN_VERSION "1.0")

if (GCP_PLUGIN_VERSION STREQUAL "mainline")
  if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
    set(ORTHANC_FRAMEWORK_VERSION "mainline")
  else()
    # "hg" is not available in holy-build-box => We set
    # "ORTHANC_FRAMEWORK_SOURCE" to "web" in the BuildBot script, which
    # forces to use a specific version (1.5.7)
    set(ORTHANC_FRAMEWORK_VERSION "1.5.7")
  endif()
    
  set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
else()
  set(ORTHANC_FRAMEWORK_VERSION "1.5.7")
  set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
endif()


# Parameters of the build
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(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")")
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\"")

# Advanced parameters to fine-tune linking against system libraries
set(USE_SYSTEM_GDCM ON CACHE BOOL "Use the system version of Grassroot DICOM (GDCM)")
set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
set(ORTHANC_SDK_VERSION "1.0.0" CACHE STRING "Version of the Orthanc plugin SDK to use, if not using the system version (can be \"1.0.0\", or \"framework\")")


include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/DownloadOrthancFramework.cmake)

include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)

set(ENABLE_CRYPTO_OPTIONS ON)
set(ENABLE_ZLIB ON)
set(ENABLE_WEB_CLIENT ON)
set(ENABLE_OPENSSL_ENGINES ON)  # Necessary on Windows

include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkConfiguration.cmake)

include(${CMAKE_SOURCE_DIR}/Resources/CMake/CRC32C.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/NlohmannJson.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleCloudPlatform.cmake)


if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
  if (ORTHANC_SDK_VERSION STREQUAL "1.0.0")
    include_directories(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-1.0.0)
  elseif (ORTHANC_SDK_VERSION STREQUAL "framework")
    include_directories(${ORTHANC_ROOT}/Plugins/Include)
  else()
    message(FATAL_ERROR "Unsupported version of the Orthanc plugin SDK: ${ORTHANC_SDK_VERSION}")
  endif()
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()



add_definitions(
  -DHAS_ORTHANC_EXCEPTION=1
  -DORTHANC_ENABLE_LOGGING=1
  -DORTHANC_ENABLE_LOGGING_PLUGIN=1
  -DGCP_PLUGIN_VERSION="${GCP_PLUGIN_VERSION}"
  )

include_directories(
  ${AUTOGENERATED_DIR}
  ${ORTHANC_ROOT}
  )

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  execute_process(
    COMMAND 
    ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py
    ${GCP_PLUGIN_VERSION} "Google Cloud Platform plugin" OrthancGoogleCloudPlatform.dll
    "Plugin to access Google Cloud Platform from Orthanc"
    ERROR_VARIABLE Failure
    OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/Version.rc
    )

  if (Failure)
    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
  endif()

  set(GCP_RESOURCES  ${CMAKE_CURRENT_BINARY_DIR}/Version.rc)
endif()


if (ON)
  # Redefine the list of Orthanc sources, removing unused items, in
  # order to reduce the number of files and speed up the builds
  set(ORTHANC_CORE_SOURCES
    ${ORTHANC_CORE_SOURCES_DEPENDENCIES}
    ${ORTHANC_ROOT}/Core/ChunkedBuffer.cpp
    ${ORTHANC_ROOT}/Core/Enumerations.cpp
    ${ORTHANC_ROOT}/Core/HttpClient.cpp
    ${ORTHANC_ROOT}/Core/Logging.cpp
    ${ORTHANC_ROOT}/Core/SystemToolbox.cpp
    ${ORTHANC_ROOT}/Core/Toolbox.cpp
    )
endif()

add_library(OrthancGoogleCloudPlatform SHARED
  ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
  ${GCP_RESOURCES}
  Plugin/GoogleAccount.cpp
  Plugin/GoogleConfiguration.cpp
  Plugin/GoogleUpdater.cpp
  Plugin/Plugin.cpp

  ${CRC32C_SOURCES}
  ${CURL_SOURCES}
  ${GCP_SOURCES}
  ${OPENSSL_SOURCES}
  ${ZLIB_SOURCES}
  ${ORTHANC_CORE_SOURCES}
  )  

set_target_properties(OrthancGoogleCloudPlatform PROPERTIES 
  VERSION ${GCP_PLUGIN_VERSION} 
  SOVERSION ${GCP_PLUGIN_VERSION})

install(
  TARGETS OrthancGoogleCloudPlatform
  RUNTIME DESTINATION lib    # Destination for Windows
  LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
  )