Mercurial > hg > orthanc
diff CMakeLists.txt @ 605:b82292ba2083 dicom-rt
integration mainline -> dicom-rt
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Oct 2013 14:21:50 +0200 |
parents | e318e9d49815 84011417321d |
children | 8cfc6119a5bd |
line wrap: on
line diff
--- a/CMakeLists.txt Wed Sep 04 14:19:14 2013 +0200 +++ b/CMakeLists.txt Thu Oct 17 14:21:50 2013 +0200 @@ -3,15 +3,19 @@ project(Orthanc) # Version of the build, should always be "mainline" except in release branches -add_definitions( - -DORTHANC_VERSION="mainline" - ) +set(ORTHANC_VERSION "mainline") + + +##################################################################### +## CMake parameters tunable at the command line +##################################################################### # Parameters of the build SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") SET(STANDALONE_BUILD ON 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") +SET(BUILD_CLIENT_LIBRARY ON CACHE BOOL "Build the client library") SET(DCMTK_DICTIONARY_DIR "/usr/share/dcmtk" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (ignored in standalone builds)") # Advanced parameters to fine-tune linking against system libraries @@ -37,8 +41,17 @@ include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake) +set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}) + + + + +##################################################################### +## Inclusion of third-party dependencies +##################################################################### + # Configuration of the standalone builds -if (${CMAKE_CROSSCOMPILING}) +if (CMAKE_CROSSCOMPILING) # Cross-compilation implies the standalone build SET(STANDALONE_BUILD ON) endif() @@ -47,7 +60,6 @@ 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) @@ -70,6 +82,11 @@ include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake) + +##################################################################### +## Autogeneration of files +##################################################################### + # Prepare the embedded files set(EMBEDDED_FILES PREPARE_DATABASE ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql @@ -97,11 +114,24 @@ -# The main instructions to build the Orthanc binaries +##################################################################### +## Build the core of Orthanc +##################################################################### + +add_definitions( + -DORTHANC_VERSION="${ORTHANC_VERSION}" + ) + +list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH) +if (${OPENSSL_SOURCES_LENGTH} GREATER 0) + add_library(OpenSSL STATIC ${OPENSSL_SOURCES}) +endif() + add_library(CoreLibrary STATIC ${AUTOGENERATED_SOURCES} ${THIRD_PARTY_SOURCES} + ${CURL_SOURCES} Core/Cache/MemoryCache.cpp Core/ChunkedBuffer.cpp @@ -156,6 +186,10 @@ ) +##################################################################### +## Build the Orthanc server +##################################################################### + add_library(ServerLibrary STATIC ${DCMTK_SOURCES} @@ -188,12 +222,21 @@ target_link_libraries(Orthanc ServerLibrary CoreLibrary) +if (${OPENSSL_SOURCES_LENGTH} GREATER 0) + target_link_libraries(Orthanc OpenSSL) +endif() + install( TARGETS Orthanc RUNTIME DESTINATION bin ) -# Build the unit tests if required + + +##################################################################### +## Build the unit tests if required +##################################################################### + if (BUILD_UNIT_TESTS) add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1) include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) @@ -212,22 +255,174 @@ UnitTests/main.cpp ) target_link_libraries(UnitTests ServerLibrary CoreLibrary) + + if (${OPENSSL_SOURCES_LENGTH} GREATER 0) + target_link_libraries(UnitTests OpenSSL) + endif() endif() -# Generate the Doxygen documentation if Doxygen is present + +##################################################################### +## Create the standalone DLL containing the Orthanc Client API +##################################################################### + +if (BUILD_CLIENT_LIBRARY) + include_directories(${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/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 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.def) + elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/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 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.rc) + elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll") + list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/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_ROOT}/Core/OrthancException.cpp + ${ORTHANC_ROOT}/Core/Enumerations.cpp + ${ORTHANC_ROOT}/Core/Toolbox.cpp + ${ORTHANC_ROOT}/Core/HttpClient.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/ArrayFilledByThreads.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/ThreadedCommandProcessor.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp + ${ORTHANC_ROOT}/Core/FileFormats/PngReader.cpp + ${ORTHANC_ROOT}/OrthancCppClient/OrthancConnection.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Series.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Study.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Instance.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Patient.cpp + ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/SharedLibrary.cpp + ${ORTHANC_ROOT}/Resources/md5/md5.c + ${ORTHANC_ROOT}/Resources/base64/base64.cpp + ${ORTHANC_CPP_CLIENT_AUX} + ${THIRD_PARTY_SOURCES} + ${CURL_SOURCES} + ) + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set_target_properties(OrthancClient + PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map" + ) + target_link_libraries(OrthancClient pthread) + + elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(OrthancClient OpenSSL 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() + + else() + message(FATAL_ERROR "Support your platform here") + endif() + + + # Set the version of the "Orthanc Client" shared library + file(STRINGS + ${CMAKE_SOURCE_DIR}/OrthancCppClient/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 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/OrthancCppClient.h + DESTINATION include/orthanc + ) +endif() + + + + +##################################################################### +## Generate the 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 + COMMENT "Generating internal documentation with Doxygen" VERBATIM ) + + if (BUILD_CLIENT_LIBRARY) + 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 + ) + endif() + 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}/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)