view CMakeLists.txt @ 8:6d59828e2662

removal of Orthanc namespace
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jun 2015 10:55:32 +0200
parents c584c25a74fd
children 1fb480a156fd
line wrap: on
line source

# TODO !

cmake_minimum_required(VERSION 2.8)

project(OrthancClient)


# Parameters of the build
SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")

# 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_CURL ON CACHE BOOL "Use the system version of LibCurl")
SET(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of LibPng")
SET(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
SET(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")

# Some basic inclusions
SET(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Orthanc)
SET(ENABLE_SSL ON)

include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(FindPythonInterp)
include(Orthanc/Resources/CMake/DownloadPackage.cmake)
include(Orthanc/Resources/CMake/Compiler.cmake)

include(Orthanc/Resources/CMake/BoostConfiguration.cmake)
include(Orthanc/Resources/CMake/JsonCppConfiguration.cmake)
include(Orthanc/Resources/CMake/LibPngConfiguration.cmake)
include(Orthanc/Resources/CMake/LibCurlConfiguration.cmake)
include(Orthanc/Resources/CMake/OpenSslConfiguration.cmake)
include(Orthanc/Resources/CMake/ZlibConfiguration.cmake)

add_definitions(-DORTHANC_SSL_ENABLED=1)


#####################################################################
## Create the standalone DLL containing the Orthanc Client API
#####################################################################

include_directories(Resources/Laaw)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  if (CMAKE_CROSSCOMPILING)
    # Remove the default "lib" prefix from "libOrthancClient.dll" if cross-compiling
    set(CMAKE_SHARED_LIBRARY_PREFIX "")

    if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
      set(ORTHANC_CPP_CLIENT_AUX CppClient/SharedLibrary/AUTOGENERATED/Windows32.def)
    elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
      set(ORTHANC_CPP_CLIENT_AUX CppClient/SharedLibrary/AUTOGENERATED/Windows64.def)
    else()
      message(FATAL_ERROR "Support your platform here")
    endif()
  else()
    # Nothing to do if using Visual Studio
  endif()

  if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
    set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows32.dll")
    list(APPEND ORTHANC_CPP_CLIENT_AUX CppClient/SharedLibrary/AUTOGENERATED/Windows32.rc)
  elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
    set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll")
    list(APPEND ORTHANC_CPP_CLIENT_AUX CppClient/SharedLibrary/AUTOGENERATED/Windows64.rc)
  else()
    message(FATAL_ERROR "Support your platform here")
  endif()    

else()
  set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES})
endif()


add_library(OrthancClient SHARED
  Orthanc/Core/HttpClient.cpp
  Orthanc/Core/ImageFormats/PngReader.cpp
  Orthanc/Core/ImageFormats/ImageAccessor.cpp
  Orthanc/Core/MultiThreading/SharedMessageQueue.cpp
  Orthanc/Core/Toolbox.cpp
  Orthanc/Core/ChunkedBuffer.cpp
  Orthanc/Core/Enumerations.cpp
  Orthanc/Core/OrthancException.cpp
  Orthanc/Resources/ThirdParty/base64/base64.cpp
  Orthanc/Resources/ThirdParty/base64/base64.cpp
  Orthanc/Resources/ThirdParty/md5/md5.c

  CppClient/Instance.cpp
  CppClient/OrthancConnection.cpp
  CppClient/Patient.cpp
  CppClient/Series.cpp
  CppClient/Study.cpp
  CppClient/ArrayFilledByThreads.cpp
  CppClient/ThreadedCommandProcessor.cpp

  SharedLibrary/SharedLibrary.cpp

  ${ORTHANC_CPP_CLIENT_AUX}
  ${THIRD_PARTY_SOURCES}
  ${CURL_SOURCES}
  )


list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
  add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
  target_link_libraries(OrthancClient OpenSSL)
endif()


if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
    ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
    ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
  set_target_properties(OrthancClient
    PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${CMAKE_SOURCE_DIR}/Resources/Laaw/VersionScript.map"
    )
  target_link_libraries(OrthancClient pthread dl)

elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  target_link_libraries(OrthancClient ws2_32)

  if (CMAKE_CROSSCOMPILING)
    set_target_properties(OrthancClient
      PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++"
      )
  endif()

elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
  # TODO
  target_link_libraries(OrthancClient pthread)

else()
  message(FATAL_ERROR "Support your platform here")
endif()


# Set the version of the "Orthanc Client" shared library
file(STRINGS
  ${CMAKE_SOURCE_DIR}/SharedLibrary/Product.json
  ORTHANC_CLIENT_VERSION_TMP
  REGEX "^[ \t]*\"Version\"[ \t]*")

string(REGEX REPLACE "^.*\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"" "\\1.\\2" 
  ORTHANC_CLIENT_VERSION ${ORTHANC_CLIENT_VERSION_TMP})

message("Setting the version of the library to ${ORTHANC_CLIENT_VERSION}")

set_target_properties(OrthancClient PROPERTIES 
  VERSION ${ORTHANC_CLIENT_VERSION} 
  SOVERSION ${ORTHANC_CLIENT_VERSION})


install(
  TARGETS OrthancClient
  RUNTIME DESTINATION lib    # Destination for Windows
  LIBRARY DESTINATION lib    # Destination for Linux
  )

install(
  FILES
  CppClient/SharedLibrary/AUTOGENERATED/CppClient.h 
  DESTINATION include/orthanc
  )




#####################################################################
## Generate the documentation if Doxygen is present
#####################################################################

find_package(Doxygen)
if (DOXYGEN_FOUND)
  configure_file(
    ${CMAKE_SOURCE_DIR}/Resources/OrthancClient.doxygen
    ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
    @ONLY)

  add_custom_command(TARGET OrthancClient 
    POST_BUILD
    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    COMMENT "Generating client documentation with Doxygen" VERBATIM
    )

  install(
    DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OrthancClientDocumentation/doc/
    DESTINATION share/doc/orthanc/OrthancClient
    )

else()
  message("Doxygen not found. The documentation will not be built.")
endif()


#####################################################################
## Prepare the "uninstall" target
## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
#####################################################################

configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/Orthanc/Resources/CMake/Uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

add_custom_target(uninstall
  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)