changeset 2448:862d943115f9

working on linux standard base
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jan 2018 18:04:11 +0100
parents 878b59270859
children e779c11c8eb2
files Core/Endianness.h NEWS Resources/CMake/BoostConfiguration.cmake Resources/CMake/Compiler.cmake Resources/CMake/DcmtkConfiguration.cmake Resources/CMake/LibCurlConfiguration.cmake Resources/CMake/OpenSslConfiguration.cmake Resources/LinuxStandardBaseToolchain.cmake Resources/Patches/boost-1.65.1-linux-standard-base.patch Resources/Patches/dcmtk-3.6.2-linux-standard-base.patch
diffstat 10 files changed, 213 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Endianness.h	Tue Jan 02 09:35:07 2018 +0100
+++ b/Core/Endianness.h	Tue Jan 02 18:04:11 2018 +0100
@@ -38,7 +38,12 @@
  ** LINUX-LIKE ARCHITECTURES
  ********************************************************************/
 
-#if defined(__linux__) || defined(__EMSCRIPTEN__)
+#if defined(__LSB_VERSION__)
+// Linux Standard Base (LSB) does not come with be16toh, be32toh, and
+// be64toh
+#  define ORTHANC_HAS_BUILTIN_BYTE_SWAP 0
+#  include <endian.h>
+#elif defined(__linux__) || defined(__EMSCRIPTEN__)
 #  define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1
 #  include <endian.h>
 #endif
@@ -155,4 +160,38 @@
           static_cast<uint64_t>(p[7]));
 }
 
+#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
+#  if __BYTE_ORDER == __LITTLE_ENDIAN
+#    define be16toh(x) __orthanc_bswap16(x)
+#    define be32toh(x) __orthanc_bswap32(x)
+#    define be64toh(x) __orthanc_bswap64(x)
+#    define htobe16(x) __orthanc_bswap16(x)
+#    define htobe32(x) __orthanc_bswap32(x)
+#    define htobe64(x) __orthanc_bswap64(x)
+#    define htole16(x) x
+#    define htole32(x) x
+#    define htole64(x) x
+#    define le16toh(x) x
+#    define le32toh(x) x
+#    define le64toh(x) x
+#  elif __BYTE_ORDER == __BIG_ENDIAN
+#    define be16toh(x) x
+#    define be32toh(x) x
+#    define be64toh(x) x
+#    define htobe16(x) x
+#    define htobe32(x) x
+#    define htobe64(x) x
+#    define htole16(x) __orthanc_bswap16(x)
+#    define htole32(x) __orthanc_bswap32(x)
+#    define htole64(x) __orthanc_bswap64(x)
+#    define le16toh(x) __orthanc_bswap16(x)
+#    define le32toh(x) __orthanc_bswap32(x)
+#    define le64toh(x) __orthanc_bswap64(x)
+#  else
+#    error Please support your platform here
+#  endif
+#else
+#  error Please support your platform here
 #endif
+
+#endif
--- a/NEWS	Tue Jan 02 09:35:07 2018 +0100
+++ b/NEWS	Tue Jan 02 18:04:11 2018 +0100
@@ -13,6 +13,8 @@
 -----------
 
 * 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
 
 
 Version 1.3.1 (2017-11-29)
--- a/Resources/CMake/BoostConfiguration.cmake	Tue Jan 02 09:35:07 2018 +0100
+++ b/Resources/CMake/BoostConfiguration.cmake	Tue Jan 02 18:04:11 2018 +0100
@@ -78,7 +78,22 @@
     ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp
     )
 
+  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+    add_definitions(-DBOOST_SYSTEM_USE_STRERROR=1)
+    
+    execute_process(
+      COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+      ${CMAKE_SOURCE_DIR}/Resources/Patches/boost-1.65.1-linux-standard-base.patch
+      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+      RESULT_VARIABLE Failure
+      )
 
+    if (FirstRun AND Failure)
+      message(FATAL_ERROR "Error while patching a file")
+    endif()
+  endif()
+
+  
   ##
   ## Configuration of boost::thread
   ##
@@ -199,13 +214,29 @@
       ${BOOST_SOURCES_DIR}/libs/locale/src/util/locale_data.cpp
       )        
 
-    if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
-        CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
-        CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
-        CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD" OR
-        CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR
-        CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
-        CMAKE_SYSTEM_NAME STREQUAL "NaCl64")
+    if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
+        CMAKE_SYSTEM_VERSION STREQUAL "LinuxStandardBase")
+      list(APPEND BOOST_SOURCES
+        ${BOOST_SOURCES_DIR}/libs/locale/src/std/codecvt.cpp
+        ${BOOST_SOURCES_DIR}/libs/locale/src/std/collate.cpp
+        ${BOOST_SOURCES_DIR}/libs/locale/src/std/converter.cpp
+        ${BOOST_SOURCES_DIR}/libs/locale/src/std/numeric.cpp
+        ${BOOST_SOURCES_DIR}/libs/locale/src/std/std_backend.cpp
+        )
+
+      add_definitions(
+        -DBOOST_LOCALE_WITH_ICONV=1
+        -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
+        -DBOOST_LOCALE_NO_POSIX_BACKEND=1
+        )
+      
+    elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
+            CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
+            CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
+            CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD" OR
+            CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR
+            CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
+            CMAKE_SYSTEM_NAME STREQUAL "NaCl64")
       list(APPEND BOOST_SOURCES
         ${BOOST_SOURCES_DIR}/libs/locale/src/posix/codecvt.cpp
         ${BOOST_SOURCES_DIR}/libs/locale/src/posix/collate.cpp
@@ -220,21 +251,6 @@
         -DBOOST_LOCALE_NO_STD_BACKEND=1
         )
       
-    elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
-      list(APPEND BOOST_SOURCES
-        ${BOOST_SOURCES_DIR}/libs/locale/src/std/codecvt.cpp
-        ${BOOST_SOURCES_DIR}/libs/locale/src/std/collate.cpp
-        ${BOOST_SOURCES_DIR}/libs/locale/src/std/converter.cpp
-        ${BOOST_SOURCES_DIR}/libs/locale/src/std/numeric.cpp
-        ${BOOST_SOURCES_DIR}/libs/locale/src/std/std_backend.cpp
-        )
-
-      add_definitions(
-        -DBOOST_LOCALE_WITH_ICONV=1
-        -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
-        -DBOOST_LOCALE_NO_POSIX_BACKEND=1
-        )
-      
     elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
       list(APPEND BOOST_SOURCES
         ${BOOST_SOURCES_DIR}/libs/locale/src/win32/collate.cpp
--- a/Resources/CMake/Compiler.cmake	Tue Jan 02 09:35:07 2018 +0100
+++ b/Resources/CMake/Compiler.cmake	Tue Jan 02 18:04:11 2018 +0100
@@ -1,6 +1,7 @@
 # This file sets all the compiler-related flags
 
-if (CMAKE_CROSSCOMPILING)
+if (CMAKE_CROSSCOMPILING OR
+    "${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
   # Cross-compilation necessarily implies standalone and static build
   SET(STATIC_BUILD ON)
   SET(STANDALONE_BUILD ON)
@@ -187,13 +188,6 @@
 endif()
 
 
-if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
-  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include")
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive")
-  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}")
-endif()
-
-
 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING)
   if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
     message(WARNING "Enabling profiling on a non-debug build will not produce full information")
--- a/Resources/CMake/DcmtkConfiguration.cmake	Tue Jan 02 09:35:07 2018 +0100
+++ b/Resources/CMake/DcmtkConfiguration.cmake	Tue Jan 02 18:04:11 2018 +0100
@@ -9,8 +9,6 @@
     SET(DCMTK_SOURCES_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.0)
     SET(DCMTK_URL "http://www.orthanc-server.com/downloads/third-party/dcmtk-3.6.0.zip")
     SET(DCMTK_MD5 "219ad631b82031806147e4abbfba4fa4")
-    SET(DCMTK_PATCH_SPEED "${ORTHANC_ROOT}/Resources/Patches/dcmtk-3.6.0-speed.patch")
-    SET(DCMTK_PATCH_MINGW64 "${ORTHANC_ROOT}/Resources/Patches/dcmtk-3.6.0-mingw64.patch")
   else()
     SET(DCMTK_VERSION_NUMBER 362)
     SET(DCMTK_PACKAGE_VERSION "3.6.2")
@@ -99,23 +97,28 @@
     endif()
   ENDIF()
   
+  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+    SET(DCMTK_ENABLE_CHARSET_CONVERSION "iconv" CACHE STRING "")
+    SET(HAVE_PROTOTYPE_STD__ISINF 1 CACHE INTERNAL "")
+    SET(HAVE_PROTOTYPE_STD__ISNAN 1 CACHE INTERNAL "")
+    SET(HAVE_SYS_GETTID 0 CACHE INTERNAL "")
+
+    execute_process(
+      COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+      ${CMAKE_SOURCE_DIR}/Resources/Patches/dcmtk-3.6.2-linux-standard-base.patch
+      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+      RESULT_VARIABLE Failure
+      )
+
+    if (FirstRun AND Failure)
+      message(FATAL_ERROR "Error while patching a file")
+    endif()
+  endif()
+
   SET(DCMTK_SOURCE_DIR ${DCMTK_SOURCES_DIR})
   include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake)
   include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake)
 
-  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
-    set(HAVE_SSTREAM 1)
-    set(HAVE_PROTOTYPE_BZERO 1)
-    set(HAVE_PROTOTYPE_GETHOSTNAME 1)
-    set(HAVE_PROTOTYPE_GETSOCKOPT 1)
-    set(HAVE_PROTOTYPE_SETSOCKOPT 1)
-    set(HAVE_PROTOTYPE_CONNECT 1)
-    set(HAVE_PROTOTYPE_BIND 1)
-    set(HAVE_PROTOTYPE_ACCEPT 1)
-    set(HAVE_PROTOTYPE_SETSOCKNAME 1)
-    set(HAVE_PROTOTYPE_GETSOCKNAME 1)
-  endif()
-
   set(DCMTK_PACKAGE_VERSION_SUFFIX "")
   set(DCMTK_PACKAGE_VERSION_NUMBER ${DCMTK_VERSION_NUMBER})
 
@@ -223,7 +226,8 @@
         USE_DCMTK_360)
       # This is a patch for MinGW64
       execute_process(
-        COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${DCMTK_PATCH_MINGW64}
+        COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+        ${ORTHANC_ROOT}/Resources/Patches/dcmtk-3.6.0-mingw64.patch
         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
         RESULT_VARIABLE Failure
         )
--- a/Resources/CMake/LibCurlConfiguration.cmake	Tue Jan 02 09:35:07 2018 +0100
+++ b/Resources/CMake/LibCurlConfiguration.cmake	Tue Jan 02 18:04:11 2018 +0100
@@ -1,7 +1,18 @@
+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.50.3)
-  SET(CURL_URL "http://www.orthanc-server.com/downloads/third-party/curl-7.50.3.tar.gz")
-  SET(CURL_MD5 "870e16fd88a88b52e26a4f04dfc161db")
+  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")
 
   DownloadPackage(${CURL_MD5} ${CURL_URL} "${CURL_SOURCES_DIR}")
 
@@ -42,7 +53,7 @@
   endif()
 
   if (NOT EXISTS "${CURL_SOURCES_DIR}/lib/curl_config.h")
-    file(WRITE ${CURL_SOURCES_DIR}/lib/curl_config.h "")
+    #file(WRITE ${CURL_SOURCES_DIR}/lib/curl_config.h "")
 
     file(WRITE ${CURL_SOURCES_DIR}/lib/vauth/vauth/vauth.h "#include \"../vauth.h\"\n")
     file(WRITE ${CURL_SOURCES_DIR}/lib/vauth/vauth/digest.h "#include \"../digest.h\"\n")
@@ -70,48 +81,56 @@
 
     set_property(
       SOURCE ${CURL_SOURCES}
-      PROPERTY COMPILE_DEFINITIONS "HAVE_TIME_H;HAVE_STRUCT_TIMEVAL;HAVE_SYS_STAT_H;HAVE_SOCKET;HAVE_STRUCT_SOCKADDR_STORAGE;HAVE_SYS_SOCKET_H;HAVE_SOCKET;HAVE_SYS_SOCKET_H;HAVE_NETINET_IN_H;HAVE_NETDB_H;HAVE_FCNTL_O_NONBLOCK;HAVE_FCNTL_H;HAVE_SELECT;HAVE_ERRNO_H;HAVE_SEND;HAVE_RECV;HAVE_LONGLONG;OS=\"${TMP_OS}\""
+      PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H=1;OS=\"${TMP_OS}\""
       )
 
-    if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
-      add_definitions(
-        -DRECV_TYPE_ARG1=int
-        -DRECV_TYPE_ARG2=void*
-        -DRECV_TYPE_ARG3=size_t
-        -DRECV_TYPE_ARG4=int
-        -DRECV_TYPE_RETV=ssize_t
-        -DSEND_TYPE_ARG1=int
-        -DSEND_TYPE_ARG2=void*
-        -DSEND_QUAL_ARG2=const
-        -DSEND_TYPE_ARG3=size_t
-        -DSEND_TYPE_ARG4=int
-        -DSEND_TYPE_RETV=ssize_t
-        -DSIZEOF_SHORT=2
-        -DSIZEOF_INT=4
-        -DSIZEOF_SIZE_T=8
-        )
-    elseif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
-      add_definitions(
-        -DRECV_TYPE_ARG1=int
-        -DRECV_TYPE_ARG2=void*
-        -DRECV_TYPE_ARG3=size_t
-        -DRECV_TYPE_ARG4=int
-        -DRECV_TYPE_RETV=int
-        -DSEND_TYPE_ARG1=int
-        -DSEND_TYPE_ARG2=void*
-        -DSEND_QUAL_ARG2=const
-        -DSEND_TYPE_ARG3=size_t
-        -DSEND_TYPE_ARG4=int
-        -DSEND_TYPE_RETV=int
-        -DSIZEOF_SHORT=2
-        -DSIZEOF_INT=4
-        -DSIZEOF_SIZE_T=4
-        )
-    else()
-      message(FATAL_ERROR "Support your platform here")
-    endif()
+    include(CheckTypeSize)
+    include(CheckIncludeFile)
+    include(CheckSymbolExists)
+
+    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_type_size("size_t"  SIZEOF_SIZE_T)
+    check_type_size("ssize_t"  SIZEOF_SSIZE_T)
+    check_type_size("long long"  SIZEOF_LONG_LONG)
+    check_type_size("long"  SIZEOF_LONG)
+    check_type_size("short"  SIZEOF_SHORT)
+    check_type_size("int"  SIZEOF_INT)
+    check_type_size("__int64"  SIZEOF___INT64)
+    check_type_size("long double"  SIZEOF_LONG_DOUBLE)
+    check_type_size("time_t"  SIZEOF_TIME_T)
+    check_type_size("off_t"  SIZEOF_OFF_T)
+    check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
+
+    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)
+
+    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?
+
+    configure_file(
+      ${CURL_SOURCES_DIR}/lib/curl_config.h.cmake
+      ${CURL_SOURCES_DIR}/lib/curl_config.h
+      )
   endif()
-
 else()
   include(FindCURL)
   include_directories(${CURL_INCLUDE_DIRS})
--- a/Resources/CMake/OpenSslConfiguration.cmake	Tue Jan 02 09:35:07 2018 +0100
+++ b/Resources/CMake/OpenSslConfiguration.cmake	Tue Jan 02 18:04:11 2018 +0100
@@ -203,17 +203,6 @@
       ${OPENSSL_SOURCES}
       PROPERTIES COMPILE_DEFINITIONS
       "OPENSSL_SYSNAME_WIN32;SO_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN")
-
-  elseif ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
-    execute_process(
-      COMMAND ${PATCH_EXECUTABLE} -N ui_openssl.c -i ${ORTHANC_ROOT}/Resources/Patches/openssl-lsb.diff
-      WORKING_DIRECTORY ${OPENSSL_SOURCES_DIR}/crypto/ui
-      RESULT_VARIABLE Failure
-      )
-
-    if (Failure AND FirstRun)
-      message(FATAL_ERROR "Error while patching a file")
-    endif()
   endif()
 
   source_group(ThirdParty\\OpenSSL REGULAR_EXPRESSION ${OPENSSL_SOURCES_DIR}/.*)
--- a/Resources/LinuxStandardBaseToolchain.cmake	Tue Jan 02 09:35:07 2018 +0100
+++ b/Resources/LinuxStandardBaseToolchain.cmake	Tue Jan 02 18:04:11 2018 +0100
@@ -1,14 +1,16 @@
+# LSB_CC=gcc-4.8 LSB_CXX=g++-4.8 cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../Resources/LinuxStandardBaseToolchain.cmake
+
 INCLUDE(CMakeForceCompiler)
 
 SET(LSB_PATH $ENV{LSB_PATH})
+SET(LSB_CC $ENV{LSB_CC})
+SET(LSB_CXX $ENV{LSB_CXX})
 SET(LSB_TARGET_VERSION "4.0")
 
 IF ("${LSB_PATH}" STREQUAL "")
   SET(LSB_PATH "/opt/lsb")
 ENDIF()
 
-message("Using the following Linux Standard Base: ${LSB_PATH}")
-
 IF (EXISTS ${LSB_PATH}/lib64)
   SET(LSB_TARGET_PROCESSOR "x86_64")
   SET(LSB_LIBPATH ${LSB_PATH}/lib64-${LSB_TARGET_VERSION})
@@ -38,5 +40,24 @@
 # search headers and libraries in the target environment, search 
 # programs in the host environment
 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
+
+SET(CMAKE_CROSSCOMPILING OFF)
+
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include" CACHE INTERNAL "" FORCE)
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward" CACHE INTERNAL "" FORCE)
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}" CACHE INTERNAL "" FORCE)
+
+if (NOT "${LSB_CXX}" STREQUAL "")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-cxx=${LSB_CXX}")
+  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-cxx=${LSB_CXX}")
+endif()
+
+if (NOT "${LSB_CC}" STREQUAL "")
+  SET(CMAKE_C_FLAGS "${CMAKE_CC_FLAGS} --lsb-cc=${LSB_CC}")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-cc=${LSB_CC}")
+  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-cc=${LSB_CC}")
+endif()
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/boost-1.65.1-linux-standard-base.patch	Tue Jan 02 18:04:11 2018 +0100
@@ -0,0 +1,12 @@
+diff -urEb boost_1_65_1.orig/boost/move/adl_move_swap.hpp boost_1_65_1/boost/move/adl_move_swap.hpp
+--- boost_1_65_1.orig/boost/move/adl_move_swap.hpp	2017-11-08 17:43:20.000000000 +0100
++++ boost_1_65_1/boost/move/adl_move_swap.hpp	2018-01-02 15:34:48.829052917 +0100
+@@ -28,6 +28,8 @@
+ //Try to avoid including <algorithm>, as it's quite big
+ #if defined(_MSC_VER) && defined(BOOST_DINKUMWARE_STDLIB)
+    #include <utility>   //Dinkum libraries define std::swap in utility which is lighter than algorithm
++#elif defined(__LSB_VERSION__)
++#  include <utility>
+ #elif defined(BOOST_GNU_STDLIB)
+    //For non-GCC compilers, where GNUC version is not very reliable, or old GCC versions
+    //use the good old stl_algobase header, which is quite lightweight
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/dcmtk-3.6.2-linux-standard-base.patch	Tue Jan 02 18:04:11 2018 +0100
@@ -0,0 +1,12 @@
+diff -urEb dcmtk-3.6.2.orig/ofstd/include/dcmtk/ofstd/offile.h dcmtk-3.6.2/ofstd/include/dcmtk/ofstd/offile.h
+--- dcmtk-3.6.2.orig/ofstd/include/dcmtk/ofstd/offile.h	2017-07-14 17:41:11.000000000 +0200
++++ dcmtk-3.6.2/ofstd/include/dcmtk/ofstd/offile.h	2018-01-02 13:56:04.075293459 +0100
+@@ -551,7 +551,7 @@
+    */
+   void setlinebuf()
+   {
+-#if defined(_WIN32) || defined(__hpux)
++#if defined(_WIN32) || defined(__hpux) || defined(__LSB_VERSION__)
+     this->setvbuf(NULL, _IOLBF, 0);
+ #else
+     :: setlinebuf(file_);