comparison CMakeLists.txt @ 3:d5027f9f676a

fix build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 01 Jun 2015 15:12:22 +0200
parents fd402e53d263
children c584c25a74fd
comparison
equal deleted inserted replaced
2:8f22ed9d48d5 3:d5027f9f676a
2 2
3 cmake_minimum_required(VERSION 2.8) 3 cmake_minimum_required(VERSION 2.8)
4 4
5 project(OrthancClient) 5 project(OrthancClient)
6 6
7 OrthancCppClient/OrthancConnection.cpp 7
8 OrthancCppClient/Study.cpp 8 # Parameters of the build
9 OrthancCppClient/Series.cpp 9 SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
10 OrthancCppClient/Instance.cpp 10
11 OrthancCppClient/Patient.cpp 11 # Advanced parameters to fine-tune linking against system libraries
12 12 SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
13 13 SET(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
14 SET(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
15 SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
16 SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of LibPng")
17 SET(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
18 SET(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
19
20 # Some basic inclusions
21 SET(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Orthanc)
22 SET(ENABLE_SSL ON)
23
24 include(CheckIncludeFiles)
25 include(CheckIncludeFileCXX)
26 include(CheckLibraryExists)
27 include(FindPythonInterp)
28 include(Orthanc/Resources/CMake/DownloadPackage.cmake)
29 include(Orthanc/Resources/CMake/Compiler.cmake)
30
31 include(Orthanc/Resources/CMake/BoostConfiguration.cmake)
32 include(Orthanc/Resources/CMake/JsonCppConfiguration.cmake)
33 include(Orthanc/Resources/CMake/LibPngConfiguration.cmake)
34 include(Orthanc/Resources/CMake/LibCurlConfiguration.cmake)
35 include(Orthanc/Resources/CMake/OpenSslConfiguration.cmake)
36 include(Orthanc/Resources/CMake/ZlibConfiguration.cmake)
37
38 add_definitions(-DORTHANC_SSL_ENABLED=1)
14 39
15 40
16 ##################################################################### 41 #####################################################################
17 ## Create the standalone DLL containing the Orthanc Client API 42 ## Create the standalone DLL containing the Orthanc Client API
18 ##################################################################### 43 #####################################################################
19 44
20 include_directories(${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw) 45 include_directories(OrthancCppClient/SharedLibrary/Laaw)
21 46
22 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 47 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
23 if (CMAKE_CROSSCOMPILING) 48 if (CMAKE_CROSSCOMPILING)
24 # Remove the default "lib" prefix from "libOrthancClient.dll" if cross-compiling 49 # Remove the default "lib" prefix from "libOrthancClient.dll" if cross-compiling
25 set(CMAKE_SHARED_LIBRARY_PREFIX "") 50 set(CMAKE_SHARED_LIBRARY_PREFIX "")
26 51
27 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4) 52 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
28 set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.def) 53 set(ORTHANC_CPP_CLIENT_AUX OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.def)
29 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) 54 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
30 set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.def) 55 set(ORTHANC_CPP_CLIENT_AUX OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.def)
31 else() 56 else()
32 message(FATAL_ERROR "Support your platform here") 57 message(FATAL_ERROR "Support your platform here")
33 endif() 58 endif()
34 else() 59 else()
35 # Nothing to do if using Visual Studio 60 # Nothing to do if using Visual Studio
36 endif() 61 endif()
37 62
38 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4) 63 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
39 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows32.dll") 64 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows32.dll")
40 list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.rc) 65 list(APPEND ORTHANC_CPP_CLIENT_AUX OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.rc)
41 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) 66 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
42 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll") 67 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll")
43 list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.rc) 68 list(APPEND ORTHANC_CPP_CLIENT_AUX OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.rc)
44 else() 69 else()
45 message(FATAL_ERROR "Support your platform here") 70 message(FATAL_ERROR "Support your platform here")
46 endif() 71 endif()
47 72
48 else() 73 else()
49 set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES}) 74 set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES})
50 endif() 75 endif()
51 76
77
52 add_library(OrthancClient SHARED 78 add_library(OrthancClient SHARED
53 ${ORTHANC_ROOT}/OrthancCppClient/OrthancCppClient.cpp 79 Orthanc/Core/HttpClient.cpp
54 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/SharedLibrary.cpp 80 Orthanc/Core/ImageFormats/PngReader.cpp
55 ${ORTHANC_ROOT}/Resources/ThirdParty/md5/md5.c 81 Orthanc/Core/ImageFormats/ImageAccessor.cpp
56 ${ORTHANC_ROOT}/Resources/ThirdParty/base64/base64.cpp 82 Orthanc/Core/MultiThreading/SharedMessageQueue.cpp
83 Orthanc/Core/Toolbox.cpp
84 Orthanc/Core/ChunkedBuffer.cpp
85 Orthanc/Core/Enumerations.cpp
86 Orthanc/Core/OrthancException.cpp
87 Orthanc/Resources/ThirdParty/base64/base64.cpp
88 Orthanc/Resources/ThirdParty/base64/base64.cpp
89 Orthanc/Resources/ThirdParty/md5/md5.c
90
91 OrthancCppClient/Instance.cpp
92 OrthancCppClient/OrthancConnection.cpp
93 OrthancCppClient/Patient.cpp
94 OrthancCppClient/Series.cpp
95 OrthancCppClient/SharedLibrary/SharedLibrary.cpp
96 OrthancCppClient/Study.cpp
97 OrthancCppClient/ArrayFilledByThreads.cpp
98 OrthancCppClient/ThreadedCommandProcessor.cpp
99
57 ${ORTHANC_CPP_CLIENT_AUX} 100 ${ORTHANC_CPP_CLIENT_AUX}
58 ${THIRD_PARTY_SOURCES} 101 ${THIRD_PARTY_SOURCES}
59 ${CURL_SOURCES} 102 ${CURL_SOURCES}
60 ${GOOGLE_LOG_SOURCES}
61 ) 103 )
104
105
106 list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
107 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
108 add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
109 target_link_libraries(OrthancClient OpenSSL)
110 endif()
111
62 112
63 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR 113 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
64 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR 114 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
65 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") 115 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
66 set_target_properties(OrthancClient 116 set_target_properties(OrthancClient
67 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map" 117 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${CMAKE_SOURCE_DIR}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map"
68 ) 118 )
69 target_link_libraries(OrthancClient pthread) 119 target_link_libraries(OrthancClient pthread)
70 120
71 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 121 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
72 target_link_libraries(OrthancClient OpenSSL ws2_32) 122 target_link_libraries(OrthancClient ws2_32)
73 123
74 if (CMAKE_CROSSCOMPILING) 124 if (CMAKE_CROSSCOMPILING)
75 set_target_properties(OrthancClient 125 set_target_properties(OrthancClient
76 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++" 126 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++"
77 ) 127 )
108 LIBRARY DESTINATION lib # Destination for Linux 158 LIBRARY DESTINATION lib # Destination for Linux
109 ) 159 )
110 160
111 install( 161 install(
112 FILES 162 FILES
113 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/OrthancCppClient.h 163 OrthancCppClient/SharedLibrary/AUTOGENERATED/OrthancCppClient.h
114 ${ORTHANC_ROOT}/Plugins/Include/OrthancCPlugin.h
115 ${ORTHANC_ROOT}/Plugins/Include/OrthancCDatabasePlugin.h
116 ${ORTHANC_ROOT}/Plugins/Include/OrthancCppDatabasePlugin.h
117 DESTINATION include/orthanc 164 DESTINATION include/orthanc
118 ) 165 )
119 166
120 167
121 168
152 ## Prepare the "uninstall" target 199 ## Prepare the "uninstall" target
153 ## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F 200 ## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
154 ##################################################################### 201 #####################################################################
155 202
156 configure_file( 203 configure_file(
157 "${CMAKE_CURRENT_SOURCE_DIR}/Resources/CMake/Uninstall.cmake.in" 204 "${CMAKE_CURRENT_SOURCE_DIR}/Orthanc/Resources/CMake/Uninstall.cmake.in"
158 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" 205 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
159 IMMEDIATE @ONLY) 206 IMMEDIATE @ONLY)
160 207
161 add_custom_target(uninstall 208 add_custom_target(uninstall
162 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 209 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)