changeset 2388:50cde8246542

CMake to build the Orthanc framework without the Orthanc server
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Aug 2017 11:26:08 +0200
parents a60a79929007
children 88402bd5dbf5
files CMakeLists.txt Core/Compression/HierarchicalZipWriter.h Core/Compression/ZipWriter.h Core/SQLite/Statement.h Resources/CMake/OrthancFrameworkConfiguration.cmake Resources/CMake/OrthancFrameworkParameters.cmake Resources/Samples/Tools/CMakeLists.txt
diffstat 7 files changed, 594 insertions(+), 340 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Wed Aug 30 09:29:31 2017 +0200
+++ b/CMakeLists.txt	Wed Aug 30 11:26:08 2017 +0200
@@ -2,17 +2,26 @@
 
 project(Orthanc)
 
-# Version of the build, should always be "mainline" except in release branches
-set(ORTHANC_VERSION "mainline")
+
+#####################################################################
+## Generic parameters of the Orthanc framework
+#####################################################################
+
+include(${CMAKE_SOURCE_DIR}/Resources/CMake/OrthancFrameworkParameters.cmake)
 
-# Version of the database schema. History:
-#   * Orthanc 0.1.0 -> Orthanc 0.3.0 = no versioning
-#   * Orthanc 0.3.1                  = version 2
-#   * Orthanc 0.4.0 -> Orthanc 0.7.2 = version 3
-#   * Orthanc 0.7.3 -> Orthanc 0.8.4 = version 4
-#   * Orthanc 0.8.5 -> Orthanc 0.9.4 = version 5
-#   * Orthanc 0.9.5 -> mainline      = version 6
-set(ORTHANC_DATABASE_VERSION 6)
+# Enable all the optional components of the Orthanc framework
+set(ENABLE_CRYPTO_OPTIONS ON)
+set(ENABLE_JPEG ON)
+set(ENABLE_LOCALE ON)
+set(ENABLE_LUA ON)
+set(ENABLE_PNG ON)
+set(ENABLE_PUGIXML ON)
+set(ENABLE_SQLITE ON)
+set(ENABLE_WEB_CLIENT ON)
+set(ENABLE_WEB_SERVER ON)
+set(ENABLE_DCMTK ON)
+set(ENABLE_DCMTK_NETWORKING ON)
+set(HAS_EMBEDDED_RESOURCES ON)
 
 
 #####################################################################
@@ -20,172 +29,41 @@
 #####################################################################
 
 # Parameters of the build
-SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
-SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
-SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
-SET(DCMTK_DICTIONARY_DIR "" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (only when using system version of DCMTK)") 
-SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
-SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
-SET(ENABLE_DCMTK_JPEG ON CACHE BOOL "Enable JPEG decompression in DCMTK")
-SET(ENABLE_DCMTK_JPEG_LOSSLESS ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression in DCMTK")
-SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins")
-SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Whether to build the ServeFolders plugin")
 SET(BUILD_MODALITY_WORKLISTS ON CACHE BOOL "Whether to build the sample plugin to serve modality worklists")
 SET(BUILD_RECOVER_COMPRESSED_FILE ON CACHE BOOL "Whether to build the companion tool to recover files compressed using Orthanc")
-SET(ENABLE_PKCS11 OFF CACHE BOOL "Enable PKCS#11 for HTTPS client authentication using hardware security modules and smart cards")
-SET(ENABLE_PROFILING OFF CACHE BOOL "Whether to enable the generation of profiling information with gprof")
-SET(ENABLE_CIVETWEB OFF CACHE BOOL "Use Civetweb instead of Mongoose (experimental)")
+SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Whether to build the ServeFolders plugin")
+SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins")
+SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
+SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
 
 # Advanced parameters to fine-tune linking against system libraries
-SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
-SET(USE_SYSTEM_CIVETWEB ON CACHE BOOL "Use the system version of Civetweb (experimental)")
-SET(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
-SET(USE_SYSTEM_DCMTK ON CACHE BOOL "Use the system version of DCMTK")
+SET(USE_GTEST_DEBIAN_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
 SET(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
-SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
-SET(USE_SYSTEM_LIBICONV ON CACHE BOOL "Use the system version of libiconv")
-SET(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
-SET(USE_SYSTEM_LIBP11 OFF CACHE BOOL "Use the system version of libp11 (PKCS#11 wrapper library)")
-SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
-SET(USE_SYSTEM_LUA ON CACHE BOOL "Use the system version of Lua")
-SET(USE_SYSTEM_MONGOOSE ON CACHE BOOL "Use the system version of Mongoose")
-SET(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
-SET(USE_SYSTEM_PUGIXML ON CACHE BOOL "Use the system version of Pugixml")
-SET(USE_SYSTEM_SQLITE ON CACHE BOOL "Use the system version of SQLite")
-SET(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
-
-# Advanced parameters
-SET(USE_PUGIXML ON CACHE BOOL "Use the Pugixml parser (turn off only for debug)")
-SET(USE_DCMTK_360 OFF CACHE BOOL "Use older DCMTK version 3.6.0 in static builds (instead of default 3.6.2)")
-SET(USE_DCMTK_362_PRIVATE_DIC ON CACHE BOOL "Use the dictionary of private tags from DCMTK 3.6.2 if using DCMTK 3.6.0")
-
-# Distribution-specific settings
-SET(USE_GTEST_DEBIAN_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
-SET(SYSTEM_MONGOOSE_USE_CALLBACKS ON CACHE BOOL "The system version of Mongoose uses callbacks (version >= 3.7)")
-SET(USE_BOOST_ICONV ON CACHE BOOL "Use iconv instead of wconv (Windows only)")
 
 mark_as_advanced(USE_GTEST_DEBIAN_SOURCE_PACKAGE)
-mark_as_advanced(SYSTEM_MONGOOSE_USE_CALLBACKS)
-mark_as_advanced(USE_BOOST_ICONV)
-mark_as_advanced(USE_PUGIXML)
+
 
-# Path to the root folder of the Orthanc distribution
-set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR})
-
-# These options must be set to "ON" if compiling Orthanc, but might be
-# set to "OFF" in some plugins if their support is not required
-set(ENABLE_DCMTK_NETWORKING ON)  # Enable support for DICOM networking in DCMTK
-set(ENABLE_LOCALE ON)            # Enable support for locales (notably in Boost)
+#####################################################################
+## Configuration of the Orthanc framework
+#####################################################################
 
-# Some basic inclusions
-include(CheckIncludeFiles)
-include(CheckIncludeFileCXX)
-include(CheckFunctionExists)
-include(CheckLibraryExists)
-include(FindPythonInterp)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/VisualStudioPrecompiledHeaders.cmake)
+include(${CMAKE_SOURCE_DIR}/Resources/CMake/OrthancFrameworkConfiguration.cmake)
+include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
 
+include_directories(${ORTHANC_ROOT})
 
 
 #####################################################################
 ## List of source files
 #####################################################################
 
-set(ORTHANC_CORE_SOURCES
-  Core/Cache/MemoryCache.cpp
-  Core/Cache/SharedArchive.cpp
-  Core/ChunkedBuffer.cpp
-  Core/Compression/DeflateBaseCompressor.cpp
-  Core/Compression/GzipCompressor.cpp
-  Core/Compression/HierarchicalZipWriter.cpp
-  Core/Compression/ZipWriter.cpp
-  Core/Compression/ZlibCompressor.cpp
-  Core/DicomFormat/DicomArray.cpp
-  Core/DicomFormat/DicomMap.cpp
-  Core/DicomFormat/DicomTag.cpp
-  Core/DicomFormat/DicomImageInformation.cpp
-  Core/DicomFormat/DicomIntegerPixelAccessor.cpp
-  Core/DicomFormat/DicomInstanceHasher.cpp
-  Core/DicomFormat/DicomValue.cpp
-  Core/Enumerations.cpp
-  Core/FileStorage/FilesystemStorage.cpp
-  Core/FileStorage/StorageAccessor.cpp
-  Core/HttpClient.cpp
-  Core/HttpServer/BufferHttpSender.cpp
-  Core/HttpServer/EmbeddedResourceHttpHandler.cpp
-  Core/HttpServer/FilesystemHttpHandler.cpp
-  Core/HttpServer/HttpToolbox.cpp
-  Core/HttpServer/HttpOutput.cpp
-  Core/HttpServer/StringHttpOutput.cpp
-  Core/HttpServer/MongooseServer.cpp
-  Core/HttpServer/HttpFileSender.cpp
-  Core/HttpServer/FilesystemHttpSender.cpp
-  Core/HttpServer/HttpContentNegociation.cpp
-  Core/HttpServer/HttpStreamTranscoder.cpp
-  Core/Logging.cpp
-  Core/RestApi/RestApiCall.cpp
-  Core/RestApi/RestApiGetCall.cpp
-  Core/RestApi/RestApiHierarchy.cpp
-  Core/RestApi/RestApiPath.cpp
-  Core/RestApi/RestApiOutput.cpp
-  Core/RestApi/RestApi.cpp
-  Core/MultiThreading/BagOfTasksProcessor.cpp
-  Core/MultiThreading/Mutex.cpp
-  Core/MultiThreading/ReaderWriterLock.cpp
-  Core/MultiThreading/RunnableWorkersPool.cpp
-  Core/MultiThreading/Semaphore.cpp
-  Core/MultiThreading/SharedMessageQueue.cpp
-  Core/Images/Font.cpp
-  Core/Images/FontRegistry.cpp
-  Core/Images/IImageWriter.cpp
-  Core/Images/Image.cpp
-  Core/Images/ImageAccessor.cpp
-  Core/Images/ImageBuffer.cpp
-  Core/Images/ImageProcessing.cpp
-  Core/Images/JpegErrorManager.cpp
-  Core/Images/JpegReader.cpp
-  Core/Images/JpegWriter.cpp
-  Core/Images/PngReader.cpp
-  Core/Images/PngWriter.cpp
-  Core/SQLite/Connection.cpp
-  Core/SQLite/FunctionContext.cpp
-  Core/SQLite/Statement.cpp
-  Core/SQLite/StatementId.cpp
-  Core/SQLite/StatementReference.cpp
-  Core/SQLite/Transaction.cpp
-  Core/SystemToolbox.cpp
-  Core/TemporaryFile.cpp
-  Core/Toolbox.cpp
-  Core/WebServiceParameters.cpp
-  Core/Lua/LuaContext.cpp
-  Core/Lua/LuaFunctionCall.cpp
-  )
-
-
 set(ORTHANC_SERVER_SOURCES
-  Core/DicomParsing/DicomDirWriter.cpp
-  Core/DicomParsing/DicomModification.cpp
-  Core/DicomParsing/FromDcmtkBridge.cpp
-  Core/DicomParsing/Internals/DicomFrameIndex.cpp
-  Core/DicomParsing/Internals/DicomImageDecoder.cpp
-  Core/DicomParsing/ParsedDicomFile.cpp
-  Core/DicomParsing/ToDcmtkBridge.cpp
-
-  Core/DicomNetworking/DicomFindAnswers.cpp
-  Core/DicomNetworking/DicomServer.cpp
-  Core/DicomNetworking/DicomUserConnection.cpp
-  Core/DicomNetworking/RemoteModalityParameters.cpp
-  Core/DicomNetworking/ReusableDicomUserConnection.cpp
-  Core/DicomNetworking/Internals/CommandDispatcher.cpp
-  Core/DicomNetworking/Internals/FindScp.cpp
-  Core/DicomNetworking/Internals/MoveScp.cpp
-  Core/DicomNetworking/Internals/StoreScp.cpp
-
+  ${ORTHANC_DICOM_SOURCES}
+  
   OrthancServer/DatabaseWrapper.cpp
   OrthancServer/DatabaseWrapperBase.cpp
+  OrthancServer/DicomInstanceToStore.cpp
   OrthancServer/ExportedResource.cpp
   OrthancServer/LuaScripting.cpp
   OrthancServer/OrthancFindRequestHandler.cpp
@@ -200,13 +78,21 @@
   OrthancServer/OrthancRestApi/OrthancRestResources.cpp
   OrthancServer/OrthancRestApi/OrthancRestSystem.cpp
   OrthancServer/QueryRetrieveHandler.cpp
+  OrthancServer/Scheduler/CallSystemCommand.cpp
+  OrthancServer/Scheduler/DeleteInstanceCommand.cpp
+  OrthancServer/Scheduler/ModifyInstanceCommand.cpp
+  OrthancServer/Scheduler/ServerCommandInstance.cpp
+  OrthancServer/Scheduler/ServerJob.cpp
+  OrthancServer/Scheduler/ServerScheduler.cpp
+  OrthancServer/Scheduler/StorePeerCommand.cpp
+  OrthancServer/Scheduler/StoreScuCommand.cpp
   OrthancServer/Search/HierarchicalMatcher.cpp
   OrthancServer/Search/IFindConstraint.cpp
+  OrthancServer/Search/ListConstraint.cpp
   OrthancServer/Search/LookupIdentifierQuery.cpp
   OrthancServer/Search/LookupResource.cpp
+  OrthancServer/Search/RangeConstraint.cpp
   OrthancServer/Search/SetOfResources.cpp
-  OrthancServer/Search/ListConstraint.cpp
-  OrthancServer/Search/RangeConstraint.cpp
   OrthancServer/Search/ValueConstraint.cpp
   OrthancServer/Search/WildcardConstraint.cpp
   OrthancServer/ServerContext.cpp
@@ -214,17 +100,6 @@
   OrthancServer/ServerIndex.cpp
   OrthancServer/ServerToolbox.cpp
   OrthancServer/SliceOrdering.cpp
-
-  # From "lua-scripting" branch
-  OrthancServer/DicomInstanceToStore.cpp
-  OrthancServer/Scheduler/DeleteInstanceCommand.cpp
-  OrthancServer/Scheduler/ModifyInstanceCommand.cpp
-  OrthancServer/Scheduler/ServerCommandInstance.cpp
-  OrthancServer/Scheduler/ServerJob.cpp
-  OrthancServer/Scheduler/ServerScheduler.cpp
-  OrthancServer/Scheduler/StorePeerCommand.cpp
-  OrthancServer/Scheduler/StoreScuCommand.cpp
-  OrthancServer/Scheduler/CallSystemCommand.cpp
   )
 
 
@@ -265,27 +140,30 @@
 endif()
 
 
-set(ORTHANC_ALL_SOURCES
-  ${ORTHANC_CORE_SOURCES}
-  ${ORTHANC_SERVER_SOURCES}
-  ${ORTHANC_UNIT_TESTS_SOURCES}
-  Plugins/Samples/ServeFolders/Plugin.cpp
-  Plugins/Samples/ModalityWorklists/Plugin.cpp
-  OrthancServer/main.cpp
-  )
-
-
 if (CMAKE_COMPILER_IS_GNUCXX
     AND NOT CMAKE_CROSSCOMPILING 
     AND USE_DCMTK_360)
   # Add the "-pedantic" flag only on the Orthanc sources, and only if
-  # using DCMTK 3.6.0
+  # cross-compiling DCMTK 3.6.0
+  set(ORTHANC_ALL_SOURCES
+    ${ORTHANC_CORE_SOURCES_INTERNAL}
+    ${ORTHANC_SERVER_SOURCES}
+    ${ORTHANC_UNIT_TESTS_SOURCES}
+    Plugins/Samples/ServeFolders/Plugin.cpp
+    Plugins/Samples/ModalityWorklists/Plugin.cpp
+    OrthancServer/main.cpp
+    )
+
   set_source_files_properties(${ORTHANC_ALL_SOURCES}
     PROPERTIES COMPILE_FLAGS -pedantic
     )
 endif()
 
 
+#####################################################################
+## Autogeneration of files
+#####################################################################
+
 set(ORTHANC_EMBEDDED_FILES
   PREPARE_DATABASE            ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql
   UPGRADE_DATABASE_3_TO_4     ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/Upgrade3To4.sql
@@ -296,105 +174,6 @@
   FONT_UBUNTU_MONO_BOLD_16    ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Fonts/UbuntuMonoBold-16.json
   )
 
-
-
-#####################################################################
-## Inclusion of third-party dependencies
-#####################################################################
-
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibJpegConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibIconvConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
-
-if (USE_PUGIXML)
-  include(${CMAKE_SOURCE_DIR}/Resources/CMake/PugixmlConfiguration.cmake)
-  add_definitions(-DORTHANC_ENABLE_PUGIXML=1)
-else()
-  add_definitions(-DORTHANC_ENABLE_PUGIXML=0)  
-endif()
-
-if (ENABLE_CIVETWEB)
-  include(${CMAKE_SOURCE_DIR}/Resources/CMake/CivetwebConfiguration.cmake)
-  add_definitions(
-    -DORTHANC_ENABLE_CIVETWEB=1
-    -DORTHANC_ENABLE_MONGOOSE=0
-    )
-else()
-  include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
-  add_definitions(
-    -DORTHANC_ENABLE_CIVETWEB=0
-    -DORTHANC_ENABLE_MONGOOSE=1
-    )
-endif()
-
-# These are the two most heavyweight dependencies. We put them as the
-# last includes to quickly spot problems when configuring static
-# builds.
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
-
-
-if (ENABLE_SSL)
-  add_definitions(-DORTHANC_ENABLE_SSL=1)
-else()
-  add_definitions(-DORTHANC_ENABLE_SSL=0)
-endif()
-
-
-if (ENABLE_DCMTK_JPEG)
-  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG=1)
-else()
-  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG=0)
-endif()
-
-
-if (ENABLE_DCMTK_JPEG_LOSSLESS)
-  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=1)
-else()
-  add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=0)
-endif()
-
-
-if (ENABLE_PLUGINS)
-  add_definitions(-DORTHANC_ENABLE_PLUGINS=1)
-else()
-  add_definitions(-DORTHANC_ENABLE_PLUGINS=0)
-endif()
-
-
-if (ENABLE_LOCALE)
-  add_definitions(-DORTHANC_ENABLE_LOCALE=1)
-else()
-  add_definitions(-DORTHANC_ENABLE_LOCALE=0)
-endif()
-
-
-if (ENABLE_PKCS11)
-  if (ENABLE_SSL)
-    include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibP11Configuration.cmake)
-
-    add_definitions(-DORTHANC_ENABLE_PKCS11=1)
-    list(APPEND ORTHANC_CORE_SOURCES Core/Pkcs11.cpp)
-  else()
-    message(FATAL_ERROR "OpenSSL is required to enable PKCS#11")
-  endif()
-else()
-  add_definitions(-DORTHANC_ENABLE_PKCS11=0)  
-endif()
-
-
-
-#####################################################################
-## Autogeneration of files
-#####################################################################
-
 if (STANDALONE_BUILD)
   # We embed all the resources in the binaries for standalone builds
   add_definitions(-DORTHANC_STANDALONE=1)
@@ -435,32 +214,24 @@
 ## Configuration of the C/C++ macros
 #####################################################################
 
+if (ENABLE_PLUGINS)
+  add_definitions(-DORTHANC_ENABLE_PLUGINS=1)
+else()
+  add_definitions(-DORTHANC_ENABLE_PLUGINS=0)
+endif()
+
+
 if (UNIT_TESTS_WITH_HTTP_CONNEXIONS)
   add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1)
 else()
   add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=0)
 endif()
 
+
 include_directories(${CMAKE_SOURCE_DIR}/Plugins/Include)
 
 add_definitions(
-  -DORTHANC_VERSION="${ORTHANC_VERSION}"
-  -DORTHANC_DATABASE_VERSION=${ORTHANC_DATABASE_VERSION}
   -DORTHANC_BUILD_UNIT_TESTS=1
-  -DORTHANC_ENABLE_BASE64=1
-  -DORTHANC_ENABLE_LOGGING=1
-  -DORTHANC_ENABLE_LOGGING_PLUGIN=0
-  -DORTHANC_ENABLE_DCMTK=1
-  -DORTHANC_ENABLE_DCMTK_NETWORKING=1
-  -DORTHANC_ENABLE_JPEG=1
-  -DORTHANC_ENABLE_LUA=1
-  -DORTHANC_ENABLE_MD5=1
-  -DORTHANC_ENABLE_PNG=1
-  -DORTHANC_ENABLE_SQLITE=1
-  -DORTHANC_HAS_EMBEDDED_RESOURCES=1
-  -DORTHANC_MAXIMUM_TAG_LENGTH=256
-  -DORTHANC_SANDBOXED=0
-  -DORTHANC_DEFAULT_DICOM_ENCODING=Encoding_Latin1
   
   # Macros for the plugins
   -DHAS_ORTHANC_EXCEPTION=0
@@ -499,33 +270,13 @@
   add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
 endif()
 
-# "CodeLibrary" contains all the third-party dependencies and the
+
+# "CoreLibrary" contains all the third-party dependencies and the
 # content of the "Core" folder, but not OpenSSL, nor DCMTK.
 add_library(CoreLibrary
   STATIC
   ${ORTHANC_CORE_SOURCES}
   ${AUTOGENERATED_SOURCES}
-
-  ${BOOST_SOURCES}
-  ${CURL_SOURCES}
-  ${JSONCPP_SOURCES}
-  ${LIBICONV_SOURCES}
-  ${LIBJPEG_SOURCES}
-  ${LIBP11_SOURCES}
-  ${LIBPNG_SOURCES}
-  ${LUA_SOURCES}
-  ${CIVETWEB_SOURCES}
-  ${MONGOOSE_SOURCES}
-  ${PUGIXML_SOURCES}
-  ${SQLITE_SOURCES}
-  ${ZLIB_SOURCES}
-
-  ${CMAKE_SOURCE_DIR}/Resources/ThirdParty/md5/md5.c
-  ${CMAKE_SOURCE_DIR}/Resources/ThirdParty/base64/base64.cpp
-
-  # This is the minizip distribution to create ZIP files using zlib
-  ${ORTHANC_ROOT}/Resources/ThirdParty/minizip/ioapi.c
-  ${ORTHANC_ROOT}/Resources/ThirdParty/minizip/zip.c
   )  
 
 
--- a/Core/Compression/HierarchicalZipWriter.h	Wed Aug 30 09:29:31 2017 +0200
+++ b/Core/Compression/HierarchicalZipWriter.h	Wed Aug 30 11:26:08 2017 +0200
@@ -39,6 +39,10 @@
 #include <list>
 #include <boost/lexical_cast.hpp>
 
+#if ORTHANC_BUILD_UNIT_TESTS == 1
+#  include <gtest/gtest_prod.h>
+#endif
+
 namespace Orthanc
 {
   class HierarchicalZipWriter
--- a/Core/Compression/ZipWriter.h	Wed Aug 30 09:29:31 2017 +0200
+++ b/Core/Compression/ZipWriter.h	Wed Aug 30 11:26:08 2017 +0200
@@ -37,10 +37,6 @@
 #include <string>
 #include <boost/shared_ptr.hpp>
 
-#if ORTHANC_BUILD_UNIT_TESTS == 1
-#include <gtest/gtest_prod.h>
-#endif
-
 namespace Orthanc
 {
   class ZipWriter
--- a/Core/SQLite/Statement.h	Wed Aug 30 09:29:31 2017 +0200
+++ b/Core/SQLite/Statement.h	Wed Aug 30 11:26:08 2017 +0200
@@ -46,7 +46,7 @@
 #include <stdint.h>
 
 #if ORTHANC_BUILD_UNIT_TESTS == 1
-#include <gtest/gtest_prod.h>
+#  include <gtest/gtest_prod.h>
 #endif
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake	Wed Aug 30 11:26:08 2017 +0200
@@ -0,0 +1,429 @@
+##
+## This is a CMake configuration file that configures the core
+## libraries of Orthanc. This file can be used by external projects so
+## as to gain access to the Orthanc APIs (the most prominent examples
+## are currently "Stone of Orthanc" and "Orthanc for whole-slide
+## imaging plugin").
+##
+
+
+#####################################################################
+## Configuration of the components
+#####################################################################
+
+# Path to the root folder of the Orthanc distribution
+set(ORTHANC_ROOT ${CMAKE_CURRENT_LIST_DIR}/../..)
+
+# Some basic inclusions
+include(CheckIncludeFiles)
+include(CheckIncludeFileCXX)
+include(CheckFunctionExists)
+include(CheckLibraryExists)
+include(FindPythonInterp)
+
+include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
+
+
+#####################################################################
+## List of source files
+#####################################################################
+
+set(ORTHANC_CORE_SOURCES_INTERNAL
+  ${ORTHANC_ROOT}/Core/Cache/MemoryCache.cpp
+  ${ORTHANC_ROOT}/Core/Cache/SharedArchive.cpp
+  ${ORTHANC_ROOT}/Core/ChunkedBuffer.cpp
+  ${ORTHANC_ROOT}/Core/Compression/DeflateBaseCompressor.cpp
+  ${ORTHANC_ROOT}/Core/Compression/GzipCompressor.cpp
+  ${ORTHANC_ROOT}/Core/Compression/HierarchicalZipWriter.cpp
+  ${ORTHANC_ROOT}/Core/Compression/ZipWriter.cpp
+  ${ORTHANC_ROOT}/Core/Compression/ZlibCompressor.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomArray.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomImageInformation.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomInstanceHasher.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomIntegerPixelAccessor.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomMap.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomTag.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomValue.cpp
+  ${ORTHANC_ROOT}/Core/Enumerations.cpp
+  ${ORTHANC_ROOT}/Core/FileStorage/FilesystemStorage.cpp
+  ${ORTHANC_ROOT}/Core/FileStorage/StorageAccessor.cpp
+  ${ORTHANC_ROOT}/Core/Images/Font.cpp
+  ${ORTHANC_ROOT}/Core/Images/FontRegistry.cpp
+  ${ORTHANC_ROOT}/Core/Images/IImageWriter.cpp
+  ${ORTHANC_ROOT}/Core/Images/Image.cpp
+  ${ORTHANC_ROOT}/Core/Images/ImageAccessor.cpp
+  ${ORTHANC_ROOT}/Core/Images/ImageBuffer.cpp
+  ${ORTHANC_ROOT}/Core/Images/ImageProcessing.cpp
+  ${ORTHANC_ROOT}/Core/Logging.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/BagOfTasksProcessor.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/Mutex.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/ReaderWriterLock.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/RunnableWorkersPool.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/Semaphore.cpp
+  ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp
+  ${ORTHANC_ROOT}/Core/SystemToolbox.cpp
+  ${ORTHANC_ROOT}/Core/TemporaryFile.cpp
+  ${ORTHANC_ROOT}/Core/Toolbox.cpp
+  ${ORTHANC_ROOT}/Core/WebServiceParameters.cpp
+  )
+
+
+#####################################################################
+## Configuration of optional third-party dependencies
+#####################################################################
+
+
+##
+## Embedded database: SQLite
+##
+
+if (ENABLE_SQLITE)
+  include(${CMAKE_CURRENT_LIST_DIR}/SQLiteConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_SQLITE=1)
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/SQLite/Connection.cpp
+    ${ORTHANC_ROOT}/Core/SQLite/FunctionContext.cpp
+    ${ORTHANC_ROOT}/Core/SQLite/Statement.cpp
+    ${ORTHANC_ROOT}/Core/SQLite/StatementId.cpp
+    ${ORTHANC_ROOT}/Core/SQLite/StatementReference.cpp
+    ${ORTHANC_ROOT}/Core/SQLite/Transaction.cpp
+    )
+else()
+  unset(USE_SYSTEM_SQLITE CACHE)
+  add_definitions(-DORTHANC_ENABLE_SQLITE=0)
+endif()
+
+
+##
+## Cryptography: OpenSSL and libp11
+## Must be above "ENABLE_WEB_CLIENT" and "ENABLE_WEB_SERVER"
+##
+
+if (ENABLE_CRYPTO_OPTIONS)
+  if (ENABLE_SSL)
+    include(${CMAKE_CURRENT_LIST_DIR}/OpenSslConfiguration.cmake)
+    add_definitions(-DORTHANC_ENABLE_SSL=1)
+  else()
+    unset(USE_SYSTEM_OPENSSL CACHE)
+    add_definitions(-DORTHANC_ENABLE_SSL=0)
+  endif()
+
+  if (ENABLE_PKCS11)
+    if (ENABLE_SSL)
+      include(${CMAKE_CURRENT_LIST_DIR}/LibP11Configuration.cmake)
+
+      add_definitions(-DORTHANC_ENABLE_PKCS11=1)
+      list(APPEND ORTHANC_CORE_SOURCES
+        ${ORTHANC_ROOT}/Core/Pkcs11.cpp
+        )
+    else()
+      message(FATAL_ERROR "OpenSSL is required to enable PKCS#11 support")
+    endif()
+  else()
+    add_definitions(-DORTHANC_ENABLE_PKCS11=0)  
+  endif()
+
+else() # ENABLE_CRYPTO_OPTIONS == OFF
+  unset(ENABLE_SSL CACHE)
+  unset(ENABLE_PKCS11 CACHE)
+  unset(USE_SYSTEM_OPENSSL CACHE)
+  unset(USE_SYSTEM_LIBP11 CACHE)
+  add_definitions(
+    -DORTHANC_ENABLE_SSL=0
+    -DORTHANC_ENABLE_PKCS11=0
+    )
+endif()
+
+
+##
+## HTTP client: libcurl
+##
+
+if (ENABLE_WEB_CLIENT)
+  include(${CMAKE_CURRENT_LIST_DIR}/LibCurlConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_CURL=1)
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/HttpClient.cpp
+    )
+else()
+  unset(USE_SYSTEM_CURL CACHE)
+  add_definitions(-DORTHANC_ENABLE_CURL=0)
+endif()
+
+
+##
+## HTTP server: Mongoose 3.8 or Civetweb
+##
+
+if (ENABLE_WEB_SERVER)
+  if (ENABLE_CIVETWEB)
+    include(${CMAKE_CURRENT_LIST_DIR}/CivetwebConfiguration.cmake)
+    add_definitions(
+      -DORTHANC_ENABLE_CIVETWEB=1
+      -DORTHANC_ENABLE_MONGOOSE=0
+      )
+  else()
+    include(${CMAKE_CURRENT_LIST_DIR}/MongooseConfiguration.cmake)
+    add_definitions(
+      -DORTHANC_ENABLE_CIVETWEB=0
+      -DORTHANC_ENABLE_MONGOOSE=1
+      )
+  endif()
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/HttpServer/BufferHttpSender.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/FilesystemHttpHandler.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/FilesystemHttpSender.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/HttpContentNegociation.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/HttpFileSender.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/HttpOutput.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/HttpStreamTranscoder.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/HttpToolbox.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/MongooseServer.cpp
+    ${ORTHANC_ROOT}/Core/HttpServer/StringHttpOutput.cpp
+    ${ORTHANC_ROOT}/Core/RestApi/RestApi.cpp
+    ${ORTHANC_ROOT}/Core/RestApi/RestApiCall.cpp
+    ${ORTHANC_ROOT}/Core/RestApi/RestApiGetCall.cpp
+    ${ORTHANC_ROOT}/Core/RestApi/RestApiHierarchy.cpp
+    ${ORTHANC_ROOT}/Core/RestApi/RestApiOutput.cpp
+    ${ORTHANC_ROOT}/Core/RestApi/RestApiPath.cpp
+    )
+  
+else()
+  unset(ENABLE_CIVETWEB CACHE)
+  unset(USE_SYSTEM_CIVETWEB CACHE)
+  unset(USE_SYSTEM_MONGOOSE CACHE)
+  add_definitions(
+    -DORTHANC_ENABLE_CIVETWEB=0
+    -DORTHANC_ENABLE_MONGOOSE=0
+    )
+endif()
+
+
+##
+## JPEG support: libjpeg
+##
+
+if (ENABLE_JPEG)
+  include(${CMAKE_CURRENT_LIST_DIR}/LibJpegConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_JPEG=1)
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/Images/JpegErrorManager.cpp
+    ${ORTHANC_ROOT}/Core/Images/JpegReader.cpp
+    ${ORTHANC_ROOT}/Core/Images/JpegWriter.cpp
+    )
+
+else()
+  unset(USE_SYSTEM_LIBJPEG CACHE)
+  add_definitions(-DORTHANC_ENABLE_JPEG=0)
+endif()
+
+
+##
+## PNG support: libpng (in conjunction with zlib)
+##
+
+if (ENABLE_PNG)
+  include(${CMAKE_CURRENT_LIST_DIR}/LibPngConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_PNG=1)
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/Images/PngReader.cpp
+    ${ORTHANC_ROOT}/Core/Images/PngWriter.cpp
+    )
+  
+else()
+  unset(USE_SYSTEM_LIBPNG CACHE)
+  add_definitions(-DORTHANC_ENABLE_PNG=0)
+endif()
+
+
+##
+## Lua support
+##
+
+if (ENABLE_LUA)
+  include(${CMAKE_CURRENT_LIST_DIR}/LuaConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_LUA=1)
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/Lua/LuaContext.cpp
+    ${ORTHANC_ROOT}/Core/Lua/LuaFunctionCall.cpp
+    )
+else()
+  unset(USE_SYSTEM_LUA CACHE)
+  add_definitions(-DORTHANC_ENABLE_LUA=0)
+endif()
+
+
+##
+## XML support: pugixml
+##
+
+if (ENABLE_PUGIXML)
+  include(${CMAKE_CURRENT_LIST_DIR}/PugixmlConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_PUGIXML=1)
+else()
+  unset(USE_SYSTEM_PUGIXML CACHE)
+  add_definitions(-DORTHANC_ENABLE_PUGIXML=0)
+endif()
+
+
+##
+## Locale support: libiconv
+##
+
+if (ENABLE_LOCALE)
+  include(${CMAKE_CURRENT_LIST_DIR}/LibIconvConfiguration.cmake)
+  add_definitions(-DORTHANC_ENABLE_LOCALE=1)
+else()
+  unset(USE_SYSTEM_LIBICONV CACHE)
+  add_definitions(-DORTHANC_ENABLE_LOCALE=0)
+endif()
+
+
+#####################################################################
+## Inclusion of mandatory third-party dependencies
+#####################################################################
+
+include(${CMAKE_CURRENT_LIST_DIR}/JsonCppConfiguration.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/ZlibConfiguration.cmake)
+
+# We put Boost as the last dependency, as it is the heaviest to
+# configure, which allows to quickly spot problems when configuring
+# static builds in other dependencies
+include(${CMAKE_CURRENT_LIST_DIR}/BoostConfiguration.cmake)
+
+
+#####################################################################
+## Optional configuration of DCMTK
+#####################################################################
+
+if (ENABLE_DCMTK)
+  if (NOT ENABLE_LOCALE)
+    message(FATAL_ERROR "Support for locales must be enabled if enabling DICOM support")
+  endif()
+
+  include(${CMAKE_CURRENT_LIST_DIR}/DcmtkConfiguration.cmake)
+
+  add_definitions(-DORTHANC_ENABLE_DCMTK=1)
+
+  if (ENABLE_DCMTK_JPEG)
+    add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG=1)
+  else()
+    add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG=0)
+  endif()
+
+  if (ENABLE_DCMTK_JPEG_LOSSLESS)
+    add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=1)
+  else()
+    add_definitions(-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=0)
+  endif()
+
+  set(ORTHANC_DICOM_SOURCES
+    ${ORTHANC_ROOT}/Core/DicomParsing/DicomDirWriter.cpp
+    ${ORTHANC_ROOT}/Core/DicomParsing/DicomModification.cpp
+    ${ORTHANC_ROOT}/Core/DicomParsing/FromDcmtkBridge.cpp
+    ${ORTHANC_ROOT}/Core/DicomParsing/ParsedDicomFile.cpp
+    ${ORTHANC_ROOT}/Core/DicomParsing/ToDcmtkBridge.cpp
+
+    ${ORTHANC_ROOT}/Core/DicomParsing/Internals/DicomFrameIndex.cpp
+    ${ORTHANC_ROOT}/Core/DicomParsing/Internals/DicomImageDecoder.cpp
+
+    ${DCMTK_SOURCES}
+    )
+
+  if (ENABLE_DCMTK_NETWORKING)
+    add_definitions(-DORTHANC_ENABLE_DCMTK_NETWORKING=1)
+    list(APPEND ORTHANC_DICOM_SOURCES
+      ${ORTHANC_ROOT}/Core/DicomNetworking/DicomFindAnswers.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/DicomServer.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/DicomUserConnection.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/RemoteModalityParameters.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/ReusableDicomUserConnection.cpp
+
+      ${ORTHANC_ROOT}/Core/DicomNetworking/Internals/CommandDispatcher.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/Internals/FindScp.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/Internals/MoveScp.cpp
+      ${ORTHANC_ROOT}/Core/DicomNetworking/Internals/StoreScp.cpp
+      )
+  else()
+    add_definitions(-DORTHANC_ENABLE_DCMTK_NETWORKING=0)
+  endif()
+  
+else()
+  add_definitions(
+    -DORTHANC_ENABLE_DCMTK=0
+    -DORTHANC_ENABLE_DCMTK_NETWORKING=0
+    )
+  unset(DCMTK_DICTIONARY_DIR CACHE)
+  unset(USE_DCMTK_360 CACHE)
+  unset(USE_DCMTK_362_PRIVATE_DIC CACHE)
+  unset(USE_SYSTEM_DCMTK CACHE)
+  unset(ENABLE_DCMTK_JPEG CACHE)
+  unset(ENABLE_DCMTK_JPEG_LOSSLESS CACHE)
+endif()
+
+
+#####################################################################
+## Configuration of the C/C++ macros
+#####################################################################
+
+add_definitions(
+  -DORTHANC_DATABASE_VERSION=${ORTHANC_DATABASE_VERSION}
+  -DORTHANC_DEFAULT_DICOM_ENCODING=Encoding_Latin1
+  -DORTHANC_ENABLE_BASE64=1
+  -DORTHANC_ENABLE_LOGGING=1
+  -DORTHANC_ENABLE_LOGGING_PLUGIN=0
+  -DORTHANC_ENABLE_MD5=1
+  -DORTHANC_MAXIMUM_TAG_LENGTH=256
+  -DORTHANC_SANDBOXED=0
+  -DORTHANC_VERSION="${ORTHANC_VERSION}"
+  )
+
+
+if (HAS_EMBEDDED_RESOURCES)
+  add_definitions(-DORTHANC_HAS_EMBEDDED_RESOURCES=1)
+
+  list(APPEND ORTHANC_CORE_SOURCES_INTERNAL
+    ${ORTHANC_ROOT}/Core/HttpServer/EmbeddedResourceHttpHandler.cpp
+    )
+else()
+  add_definitions(-DORTHANC_HAS_EMBEDDED_RESOURCES=0)
+endif()
+
+
+#####################################################################
+## Gathering of all the source code
+#####################################################################
+
+set(ORTHANC_CORE_SOURCES
+  ${ORTHANC_CORE_SOURCES_INTERNAL}
+
+  ${BOOST_SOURCES}
+  ${CIVETWEB_SOURCES}
+  ${CURL_SOURCES}
+  ${JSONCPP_SOURCES}
+  ${LIBICONV_SOURCES}
+  ${LIBJPEG_SOURCES}
+  ${LIBP11_SOURCES}
+  ${LIBPNG_SOURCES}
+  ${LUA_SOURCES}
+  ${MONGOOSE_SOURCES}
+  ${OPENSSL_SOURCES}
+  ${PUGIXML_SOURCES}
+  ${SQLITE_SOURCES}
+  ${ZLIB_SOURCES}
+
+  ${ORTHANC_ROOT}/Resources/ThirdParty/md5/md5.c
+  ${ORTHANC_ROOT}/Resources/ThirdParty/base64/base64.cpp
+
+  # This is the minizip distribution to create ZIP files using zlib
+  ${ORTHANC_ROOT}/Resources/ThirdParty/minizip/ioapi.c
+  ${ORTHANC_ROOT}/Resources/ThirdParty/minizip/zip.c
+  )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/OrthancFrameworkParameters.cmake	Wed Aug 30 11:26:08 2017 +0200
@@ -0,0 +1,88 @@
+#####################################################################
+## Versioning information
+#####################################################################
+
+# Version of the build, should always be "mainline" except in release branches
+set(ORTHANC_VERSION "mainline")
+
+# Version of the database schema. History:
+#   * Orthanc 0.1.0 -> Orthanc 0.3.0 = no versioning
+#   * Orthanc 0.3.1                  = version 2
+#   * Orthanc 0.4.0 -> Orthanc 0.7.2 = version 3
+#   * Orthanc 0.7.3 -> Orthanc 0.8.4 = version 4
+#   * Orthanc 0.8.5 -> Orthanc 0.9.4 = version 5
+#   * Orthanc 0.9.5 -> mainline      = version 6
+set(ORTHANC_DATABASE_VERSION 6)
+
+
+#####################################################################
+## CMake parameters tunable by the user
+#####################################################################
+
+# Support of static compilation
+set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
+set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
+
+# Generic parameters of the build
+set(ENABLE_CIVETWEB OFF CACHE BOOL "Use Civetweb instead of Mongoose (experimental)")
+set(ENABLE_PKCS11 OFF CACHE BOOL "Enable PKCS#11 for HTTPS client authentication using hardware security modules and smart cards")
+set(ENABLE_PROFILING OFF CACHE BOOL "Whether to enable the generation of profiling information with gprof")
+set(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
+
+# Parameters to fine-tune linking against system libraries
+set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
+set(USE_SYSTEM_CIVETWEB ON CACHE BOOL "Use the system version of Civetweb (experimental)")
+set(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
+set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
+set(USE_SYSTEM_LIBICONV ON CACHE BOOL "Use the system version of libiconv")
+set(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
+set(USE_SYSTEM_LIBP11 OFF CACHE BOOL "Use the system version of libp11 (PKCS#11 wrapper library)")
+set(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
+set(USE_SYSTEM_LUA ON CACHE BOOL "Use the system version of Lua")
+set(USE_SYSTEM_MONGOOSE ON CACHE BOOL "Use the system version of Mongoose")
+set(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
+set(USE_SYSTEM_PUGIXML ON CACHE BOOL "Use the system version of Pugixml")
+set(USE_SYSTEM_SQLITE ON CACHE BOOL "Use the system version of SQLite")
+set(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
+
+# Parameters specific to DCMTK
+set(DCMTK_DICTIONARY_DIR "" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (only when using system version of DCMTK)") 
+set(USE_DCMTK_360 OFF CACHE BOOL "Use older DCMTK version 3.6.0 in static builds (instead of default 3.6.2)")
+set(USE_DCMTK_362_PRIVATE_DIC ON CACHE BOOL "Use the dictionary of private tags from DCMTK 3.6.2 if using DCMTK 3.6.0")
+set(USE_SYSTEM_DCMTK ON CACHE BOOL "Use the system version of DCMTK")
+set(ENABLE_DCMTK_JPEG ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression")
+set(ENABLE_DCMTK_JPEG_LOSSLESS ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression")
+
+# Advanced and distribution-specific parameters
+set(SYSTEM_MONGOOSE_USE_CALLBACKS ON CACHE BOOL "The system version of Mongoose uses callbacks (version >= 3.7)")
+set(USE_BOOST_ICONV ON CACHE BOOL "Use iconv instead of wconv (Windows only)")
+set(USE_PUGIXML ON CACHE BOOL "Use the Pugixml parser (turn off only for debug)")
+
+mark_as_advanced(SYSTEM_MONGOOSE_USE_CALLBACKS)
+mark_as_advanced(USE_BOOST_ICONV)
+mark_as_advanced(USE_PUGIXML)
+
+
+#####################################################################
+## Internal CMake parameters to enable the optional subcomponents of
+## the Orthanc framework
+#####################################################################
+
+# These options must be set to "ON" if compiling Orthanc, but might be
+# set to "OFF" by third-party projects if their associated features
+# are not required
+
+set(ENABLE_CRYPTO_OPTIONS OFF CACHE INTERNAL "Show options related to cryptography")
+set(ENABLE_JPEG OFF CACHE INTERNAL "Enable support of JPEG")
+set(ENABLE_LOCALE OFF CACHE INTERNAL "Enable support for locales (notably in Boost)")
+set(ENABLE_LUA OFF CACHE INTERNAL "Enable support of Lua scripting")
+set(ENABLE_PNG OFF CACHE INTERNAL "Enable support of PNG")
+set(ENABLE_PUGIXML OFF CACHE INTERNAL "Enable support of XML through Pugixml")
+set(ENABLE_SQLITE OFF CACHE INTERNAL "Enable support of SQLite databases")
+set(ENABLE_WEB_CLIENT OFF CACHE INTERNAL "Enable Web client")
+set(ENABLE_WEB_SERVER OFF CACHE INTERNAL "Enable embedded Web server")
+set(ENABLE_DCMTK OFF CACHE INTERNAL "Enable DCMTK")
+set(ENABLE_DCMTK_NETWORKING OFF CACHE INTERNAL "Enable DICOM networking in DCMTK")
+
+set(HAS_EMBEDDED_RESOURCES OFF CACHE INTERNAL
+  "Whether resources are auto-generated using EmbedResources.py")
--- a/Resources/Samples/Tools/CMakeLists.txt	Wed Aug 30 09:29:31 2017 +0200
+++ b/Resources/Samples/Tools/CMakeLists.txt	Wed Aug 30 11:26:08 2017 +0200
@@ -8,32 +8,18 @@
   link_libraries(pthread dl)
 endif()
 
+include(${CMAKE_SOURCE_DIR}/../../CMake/OrthancFrameworkParameters.cmake)
+
 set(STATIC_BUILD ON)
 set(ALLOW_DOWNLOADS ON)
 
-set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../..)
-
-include(CheckIncludeFiles)
-include(CheckIncludeFileCXX)
-include(CheckLibraryExists)
-include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
-include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
-include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
-include(${ORTHANC_ROOT}/Resources/CMake/ZlibConfiguration.cmake)
-include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
-
-add_definitions(
-  -DORTHANC_ENABLE_BASE64=0
-  -DORTHANC_ENABLE_MD5=0
-  -DORTHANC_ENABLE_PUGIXML=0
-  -DORTHANC_ENABLE_LOGGING=0
-  -DORTHANC_SANDBOXED=0
-  )
+include(${CMAKE_SOURCE_DIR}/../../CMake/OrthancFrameworkConfiguration.cmake)
 
 add_library(CommonLibraries
   ${BOOST_SOURCES}
   ${JSONCPP_SOURCES}
   ${ORTHANC_ROOT}/Core/Enumerations.cpp
+  ${ORTHANC_ROOT}/Core/Logging.cpp
   ${ORTHANC_ROOT}/Core/SystemToolbox.cpp
   ${ORTHANC_ROOT}/Core/Toolbox.cpp
   ${ORTHANC_ROOT}/Resources/ThirdParty/md5/md5.c