Mercurial > hg > orthanc-client
diff CMakeLists.txt @ 1:fd402e53d263
new files
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 11:12:20 +0200 |
parents | |
children | d5027f9f676a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Mon Jun 01 11:12:20 2015 +0200 @@ -0,0 +1,162 @@ +# TODO ! + +cmake_minimum_required(VERSION 2.8) + +project(OrthancClient) + + OrthancCppClient/OrthancConnection.cpp + OrthancCppClient/Study.cpp + OrthancCppClient/Series.cpp + OrthancCppClient/Instance.cpp + OrthancCppClient/Patient.cpp + + + + +##################################################################### +## Create the standalone DLL containing the Orthanc Client API +##################################################################### + +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}/OrthancCppClient/OrthancCppClient.cpp + ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/SharedLibrary.cpp + ${ORTHANC_ROOT}/Resources/ThirdParty/md5/md5.c + ${ORTHANC_ROOT}/Resources/ThirdParty/base64/base64.cpp + ${ORTHANC_CPP_CLIENT_AUX} + ${THIRD_PARTY_SOURCES} + ${CURL_SOURCES} + ${GOOGLE_LOG_SOURCES} + ) + +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=${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() + +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}/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 + ${ORTHANC_ROOT}/Plugins/Include/OrthancCPlugin.h + ${ORTHANC_ROOT}/Plugins/Include/OrthancCDatabasePlugin.h + ${ORTHANC_ROOT}/Plugins/Include/OrthancCppDatabasePlugin.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}/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)