comparison CMakeLists.txt @ 606:ce5d2040c47b find-move-scp

integration mainline -> find-move-scp
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Oct 2013 14:20:13 +0200
parents c2be0a0e049e 84011417321d
children dbecea588ef5
comparison
equal deleted inserted replaced
567:c2be0a0e049e 606:ce5d2040c47b
1 cmake_minimum_required(VERSION 2.8) 1 cmake_minimum_required(VERSION 2.8)
2 2
3 project(Orthanc) 3 project(Orthanc)
4 4
5 # Version of the build, should always be "mainline" except in release branches 5 # Version of the build, should always be "mainline" except in release branches
6 add_definitions( 6 set(ORTHANC_VERSION "mainline")
7 -DORTHANC_VERSION="mainline" 7
8 ) 8
9 #####################################################################
10 ## CMake parameters tunable at the command line
11 #####################################################################
9 12
10 # Parameters of the build 13 # Parameters of the build
11 SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") 14 SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
12 SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)") 15 SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
13 SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL") 16 SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
14 SET(BUILD_UNIT_TESTS ON CACHE BOOL "Build the unit tests") 17 SET(BUILD_UNIT_TESTS ON CACHE BOOL "Build the unit tests")
18 SET(BUILD_CLIENT_LIBRARY ON CACHE BOOL "Build the client library")
15 SET(DCMTK_DICTIONARY_DIR "/usr/share/dcmtk" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (ignored in standalone builds)") 19 SET(DCMTK_DICTIONARY_DIR "/usr/share/dcmtk" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (ignored in standalone builds)")
16 20
17 # Advanced parameters to fine-tune linking against system libraries 21 # Advanced parameters to fine-tune linking against system libraries
18 SET(USE_DYNAMIC_JSONCPP OFF CACHE BOOL "Use the dynamic version of JsonCpp") 22 SET(USE_DYNAMIC_JSONCPP OFF CACHE BOOL "Use the dynamic version of JsonCpp")
19 SET(USE_DYNAMIC_GOOGLE_LOG ON CACHE BOOL "Use the dynamic version of Google Log") 23 SET(USE_DYNAMIC_GOOGLE_LOG ON CACHE BOOL "Use the dynamic version of Google Log")
35 include(CheckLibraryExists) 39 include(CheckLibraryExists)
36 include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake) 40 include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
37 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake) 41 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
38 include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake) 42 include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake)
39 43
44 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR})
45
46
47
48
49 #####################################################################
50 ## Inclusion of third-party dependencies
51 #####################################################################
52
40 # Configuration of the standalone builds 53 # Configuration of the standalone builds
41 if (${CMAKE_CROSSCOMPILING}) 54 if (CMAKE_CROSSCOMPILING)
42 # Cross-compilation implies the standalone build 55 # Cross-compilation implies the standalone build
43 SET(STANDALONE_BUILD ON) 56 SET(STANDALONE_BUILD ON)
44 endif() 57 endif()
45 58
46 # Prepare the third-party dependencies 59 # Prepare the third-party dependencies
47 SET(THIRD_PARTY_SOURCES 60 SET(THIRD_PARTY_SOURCES
48 ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c 61 ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
49 ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp 62 ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
50 ${CMAKE_SOURCE_DIR}/Resources/sha1/sha1.cpp
51 ) 63 )
52 64
53 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleLogConfiguration.cmake) 65 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleLogConfiguration.cmake)
54 66
55 if (${ENABLE_SSL}) 67 if (${ENABLE_SSL})
68 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake) 80 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
69 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake) 81 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
70 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake) 82 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
71 83
72 84
85
86 #####################################################################
87 ## Autogeneration of files
88 #####################################################################
89
73 # Prepare the embedded files 90 # Prepare the embedded files
74 set(EMBEDDED_FILES 91 set(EMBEDDED_FILES
75 PREPARE_DATABASE ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql 92 PREPARE_DATABASE ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql
76 PREPARE_DATABASE_V4 ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabaseV4.sql 93 PREPARE_DATABASE_V4 ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabaseV4.sql
77 CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json 94 CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json
96 ) 113 )
97 endif() 114 endif()
98 115
99 116
100 117
101 # The main instructions to build the Orthanc binaries 118 #####################################################################
119 ## Build the core of Orthanc
120 #####################################################################
121
122 add_definitions(
123 -DORTHANC_VERSION="${ORTHANC_VERSION}"
124 )
125
126 list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
127 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
128 add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
129 endif()
130
102 add_library(CoreLibrary 131 add_library(CoreLibrary
103 STATIC 132 STATIC
104 ${AUTOGENERATED_SOURCES} 133 ${AUTOGENERATED_SOURCES}
105 ${THIRD_PARTY_SOURCES} 134 ${THIRD_PARTY_SOURCES}
135 ${CURL_SOURCES}
106 136
107 Core/Cache/MemoryCache.cpp 137 Core/Cache/MemoryCache.cpp
108 Core/ChunkedBuffer.cpp 138 Core/ChunkedBuffer.cpp
109 Core/Compression/BufferCompressor.cpp 139 Core/Compression/BufferCompressor.cpp
110 Core/Compression/ZlibCompressor.cpp 140 Core/Compression/ZlibCompressor.cpp
155 OrthancCppClient/Instance.cpp 185 OrthancCppClient/Instance.cpp
156 OrthancCppClient/Patient.cpp 186 OrthancCppClient/Patient.cpp
157 ) 187 )
158 188
159 189
190 #####################################################################
191 ## Build the Orthanc server
192 #####################################################################
193
160 add_library(ServerLibrary 194 add_library(ServerLibrary
161 STATIC 195 STATIC
162 ${DCMTK_SOURCES} 196 ${DCMTK_SOURCES}
163 OrthancServer/DicomProtocol/DicomFindAnswers.cpp 197 OrthancServer/DicomProtocol/DicomFindAnswers.cpp
164 OrthancServer/DicomProtocol/DicomServer.cpp 198 OrthancServer/DicomProtocol/DicomServer.cpp
186 OrthancServer/main.cpp 220 OrthancServer/main.cpp
187 ) 221 )
188 222
189 target_link_libraries(Orthanc ServerLibrary CoreLibrary) 223 target_link_libraries(Orthanc ServerLibrary CoreLibrary)
190 224
225 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
226 target_link_libraries(Orthanc OpenSSL)
227 endif()
228
191 install( 229 install(
192 TARGETS Orthanc 230 TARGETS Orthanc
193 RUNTIME DESTINATION bin 231 RUNTIME DESTINATION bin
194 ) 232 )
195 233
196 # Build the unit tests if required 234
235
236 #####################################################################
237 ## Build the unit tests if required
238 #####################################################################
239
197 if (BUILD_UNIT_TESTS) 240 if (BUILD_UNIT_TESTS)
198 add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1) 241 add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1)
199 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) 242 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
200 add_executable(UnitTests 243 add_executable(UnitTests
201 ${GTEST_SOURCES} 244 ${GTEST_SOURCES}
210 UnitTests/Zip.cpp 253 UnitTests/Zip.cpp
211 UnitTests/Lua.cpp 254 UnitTests/Lua.cpp
212 UnitTests/main.cpp 255 UnitTests/main.cpp
213 ) 256 )
214 target_link_libraries(UnitTests ServerLibrary CoreLibrary) 257 target_link_libraries(UnitTests ServerLibrary CoreLibrary)
215 endif() 258
216 259 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
217 260 target_link_libraries(UnitTests OpenSSL)
218 # Generate the Doxygen documentation if Doxygen is present 261 endif()
262 endif()
263
264
265
266 #####################################################################
267 ## Create the standalone DLL containing the Orthanc Client API
268 #####################################################################
269
270 if (BUILD_CLIENT_LIBRARY)
271 include_directories(${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw)
272
273 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
274 if (CMAKE_CROSSCOMPILING)
275 # Remove the default "lib" prefix from "libOrthancClient.dll" if cross-compiling
276 set(CMAKE_SHARED_LIBRARY_PREFIX "")
277
278 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
279 set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.def)
280 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
281 set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.def)
282 else()
283 message(FATAL_ERROR "Support your platform here")
284 endif()
285 else()
286 # Nothing to do if using Visual Studio
287 endif()
288
289 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
290 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows32.dll")
291 list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.rc)
292 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
293 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll")
294 list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.rc)
295 else()
296 message(FATAL_ERROR "Support your platform here")
297 endif()
298
299 else()
300 set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES})
301 endif()
302
303 add_library(OrthancClient SHARED
304 ${ORTHANC_ROOT}/Core/OrthancException.cpp
305 ${ORTHANC_ROOT}/Core/Enumerations.cpp
306 ${ORTHANC_ROOT}/Core/Toolbox.cpp
307 ${ORTHANC_ROOT}/Core/HttpClient.cpp
308 ${ORTHANC_ROOT}/Core/MultiThreading/ArrayFilledByThreads.cpp
309 ${ORTHANC_ROOT}/Core/MultiThreading/ThreadedCommandProcessor.cpp
310 ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp
311 ${ORTHANC_ROOT}/Core/FileFormats/PngReader.cpp
312 ${ORTHANC_ROOT}/OrthancCppClient/OrthancConnection.cpp
313 ${ORTHANC_ROOT}/OrthancCppClient/Series.cpp
314 ${ORTHANC_ROOT}/OrthancCppClient/Study.cpp
315 ${ORTHANC_ROOT}/OrthancCppClient/Instance.cpp
316 ${ORTHANC_ROOT}/OrthancCppClient/Patient.cpp
317 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/SharedLibrary.cpp
318 ${ORTHANC_ROOT}/Resources/md5/md5.c
319 ${ORTHANC_ROOT}/Resources/base64/base64.cpp
320 ${ORTHANC_CPP_CLIENT_AUX}
321 ${THIRD_PARTY_SOURCES}
322 ${CURL_SOURCES}
323 )
324
325 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
326 set_target_properties(OrthancClient
327 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map"
328 )
329 target_link_libraries(OrthancClient pthread)
330
331 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
332 target_link_libraries(OrthancClient OpenSSL ws2_32)
333
334 if (CMAKE_CROSSCOMPILING)
335 set_target_properties(OrthancClient
336 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++"
337 )
338 endif()
339
340 else()
341 message(FATAL_ERROR "Support your platform here")
342 endif()
343
344
345 # Set the version of the "Orthanc Client" shared library
346 file(STRINGS
347 ${CMAKE_SOURCE_DIR}/OrthancCppClient/SharedLibrary/Product.json
348 ORTHANC_CLIENT_VERSION_TMP
349 REGEX "^[ \t]*\"Version\"[ \t]*")
350
351 string(REGEX REPLACE "^.*\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"" "\\1.\\2"
352 ORTHANC_CLIENT_VERSION ${ORTHANC_CLIENT_VERSION_TMP})
353
354 message("Setting the version of the library to ${ORTHANC_CLIENT_VERSION}")
355
356 set_target_properties(OrthancClient PROPERTIES
357 VERSION ${ORTHANC_CLIENT_VERSION}
358 SOVERSION ${ORTHANC_CLIENT_VERSION})
359
360
361 install(
362 TARGETS OrthancClient
363 RUNTIME DESTINATION lib # Destination for Windows
364 LIBRARY DESTINATION lib # Destination for Linux
365 )
366
367 install(
368 FILES ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/OrthancCppClient.h
369 DESTINATION include/orthanc
370 )
371 endif()
372
373
374
375
376 #####################################################################
377 ## Generate the documentation if Doxygen is present
378 #####################################################################
379
219 find_package(Doxygen) 380 find_package(Doxygen)
220 if (DOXYGEN_FOUND) 381 if (DOXYGEN_FOUND)
221 configure_file( 382 configure_file(
222 ${CMAKE_SOURCE_DIR}/Resources/Orthanc.doxygen 383 ${CMAKE_SOURCE_DIR}/Resources/Orthanc.doxygen
223 ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen 384 ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
224 @ONLY) 385 @ONLY)
386
225 add_custom_target(doc 387 add_custom_target(doc
226 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen 388 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
227 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 389 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
228 COMMENT "Generating API documentation with Doxygen" VERBATIM 390 COMMENT "Generating internal documentation with Doxygen" VERBATIM
229 ) 391 )
392
393 if (BUILD_CLIENT_LIBRARY)
394 configure_file(
395 ${CMAKE_SOURCE_DIR}/Resources/OrthancClient.doxygen
396 ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
397 @ONLY)
398
399 add_custom_command(TARGET OrthancClient
400 POST_BUILD
401 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
402 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
403 COMMENT "Generating client documentation with Doxygen" VERBATIM
404 )
405
406 install(
407 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OrthancClientDocumentation/doc/
408 DESTINATION share/doc/orthanc/OrthancClient
409 )
410 endif()
411
230 else() 412 else()
231 message("Doxygen not found. The documentation will not be built.") 413 message("Doxygen not found. The documentation will not be built.")
232 endif() 414 endif()
233 415
416
417 #####################################################################
418 ## Prepare the "uninstall" target
419 ## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
420 #####################################################################
421
422 configure_file(
423 "${CMAKE_CURRENT_SOURCE_DIR}/Resources/CMake/Uninstall.cmake.in"
424 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
425 IMMEDIATE @ONLY)
426
427 add_custom_target(uninstall
428 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)