Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
544:a482948c1fd6 | 605:b82292ba2083 |
---|---|
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 CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json | 93 CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json |
77 LUA_TOOLBOX ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Toolbox.lua | 94 LUA_TOOLBOX ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Toolbox.lua |
95 ) | 112 ) |
96 endif() | 113 endif() |
97 | 114 |
98 | 115 |
99 | 116 |
100 # The main instructions to build the Orthanc binaries | 117 ##################################################################### |
118 ## Build the core of Orthanc | |
119 ##################################################################### | |
120 | |
121 add_definitions( | |
122 -DORTHANC_VERSION="${ORTHANC_VERSION}" | |
123 ) | |
124 | |
125 list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH) | |
126 if (${OPENSSL_SOURCES_LENGTH} GREATER 0) | |
127 add_library(OpenSSL STATIC ${OPENSSL_SOURCES}) | |
128 endif() | |
129 | |
101 add_library(CoreLibrary | 130 add_library(CoreLibrary |
102 STATIC | 131 STATIC |
103 ${AUTOGENERATED_SOURCES} | 132 ${AUTOGENERATED_SOURCES} |
104 ${THIRD_PARTY_SOURCES} | 133 ${THIRD_PARTY_SOURCES} |
134 ${CURL_SOURCES} | |
105 | 135 |
106 Core/Cache/MemoryCache.cpp | 136 Core/Cache/MemoryCache.cpp |
107 Core/ChunkedBuffer.cpp | 137 Core/ChunkedBuffer.cpp |
108 Core/Compression/BufferCompressor.cpp | 138 Core/Compression/BufferCompressor.cpp |
109 Core/Compression/ZlibCompressor.cpp | 139 Core/Compression/ZlibCompressor.cpp |
154 OrthancCppClient/Instance.cpp | 184 OrthancCppClient/Instance.cpp |
155 OrthancCppClient/Patient.cpp | 185 OrthancCppClient/Patient.cpp |
156 ) | 186 ) |
157 | 187 |
158 | 188 |
189 ##################################################################### | |
190 ## Build the Orthanc server | |
191 ##################################################################### | |
192 | |
159 add_library(ServerLibrary | 193 add_library(ServerLibrary |
160 STATIC | 194 STATIC |
161 ${DCMTK_SOURCES} | 195 ${DCMTK_SOURCES} |
162 OrthancServer/DicomProtocol/DicomFindAnswers.cpp | 196 OrthancServer/DicomProtocol/DicomFindAnswers.cpp |
163 OrthancServer/DicomProtocol/DicomServer.cpp | 197 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) |