comparison Resources/Orthanc/DownloadOrthancFramework.cmake @ 34:53dbed29949a

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 01 Jul 2020 16:10:02 +0200
parents 79d871605ffd
children 8ada1b669194
comparison
equal deleted inserted replaced
32:79d871605ffd 34:53dbed29949a
193 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}) 193 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT})
194 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}") 194 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}")
195 endif() 195 endif()
196 196
197 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake) 197 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
198 message(FATAL_ERROR "Directory not containing the source code of Orthanc: ${ORTHANC_FRAMEWORK_ROOT}") 198 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_FRAMEWORK_ROOT}")
199 endif() 199 endif()
200
201 set(ORTHANC_ROOT ${ORTHANC_FRAMEWORK_ROOT})
202 endif() 200 endif()
203 201
204 202
205 203
206 ## 204 ##
243 ) 241 )
244 242
245 if (Failure) 243 if (Failure)
246 message(FATAL_ERROR "Error while running Mercurial") 244 message(FATAL_ERROR "Error while running Mercurial")
247 endif() 245 endif()
246
247 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
248 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE
249 STRING "Path to the Orthanc framework source directory")
250
251 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
252 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}")
253 endif()
254
255 unset(ORTHANC_ROOT)
248 endif() 256 endif()
249 257
250 258
251 259
252 ## 260 ##
370 378
371 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}") 379 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
372 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.") 380 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.")
373 endif() 381 endif()
374 endif() 382 endif()
383
384 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
385 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE
386 STRING "Path to the Orthanc framework source directory")
387
388 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
389 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}")
390 endif()
391
392 unset(ORTHANC_ROOT)
375 endif() 393 endif()
376 394
377 395
378 396
379 ## 397 ##
397 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake) 415 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
398 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake) 416 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
399 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake) 417 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
400 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py) 418 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
401 419
402 if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND 420 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR
403 NOT ORTHANC_FRAMEWORK_STATIC) 421 ORTHANC_FRAMEWORK_STATIC)
422 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
423 else()
404 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake) 424 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
405 find_path(JSONCPP_INCLUDE_DIR json/reader.h 425 find_path(JSONCPP_INCLUDE_DIR json/reader.h
406 /usr/include/jsoncpp 426 /usr/include/jsoncpp
407 /usr/local/include/jsoncpp 427 /usr/local/include/jsoncpp
408 ) 428 )
445 if (NOT HAVE_SQLITE_H) 465 if (NOT HAVE_SQLITE_H)
446 message(FATAL_ERROR "Please install the libsqlite3-dev package") 466 message(FATAL_ERROR "Please install the libsqlite3-dev package")
447 endif() 467 endif()
448 link_libraries(sqlite3) 468 link_libraries(sqlite3)
449 endif() 469 endif()
470
471 # Optional component - Pugixml
472 if (ENABLE_PUGIXML)
473 CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H)
474 if (NOT HAVE_PUGIXML_H)
475 message(FATAL_ERROR "Please install the libpugixml-dev package")
476 endif()
477 link_libraries(pugixml)
478 endif()
479
480 # Optional component - DCMTK
481 if (ENABLE_DCMTK)
482 include(FindDCMTK)
483 include_directories(${DCMTK_INCLUDE_DIRS})
484 link_libraries(${DCMTK_LIBRARIES})
485 endif()
450 endif() 486 endif()
451 487
452 # Optional component - Google Test 488 # Optional component - Google Test
453 if (ENABLE_GOOGLE_TEST) 489 if (ENABLE_GOOGLE_TEST)
454 set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test") 490 set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
460 # Look for Orthanc framework shared library 496 # Look for Orthanc framework shared library
461 include(CheckCXXSymbolExists) 497 include(CheckCXXSymbolExists)
462 498
463 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") 499 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
464 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}) 500 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT})
465 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
466 else() 501 else()
467 find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h 502 find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
468 /usr/include/orthanc-framework 503 /usr/include/orthanc-framework
469 /usr/local/include/orthanc-framework 504 /usr/local/include/orthanc-framework
470 ${ORTHANC_FRAMEWORK_ROOT} 505 ${ORTHANC_FRAMEWORK_ROOT}
471 ) 506 )
472 endif() 507 endif()
508
509 if (${ORTHANC_FRAMEWORK_INCLUDE_DIR} STREQUAL "ORTHANC_FRAMEWORK_INCLUDE_DIR-NOTFOUND")
510 message(FATAL_ERROR "Cannot locate the OrthancFramework.h header")
511 endif()
473 512
474 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}") 513 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
475 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR}) 514 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
476 515
516 if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
517 set(ORTHANC_FRAMEWORK_LIBRARIES OrthancFramework)
518 else()
519 if (MSVC)
520 set(Suffix ".lib")
521 set(Prefix "")
522 else()
523 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
524 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix)
525 endif()
526 set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix})
527 endif()
528
477 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}") 529 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
478 530 set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}")
479 if (NOT "${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
480 set(CMAKE_REQUIRED_LIBRARIES "-L${ORTHANC_FRAMEWORK_LIBDIR} -lOrthancFramework")
481 else()
482 set(CMAKE_REQUIRED_LIBRARIES "OrthancFramework")
483 endif()
484 531
485 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK) 532 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
486 if(NOT HAVE_ORTHANC_FRAMEWORK) 533 if (NOT HAVE_ORTHANC_FRAMEWORK)
487 message(FATAL_ERROR "Cannot find the Orthanc framework") 534 message(FATAL_ERROR "Cannot find the Orthanc framework")
488 endif() 535 endif()
489 536
490 if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "") 537 if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "")
491 include_directories(${ORTHANC_FRAMEWORK_ROOT}) 538 include_directories(${ORTHANC_FRAMEWORK_ROOT})
492 endif() 539 endif()
493 540 endif()
494 if (NOT "${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
495 link_directories(${ORTHANC_FRAMEWORK_LIBDIR})
496 endif()
497 endif()