view CMakeLists.txt @ 53:487f87984eac default tip

added CITATION.cff
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 06 Apr 2024 17:15:10 +0200
parents c2faa911b51d
children
line wrap: on
line source


# C++11 is necessary to build the Google Cloud Platform C++ Client
# Libraries (this plugin cannot be compiled on Visual Studio 2008, or
# using Linux Standard Base - HolyBuildBox is used on Linux). MinGW on
# Ubuntu 18.04 does not work either, as "std::mutex" seems to be
# undefined. https://github.com/googleapis/google-cloud-cpp


cmake_minimum_required(VERSION 2.8)

project(GoogleCloudPlatform)

set(GCP_PLUGIN_VERSION "mainline")

if (GCP_PLUGIN_VERSION STREQUAL "mainline")
  set(ORTHANC_FRAMEWORK_VERSION "mainline")
  set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
else()
  set(ORTHANC_FRAMEWORK_VERSION "1.9.3")
  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\")")


# Download and setup the Orthanc framework
include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake)

if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
  if (ORTHANC_FRAMEWORK_USE_SHARED)
    include(FindBoost)
    find_package(Boost COMPONENTS thread)
    
    if (NOT Boost_FOUND)
      message(FATAL_ERROR "Unable to locate Boost on this system")
    endif()
    
    link_libraries(${Boost_LIBRARIES} jsoncpp)
  endif()
  
  link_libraries(${ORTHANC_FRAMEWORK_LIBRARIES})

  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")
  
  include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/LibCurlConfiguration.cmake)
  include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/OpenSslConfiguration.cmake)

else()
  set(OPENSSL_STATIC_VERSION "1.1.1" CACHE STRING "Force the use of OpenSSL 1.1.1" FORCE)
  
  include(${ORTHANC_FRAMEWORK_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_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkConfiguration.cmake)
  include_directories(${ORTHANC_FRAMEWORK_ROOT})
endif()


include(${CMAKE_SOURCE_DIR}/Resources/CMake/CRC32C.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/NlohmannJson.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleCloudPlatform.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginsExports.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)
  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}
  )

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  execute_process(
    COMMAND 
    ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_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 (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
  # 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_FRAMEWORK_ROOT}/ChunkedBuffer.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/DicomFormat/DicomTag.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/Enumerations.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/HttpClient.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/Logging.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/OrthancException.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/SerializationToolbox.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/SystemToolbox.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/Toolbox.cpp
    ${ORTHANC_FRAMEWORK_ROOT}/WebServiceParameters.cpp
    )
endif()

add_library(OrthancGoogleCloudPlatform SHARED
  ${GCP_RESOURCES}
  Plugin/GoogleAccount.cpp
  Plugin/GoogleConfiguration.cpp
  Plugin/GoogleUpdater.cpp
  Plugin/Plugin.cpp
  Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp

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

if (COMMAND DefineSourceBasenameForTarget)
  DefineSourceBasenameForTarget(OrthancGoogleCloudPlatform)
endif()

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
  )