view CMakeLists.txt @ 222:bd934af46ba4

unit test of storagearea in separate file
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2012 18:03:37 +0100
parents e7432706b354
children 4eb0c7ce86c9
line wrap: on
line source

cmake_minimum_required(VERSION 2.8)

project(Orthanc)

# Version of the build, should always be "mainline" except in release branches
add_definitions(
  -DORTHANC_VERSION="mainline"
  )

# Parameters of the build
SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
SET(STANDALONE_BUILD OFF CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
SET(BUILD_UNIT_TESTS ON CACHE BOOL "Build the unit tests")

# Advanced parameters (for Debian packaging)
SET(USE_DYNAMIC_JSONCPP OFF CACHE BOOL "Use the dynamic version of JsonCpp (only for Debian sid)")
SET(USE_DYNAMIC_GOOGLE_LOG ON CACHE BOOL "Use the dynamic version of Google Log")
SET(USE_DYNAMIC_GOOGLE_TEST ON CACHE BOOL "Use the dynamic version of Google Test (not for Debian sid)")
SET(USE_DYNAMIC_SQLITE ON CACHE BOOL "Use the dynamic version of SQLite")
SET(DEBIAN_FORCE_HARDENING OFF CACHE BOOL "Force the injection of Debian hardening flags (unrecommended)")
SET(DEBIAN_USE_GTEST_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (only for Debian sid)")

mark_as_advanced(USE_DYNAMIC_JSONCPP)
mark_as_advanced(USE_DYNAMIC_GOOGLE_LOG)
mark_as_advanced(USE_DYNAMIC_GOOGLE_TEST)
mark_as_advanced(USE_DYNAMIC_SQLITE)
mark_as_advanced(DEBIAN_FORCE_HARDENING)
mark_as_advanced(DEBIAN_USE_STATIC_GOOGLE_TEST)

# Some basic inclusions
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake)

# Configuration of the standalone builds
if (${CMAKE_CROSSCOMPILING})
  # Cross-compilation implies the standalone build
  SET(STANDALONE_BUILD ON)
endif()

if (${STANDALONE_BUILD})
  # We embed all the resources in the binaries for standalone builds
  add_definitions(-DORTHANC_STANDALONE=1)
  EmbedResources(
    PREPARE_DATABASE OrthancServer/PrepareDatabase.sql
    ORTHANC_EXPLORER OrthancExplorer
    CONFIGURATION_SAMPLE Resources/Configuration.json
    )
else()
  add_definitions(
    -DORTHANC_STANDALONE=0
    -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\"
    )
  EmbedResources(
    PREPARE_DATABASE OrthancServer/PrepareDatabase.sql
    CONFIGURATION_SAMPLE Resources/Configuration.json
    )
endif()


# Prepare the third-party dependencies
SET(THIRD_PARTY_SOURCES
  ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
  ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
  ${CMAKE_SOURCE_DIR}/Resources/sha1/sha1.cpp
  )

include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleLogConfiguration.cmake)

if (${ENABLE_SSL})
  add_definitions(-DORTHANC_SSL_ENABLED=1)
  include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
else()
  add_definitions(-DORTHANC_SSL_ENABLED=0)
endif()

include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)


# The main instructions to build the Orthanc binaries
add_library(CoreLibrary
  STATIC
  ${AUTOGENERATED_SOURCES}
  ${THIRD_PARTY_SOURCES}

  Core/ChunkedBuffer.cpp
  Core/Compression/BufferCompressor.cpp
  Core/Compression/ZlibCompressor.cpp
  Core/Compression/ZipWriter.cpp
  Core/OrthancException.cpp
  Core/DicomFormat/DicomArray.cpp
  Core/DicomFormat/DicomMap.cpp
  Core/DicomFormat/DicomTag.cpp
  Core/DicomFormat/DicomIntegerPixelAccessor.cpp
  Core/DicomFormat/DicomInstanceHasher.cpp
  Core/FileStorage.cpp
  Core/FileStorage/StorageAccessor.cpp
  Core/FileStorage/CompressedFileStorageAccessor.cpp
  Core/HttpServer/EmbeddedResourceHttpHandler.cpp
  Core/HttpServer/FilesystemHttpHandler.cpp
  Core/HttpServer/HttpHandler.cpp
  Core/HttpServer/HttpOutput.cpp
  Core/HttpServer/MongooseServer.cpp
  Core/HttpServer/HttpFileSender.cpp
  Core/HttpServer/FilesystemHttpSender.cpp
  Core/RestApi/RestApiPath.cpp
  Core/RestApi/RestApiOutput.cpp
  Core/RestApi/RestApi.cpp
  Core/MultiThreading/BagOfRunnablesBySteps.cpp
  Core/PngWriter.cpp
  Core/SQLite/Connection.cpp
  Core/SQLite/FunctionContext.cpp
  Core/SQLite/Statement.cpp
  Core/SQLite/StatementId.cpp
  Core/SQLite/StatementReference.cpp
  Core/SQLite/Transaction.cpp
  Core/Toolbox.cpp
  Core/Uuid.cpp

  OrthancCppClient/HttpClient.cpp
  OrthancCppClient/HttpException.cpp
  )  

add_library(ServerLibrary
  OrthancServer/DicomProtocol/DicomFindAnswers.cpp
  OrthancServer/DicomProtocol/DicomServer.cpp
  OrthancServer/DicomProtocol/DicomUserConnection.cpp
  OrthancServer/FromDcmtkBridge.cpp
  OrthancServer/Internals/CommandDispatcher.cpp
  OrthancServer/Internals/FindScp.cpp
  OrthancServer/Internals/MoveScp.cpp
  OrthancServer/Internals/StoreScp.cpp
  OrthancServer/OrthancInitialization.cpp
  OrthancServer/OrthancRestApi.cpp
  OrthancServer/OrthancRestApi2.cpp
  OrthancServer/ServerIndex.cpp
  OrthancServer/ToDcmtkBridge.cpp
  OrthancServer/DatabaseWrapper.cpp
  OrthancServer/ServerEnumerations.cpp
  OrthancServer/ServerToolbox.cpp
  )

# Ensure autogenerated code is built before building ServerLibrary
add_dependencies(ServerLibrary CoreLibrary)

add_executable(Orthanc
  OrthancServer/main.cpp
  )

target_link_libraries(Orthanc ServerLibrary CoreLibrary)

install(
  TARGETS Orthanc
  RUNTIME DESTINATION bin
  )


# Build the unit tests if required
if (BUILD_UNIT_TESTS)
  include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
  add_executable(UnitTests
    ${GTEST_SOURCES}
    UnitTests/MessageWithDestination.cpp
    UnitTests/RestApi.cpp
    UnitTests/SQLite.cpp
    UnitTests/SQLiteChromium.cpp
    UnitTests/ServerIndex.cpp
    UnitTests/Versions.cpp
    UnitTests/Zip.cpp
    UnitTests/FileStorage.cpp
    UnitTests/main.cpp
    )
  target_link_libraries(UnitTests ServerLibrary CoreLibrary)
endif()


# Generate the Doxygen documentation if Doxygen is present
find_package(Doxygen)
if (DOXYGEN_FOUND)
  configure_file(
    ${CMAKE_SOURCE_DIR}/Resources/Orthanc.doxygen
    ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
    @ONLY)
  add_custom_target(doc
    ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    COMMENT "Generating API documentation with Doxygen" VERBATIM
    )
else()
  message("Doxygen not found. The documentation will not be built.")
endif()