Mercurial > hg > orthanc-client
view CMakeLists.txt @ 17:ae34bde412ae default tip
note
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 21 Dec 2016 11:05:16 +0100 |
parents | f7379096e014 |
children |
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)") SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") # 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) SET(ENABLE_PLUGINS_VERSION_SCRIPT OFF) 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/GoogleTestConfiguration.cmake) include(Orthanc/Resources/CMake/JsonCppConfiguration.cmake) include(Orthanc/Resources/CMake/LibCurlConfiguration.cmake) include(Orthanc/Resources/CMake/LibPngConfiguration.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 SharedLibrary/AUTOGENERATED/Windows32.def) elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) set(ORTHANC_CPP_CLIENT_AUX 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 SharedLibrary/AUTOGENERATED/Windows32.rc) elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll") list(APPEND ORTHANC_CPP_CLIENT_AUX SharedLibrary/AUTOGENERATED/Windows64.rc) else() message(FATAL_ERROR "Support your platform here") endif() else() set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES}) endif() add_definitions( -DORTHANC_ENABLE_MD5=0 -DORTHANC_ENABLE_BASE64=0 -DORTHANC_ENABLE_LOGGING=0 ) add_library(OrthancClient SHARED Orthanc/Core/ChunkedBuffer.cpp Orthanc/Core/Enumerations.cpp Orthanc/Core/HttpClient.cpp Orthanc/Core/Images/ImageAccessor.cpp Orthanc/Core/Images/PngReader.cpp Orthanc/Core/MultiThreading/SharedMessageQueue.cpp Orthanc/Core/Toolbox.cpp 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} ) add_executable(UnitTests CppClient/ArrayFilledByThreads.cpp CppClient/ThreadedCommandProcessor.cpp Orthanc/Core/Enumerations.cpp Orthanc/Core/MultiThreading/SharedMessageQueue.cpp Orthanc/Core/Toolbox.cpp UnitTestsSources/MultiThreadingTests.cpp UnitTestsSources/UnitTestsMain.cpp ${THIRD_PARTY_SOURCES} ${GTEST_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 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)