changeset 2450:ade8b4ddd8a6

Static linking against libuuid
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jan 2018 11:02:59 +0100
parents e779c11c8eb2
children a4032b162502
files NEWS Resources/CMake/CivetwebConfiguration.cmake Resources/CMake/Compiler.cmake Resources/CMake/GoogleTestConfiguration.cmake Resources/CMake/LibCurlConfiguration.cmake Resources/CMake/OrthancFrameworkConfiguration.cmake Resources/CMake/OrthancFrameworkParameters.cmake Resources/CMake/UuidConfiguration.cmake Resources/Patches/curl-7.57.0-cmake.patch
diffstat 9 files changed, 304 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jan 03 08:41:14 2018 +0100
+++ b/NEWS	Wed Jan 03 11:02:59 2018 +0100
@@ -15,6 +15,7 @@
 * Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
 * Upgrade to curl 7.57.0 for static and Windows builds
 * Support of Linux Standard Base
+* Static linking against libuuid (from e2fsprogs)
 
 
 Version 1.3.1 (2017-11-29)
--- a/Resources/CMake/CivetwebConfiguration.cmake	Wed Jan 03 08:41:14 2018 +0100
+++ b/Resources/CMake/CivetwebConfiguration.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -39,8 +39,6 @@
   source_group(ThirdParty\\Civetweb REGULAR_EXPRESSION ${CIVETWEB_SOURCES_DIR}/.*)
 
 else()
-  include(CMakePushCheckState)
-  
   CHECK_INCLUDE_FILE_CXX(civetweb.h HAVE_CIVETWEB_H)
   if (NOT HAVE_CIVETWEB_H)
     message(FATAL_ERROR "Please install the libcivetweb-devel package")
--- a/Resources/CMake/Compiler.cmake	Wed Jan 03 08:41:14 2018 +0100
+++ b/Resources/CMake/Compiler.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -88,7 +88,7 @@
   # Remove the "-rdynamic" option
   # http://www.mail-archive.com/cmake@cmake.org/msg08837.html
   set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
-  link_libraries(uuid pthread)
+  link_libraries(pthread)
 
   if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
     link_libraries(rt)
@@ -118,11 +118,6 @@
       )
   endif()
 
-  CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H)
-  if (NOT HAVE_UUID_H)
-    message(FATAL_ERROR "Please install the uuid-dev package (or e2fsprogs if OpenBSD)")
-  endif()
-
 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
   if (MSVC)
     message("MSVC compiler version = " ${MSVC_VERSION} "\n")
@@ -175,11 +170,6 @@
     )
   link_libraries(iconv)
 
-  CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H)
-  if (NOT HAVE_UUID_H)
-    message(FATAL_ERROR "Please install the uuid-dev package")
-  endif()
-
 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
   message("Building using Emscripten (for WebAssembly or asm.js targets)")
 
--- a/Resources/CMake/GoogleTestConfiguration.cmake	Wed Jan 03 08:41:14 2018 +0100
+++ b/Resources/CMake/GoogleTestConfiguration.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -47,7 +47,11 @@
   if (MSVC) # VS2012 does not support tuples correctly yet
     add_definitions(/D _VARIADIC_MAX=10)
   endif()
-
+  
+  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+    add_definitions(-DGTEST_HAS_CLONE=0)
+  endif()
+  
   source_group(ThirdParty\\GoogleTest REGULAR_EXPRESSION ${GOOGLE_TEST_SOURCES_DIR}/.*)
 
 else()
--- a/Resources/CMake/LibCurlConfiguration.cmake	Wed Jan 03 08:41:14 2018 +0100
+++ b/Resources/CMake/LibCurlConfiguration.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -1,21 +1,29 @@
-macro(CHECK_CURL_TYPE_EXISTS TYPE VARIABLE)
-  check_type_size("${TYPE}" SIZEOF_TYPE) # LANGUAGE CXX)
-  
-  if (SIZEOF_TYPE)
-    set(${VARIABLE} ON)
-  else()
-    set(${VARIABLE} OFF)
-  endif()
-endmacro()
-
-
 if (STATIC_BUILD OR NOT USE_SYSTEM_CURL)
   SET(CURL_SOURCES_DIR ${CMAKE_BINARY_DIR}/curl-7.57.0)
   SET(CURL_URL "http://www.orthanc-server.com/downloads/third-party/curl-7.57.0.tar.gz")
   SET(CURL_MD5 "c7aab73aaf5e883ca1d7518f93649dc2")
 
+  if (IS_DIRECTORY "${CURL_SOURCES_DIR}")
+    set(FirstRun OFF)
+  else()
+    set(FirstRun ON)
+  endif()
+  
   DownloadPackage(${CURL_MD5} ${CURL_URL} "${CURL_SOURCES_DIR}")
 
+  if (FirstRun)
+    execute_process(
+      COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+      ${ORTHANC_ROOT}/Resources/Patches/curl-7.57.0-cmake.patch
+      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+      RESULT_VARIABLE Failure
+      )
+    
+    if (Failure)
+      message(FATAL_ERROR "Error while patching a file")
+    endif()
+  endif()
+  
   include_directories(
     ${CURL_SOURCES_DIR}/include
     )
@@ -83,28 +91,84 @@
       SOURCE ${CURL_SOURCES}
       PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H=1;OS=\"${TMP_OS}\""
       )
-
-    include(CheckTypeSize)
-    include(CheckIncludeFile)
-    include(CheckSymbolExists)
+   
+    include(${CURL_SOURCES_DIR}/CMake/Macros.cmake)
 
-    CHECK_INCLUDE_FILE(time.h HAVE_TIME_H)
-    CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
-    CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
-    CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_IN_H)
-    CHECK_INCLUDE_FILE(netdb.h HAVE_NETDB_H)
-    CHECK_INCLUDE_FILE(fcntl.h HAVE_FCNTL_H)
-    CHECK_INCLUDE_FILE(errno.h HAVE_ERRNO_H)
-    CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
-    CHECK_INCLUDE_FILE(stdio.h HAVE_STDIO_H)
-    CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
-
-    CHECK_CURL_TYPE_EXISTS("long long" HAVE_LONGLONG)
-    
-    check_symbol_exists(socket "sys/socket.h" HAVE_SOCKET)
-    check_symbol_exists(recv "sys/socket.h" HAVE_RECV)
-    check_symbol_exists(send "sys/socket.h" HAVE_SEND)
-    check_symbol_exists(select "sys/select.h" HAVE_SELECT)
+    check_include_file_concat("alloca.h"         HAVE_ALLOCA_H)
+    check_include_file_concat("arpa/inet.h"      HAVE_ARPA_INET_H)
+    check_include_file_concat("arpa/tftp.h"      HAVE_ARPA_TFTP_H)
+    check_include_file_concat("assert.h"         HAVE_ASSERT_H)
+    check_include_file_concat("crypto.h"         HAVE_CRYPTO_H)
+    check_include_file_concat("des.h"            HAVE_DES_H)
+    check_include_file_concat("dlfcn.h"          HAVE_DLFCN_H)
+    check_include_file_concat("err.h"            HAVE_ERR_H)
+    check_include_file_concat("errno.h"          HAVE_ERRNO_H)
+    check_include_file_concat("fcntl.h"          HAVE_FCNTL_H)
+    check_include_file_concat("idn2.h"           HAVE_IDN2_H)
+    check_include_file_concat("ifaddrs.h"        HAVE_IFADDRS_H)
+    check_include_file_concat("inttypes.h"       HAVE_INTTYPES_H)
+    check_include_file_concat("io.h"             HAVE_IO_H)
+    check_include_file_concat("krb.h"            HAVE_KRB_H)
+    check_include_file_concat("libgen.h"         HAVE_LIBGEN_H)
+    check_include_file_concat("limits.h"         HAVE_LIMITS_H)
+    check_include_file_concat("locale.h"         HAVE_LOCALE_H)
+    check_include_file_concat("malloc.h"         HAVE_MALLOC_H)
+    check_include_file_concat("memory.h"         HAVE_MEMORY_H)
+    check_include_file_concat("net/if.h"         HAVE_NET_IF_H)
+    check_include_file_concat("netdb.h"          HAVE_NETDB_H)
+    check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H)
+    check_include_file_concat("netinet/in.h"     HAVE_NETINET_IN_H)
+    check_include_file_concat("netinet/tcp.h"    HAVE_NETINET_TCP_H)
+    check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
+    check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
+    check_include_file_concat("openssl/err.h"    HAVE_OPENSSL_ERR_H)
+    check_include_file_concat("openssl/pem.h"    HAVE_OPENSSL_PEM_H)
+    check_include_file_concat("openssl/rand.h"   HAVE_OPENSSL_RAND_H)
+    check_include_file_concat("openssl/rsa.h"    HAVE_OPENSSL_RSA_H)
+    check_include_file_concat("openssl/ssl.h"    HAVE_OPENSSL_SSL_H)
+    check_include_file_concat("openssl/x509.h"   HAVE_OPENSSL_X509_H)
+    check_include_file_concat("pem.h"            HAVE_PEM_H)
+    check_include_file_concat("poll.h"           HAVE_POLL_H)
+    check_include_file_concat("process.h"        HAVE_PROCESS_H)
+    check_include_file_concat("pwd.h"            HAVE_PWD_H)
+    check_include_file_concat("rsa.h"            HAVE_RSA_H)
+    check_include_file_concat("setjmp.h"         HAVE_SETJMP_H)
+    check_include_file_concat("sgtty.h"          HAVE_SGTTY_H)
+    check_include_file_concat("signal.h"         HAVE_SIGNAL_H)
+    check_include_file_concat("sockio.h"         HAVE_SOCKIO_H)
+    check_include_file_concat("ssl.h"            HAVE_SSL_H)
+    check_include_file_concat("stdbool.h"        HAVE_STDBOOL_H)
+    check_include_file_concat("stddef.h"         HAVE_STDDEF_H)
+    check_include_file_concat("stdint.h"         HAVE_STDINT_H)
+    check_include_file_concat("stdint.h"         HAVE_STDINT_H)
+    check_include_file_concat("stdio.h"          HAVE_STDIO_H)
+    check_include_file_concat("stdio.h"          HAVE_STDIO_H)
+    check_include_file_concat("stdlib.h"         HAVE_STDLIB_H)
+    check_include_file_concat("string.h"         HAVE_STRING_H)
+    check_include_file_concat("strings.h"        HAVE_STRINGS_H)
+    check_include_file_concat("stropts.h"        HAVE_STROPTS_H)
+    check_include_file_concat("sys/filio.h"      HAVE_SYS_FILIO_H)
+    check_include_file_concat("sys/ioctl.h"      HAVE_SYS_IOCTL_H)
+    check_include_file_concat("sys/param.h"      HAVE_SYS_PARAM_H)
+    check_include_file_concat("sys/poll.h"       HAVE_SYS_POLL_H)
+    check_include_file_concat("sys/resource.h"   HAVE_SYS_RESOURCE_H)
+    check_include_file_concat("sys/select.h"     HAVE_SYS_SELECT_H)
+    check_include_file_concat("sys/socket.h"     HAVE_SYS_SOCKET_H)
+    check_include_file_concat("sys/sockio.h"     HAVE_SYS_SOCKIO_H)
+    check_include_file_concat("sys/stat.h"       HAVE_SYS_STAT_H)
+    check_include_file_concat("sys/time.h"       HAVE_SYS_TIME_H)
+    check_include_file_concat("sys/types.h"      HAVE_SYS_TYPES_H)
+    check_include_file_concat("sys/uio.h"        HAVE_SYS_UIO_H)
+    check_include_file_concat("sys/un.h"         HAVE_SYS_UN_H)
+    check_include_file_concat("sys/utime.h"      HAVE_SYS_UTIME_H)
+    check_include_file_concat("sys/utsname.h"    HAVE_SYS_UTSNAME_H)
+    check_include_file_concat("sys/xattr.h"      HAVE_SYS_XATTR_H)
+    check_include_file_concat("termio.h"         HAVE_TERMIO_H)
+    check_include_file_concat("termios.h"        HAVE_TERMIOS_H)
+    check_include_file_concat("time.h"           HAVE_TIME_H)
+    check_include_file_concat("unistd.h"         HAVE_UNISTD_H)
+    check_include_file_concat("utime.h"          HAVE_UTIME_H)
+    check_include_file_concat("x509.h"           HAVE_X509_H)
 
     check_type_size("size_t"  SIZEOF_SIZE_T)
     check_type_size("ssize_t"  SIZEOF_SSIZE_T)
@@ -118,13 +182,135 @@
     check_type_size("off_t"  SIZEOF_OFF_T)
     check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
 
+    check_symbol_exists(basename      "${CURL_INCLUDES}" HAVE_BASENAME)
+    check_symbol_exists(socket        "${CURL_INCLUDES}" HAVE_SOCKET)
+    # poll on macOS is unreliable, it first did not exist, then was broken until
+    # fixed in 10.9 only to break again in 10.12.
+    if(NOT APPLE)
+      check_symbol_exists(poll        "${CURL_INCLUDES}" HAVE_POLL)
+    endif()
+    check_symbol_exists(select        "${CURL_INCLUDES}" HAVE_SELECT)
+    check_symbol_exists(strdup        "${CURL_INCLUDES}" HAVE_STRDUP)
+    check_symbol_exists(strstr        "${CURL_INCLUDES}" HAVE_STRSTR)
+    check_symbol_exists(strtok_r      "${CURL_INCLUDES}" HAVE_STRTOK_R)
+    check_symbol_exists(strftime      "${CURL_INCLUDES}" HAVE_STRFTIME)
+    check_symbol_exists(uname         "${CURL_INCLUDES}" HAVE_UNAME)
+    check_symbol_exists(strcasecmp    "${CURL_INCLUDES}" HAVE_STRCASECMP)
+    check_symbol_exists(stricmp       "${CURL_INCLUDES}" HAVE_STRICMP)
+    check_symbol_exists(strcmpi       "${CURL_INCLUDES}" HAVE_STRCMPI)
+    check_symbol_exists(strncmpi      "${CURL_INCLUDES}" HAVE_STRNCMPI)
+    check_symbol_exists(alarm         "${CURL_INCLUDES}" HAVE_ALARM)
+    if(NOT HAVE_STRNCMPI)
+      set(HAVE_STRCMPI)
+    endif(NOT HAVE_STRNCMPI)
+
+    check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
+    check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
+    check_symbol_exists(gettimeofday  "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
+    check_symbol_exists(inet_addr     "${CURL_INCLUDES}" HAVE_INET_ADDR)
+    check_symbol_exists(inet_ntoa     "${CURL_INCLUDES}" HAVE_INET_NTOA)
+    check_symbol_exists(inet_ntoa_r   "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
+    check_symbol_exists(tcsetattr     "${CURL_INCLUDES}" HAVE_TCSETATTR)
+    check_symbol_exists(tcgetattr     "${CURL_INCLUDES}" HAVE_TCGETATTR)
+    check_symbol_exists(perror        "${CURL_INCLUDES}" HAVE_PERROR)
+    check_symbol_exists(closesocket   "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
+    check_symbol_exists(setvbuf       "${CURL_INCLUDES}" HAVE_SETVBUF)
+    check_symbol_exists(sigsetjmp     "${CURL_INCLUDES}" HAVE_SIGSETJMP)
+    check_symbol_exists(getpass_r     "${CURL_INCLUDES}" HAVE_GETPASS_R)
+    check_symbol_exists(strlcat       "${CURL_INCLUDES}" HAVE_STRLCAT)
+    check_symbol_exists(getpwuid      "${CURL_INCLUDES}" HAVE_GETPWUID)
+    check_symbol_exists(geteuid       "${CURL_INCLUDES}" HAVE_GETEUID)
+    check_symbol_exists(utime         "${CURL_INCLUDES}" HAVE_UTIME)
+    check_symbol_exists(gmtime_r      "${CURL_INCLUDES}" HAVE_GMTIME_R)
+    check_symbol_exists(localtime_r   "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
+
+    check_symbol_exists(gethostbyname   "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
+    check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
+
+    check_symbol_exists(signal        "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
+    check_symbol_exists(SIGALRM       "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
+    if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
+      set(HAVE_SIGNAL 1)
+    endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
+    check_symbol_exists(uname          "${CURL_INCLUDES}" HAVE_UNAME)
+    check_symbol_exists(strtoll        "${CURL_INCLUDES}" HAVE_STRTOLL)
+    check_symbol_exists(_strtoi64      "${CURL_INCLUDES}" HAVE__STRTOI64)
+    check_symbol_exists(strerror_r     "${CURL_INCLUDES}" HAVE_STRERROR_R)
+    check_symbol_exists(siginterrupt   "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
+    check_symbol_exists(perror         "${CURL_INCLUDES}" HAVE_PERROR)
+    check_symbol_exists(fork           "${CURL_INCLUDES}" HAVE_FORK)
+    check_symbol_exists(getaddrinfo    "${CURL_INCLUDES}" HAVE_GETADDRINFO)
+    check_symbol_exists(freeaddrinfo   "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
+    check_symbol_exists(freeifaddrs    "${CURL_INCLUDES}" HAVE_FREEIFADDRS)
+    check_symbol_exists(pipe           "${CURL_INCLUDES}" HAVE_PIPE)
+    check_symbol_exists(ftruncate      "${CURL_INCLUDES}" HAVE_FTRUNCATE)
+    check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
+    check_symbol_exists(getrlimit      "${CURL_INCLUDES}" HAVE_GETRLIMIT)
+    check_symbol_exists(setlocale      "${CURL_INCLUDES}" HAVE_SETLOCALE)
+    check_symbol_exists(setmode        "${CURL_INCLUDES}" HAVE_SETMODE)
+    check_symbol_exists(setrlimit      "${CURL_INCLUDES}" HAVE_SETRLIMIT)
+    check_symbol_exists(fcntl          "${CURL_INCLUDES}" HAVE_FCNTL)
+    check_symbol_exists(ioctl          "${CURL_INCLUDES}" HAVE_IOCTL)
+    check_symbol_exists(setsockopt     "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
+
+    if(HAVE_SIZEOF_LONG_LONG)
+      set(HAVE_LONGLONG 1)
+      set(HAVE_LL 1)
+    endif(HAVE_SIZEOF_LONG_LONG)
+
+    check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
+    check_function_exists(gethostname HAVE_GETHOSTNAME)
+
+    check_include_file_concat("pthread.h" HAVE_PTHREAD_H)
+    check_symbol_exists(recv "sys/socket.h" HAVE_RECV)
+    check_symbol_exists(send "sys/socket.h" HAVE_SEND)
+
+    check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS)
+
     set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCES_DIR}/include")
     set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h")
     check_type_size("curl_off_t"  SIZEOF_CURL_OFF_T)
 
+    add_definitions(-DHAVE_GLIBC_STRERROR_R=1)
+
     include(${CURL_SOURCES_DIR}/CMake/OtherTests.cmake)
-    set(HAVE_STRUCT_TIMEVAL ON)  # TODO WHY IS THIS NECESSARY?
-    set(HAVE_FCNTL_O_NONBLOCK ON)  # TODO WHY IS THIS NECESSARY?
+
+    foreach(CURL_TEST
+        HAVE_FCNTL_O_NONBLOCK
+        HAVE_IOCTLSOCKET
+        HAVE_IOCTLSOCKET_CAMEL
+        HAVE_IOCTLSOCKET_CAMEL_FIONBIO
+        HAVE_IOCTLSOCKET_FIONBIO
+        HAVE_IOCTL_FIONBIO
+        HAVE_IOCTL_SIOCGIFADDR
+        HAVE_SETSOCKOPT_SO_NONBLOCK
+        HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
+        TIME_WITH_SYS_TIME
+        HAVE_O_NONBLOCK
+        HAVE_GETHOSTBYADDR_R_5
+        HAVE_GETHOSTBYADDR_R_7
+        HAVE_GETHOSTBYADDR_R_8
+        HAVE_GETHOSTBYADDR_R_5_REENTRANT
+        HAVE_GETHOSTBYADDR_R_7_REENTRANT
+        HAVE_GETHOSTBYADDR_R_8_REENTRANT
+        HAVE_GETHOSTBYNAME_R_3
+        HAVE_GETHOSTBYNAME_R_5
+        HAVE_GETHOSTBYNAME_R_6
+        HAVE_GETHOSTBYNAME_R_3_REENTRANT
+        HAVE_GETHOSTBYNAME_R_5_REENTRANT
+        HAVE_GETHOSTBYNAME_R_6_REENTRANT
+        HAVE_SOCKLEN_T
+        HAVE_IN_ADDR_T
+        HAVE_BOOL_T
+        STDC_HEADERS
+        RETSIGTYPE_TEST
+        HAVE_INET_NTOA_R_DECL
+        HAVE_INET_NTOA_R_DECL_REENTRANT
+        HAVE_GETADDRINFO
+        HAVE_FILE_OFFSET_BITS
+        )
+      curl_internal_test(${CURL_TEST})
+    endforeach(CURL_TEST)
 
     configure_file(
       ${CURL_SOURCES_DIR}/lib/curl_config.h.cmake
--- a/Resources/CMake/OrthancFrameworkConfiguration.cmake	Wed Jan 03 08:41:14 2018 +0100
+++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -15,12 +15,17 @@
 set(ORTHANC_ROOT ${CMAKE_CURRENT_LIST_DIR}/../..)
 
 # Some basic inclusions
-include(CheckIncludeFiles)
-include(CheckIncludeFileCXX)
+include(CMakePushCheckState)
 include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
+include(CheckIncludeFiles)
 include(CheckLibraryExists)
+include(CheckStructHasMember)
+include(CheckSymbolExists)
+include(CheckTypeSize)
 include(FindPythonInterp)
-
+  
 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
@@ -328,6 +333,7 @@
 #####################################################################
 
 include(${CMAKE_CURRENT_LIST_DIR}/JsonCppConfiguration.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/UuidConfiguration.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/ZlibConfiguration.cmake)
 
 # We put Boost as the last dependency, as it is the heaviest to
@@ -473,6 +479,7 @@
   ${BOOST_SOURCES}
   ${CIVETWEB_SOURCES}
   ${CURL_SOURCES}
+  ${E2FSPROGS_SOURCES}
   ${JSONCPP_SOURCES}
   ${LIBICONV_SOURCES}
   ${LIBJPEG_SOURCES}
--- a/Resources/CMake/OrthancFrameworkParameters.cmake	Wed Jan 03 08:41:14 2018 +0100
+++ b/Resources/CMake/OrthancFrameworkParameters.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -50,6 +50,7 @@
 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_UUID ON CACHE BOOL "Use the system version of the uuid library from e2fsprogs")
 set(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
 
 # Parameters specific to DCMTK
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/UuidConfiguration.cmake	Wed Jan 03 11:02:59 2018 +0100
@@ -0,0 +1,54 @@
+if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+
+  if (STATIC_BUILD OR NOT USE_SYSTEM_UUID)
+    SET(E2FSPROGS_SOURCES_DIR ${CMAKE_BINARY_DIR}/e2fsprogs-1.43.8)
+    SET(E2FSPROGS_URL "http://www.orthanc-server.com/downloads/third-party/e2fsprogs-1.43.8.tar.gz")
+    SET(E2FSPROGS_MD5 "670b7a74a8ead5333acf21b9afc92b3c")
+
+    DownloadPackage(${E2FSPROGS_MD5} ${E2FSPROGS_URL} "${E2FSPROGS_SOURCES_DIR}")
+
+    include_directories(
+      ${E2FSPROGS_SOURCES_DIR}/lib
+      )
+
+    set(E2FSPROGS_SOURCES
+      #${E2FSPROGS_SOURCES_DIR}/lib/uuid/tst_uuid.c
+      #${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid_time.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/clear.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/compare.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/copy.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/gen_uuid.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/isnull.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/pack.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/parse.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/unpack.c
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/unparse.c
+      )
+
+    configure_file(
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid.h.in
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid.h
+      )
+    
+    configure_file(
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid_types.h.in
+      ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid_types.h
+      )
+    
+    source_group(ThirdParty\\uuid REGULAR_EXPRESSION ${E2FSPROGS_SOURCES_DIR}/.*)
+
+  else()
+    CHECK_INCLUDE_FILE(uuid/uuid.h HAVE_UUID_H)
+    if (NOT HAVE_UUID_H)
+      message(FATAL_ERROR "Please install uuid-dev, e2fsprogs (OpenBSD) or e2fsprogs-libuuid (FreeBSD)")
+    endif()
+
+    check_library_exists(uuid uuid_generate_random "" HAVE_UUID_LIB)
+    if (NOT HAVE_UUID_LIB)
+      message(FATAL_ERROR "Unable to find the uuid library")
+    endif()
+    
+    link_libraries(uuid)
+  endif()
+
+endif()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/curl-7.57.0-cmake.patch	Wed Jan 03 11:02:59 2018 +0100
@@ -0,0 +1,12 @@
+diff -urEb curl-7.57.0.orig/CMake/Macros.cmake curl-7.57.0/CMake/Macros.cmake
+--- curl-7.57.0.orig/CMake/Macros.cmake	2017-11-09 23:40:36.000000000 +0100
++++ curl-7.57.0/CMake/Macros.cmake	2018-01-03 10:39:15.589520034 +0100
+@@ -38,7 +38,7 @@
+     message(STATUS "Performing Curl Test ${CURL_TEST}")
+     try_compile(${CURL_TEST}
+       ${CMAKE_BINARY_DIR}
+-      ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
++      ${CURL_SOURCES_DIR}/CMake/CurlTests.c
+       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+       "${CURL_TEST_ADD_LIBRARIES}"
+       OUTPUT_VARIABLE OUTPUT)