diff Resources/CMake/GdcmConfiguration.cmake @ 176:55f8cf4ea237

support for Linux Standard Base
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Jan 2018 09:01:14 +0100
parents 81f16c5667ba
children 8d1b1dc6150b
line wrap: on
line diff
--- a/Resources/CMake/GdcmConfiguration.cmake	Thu Jan 04 07:34:54 2018 +0100
+++ b/Resources/CMake/GdcmConfiguration.cmake	Thu Jan 04 09:01:14 2018 +0100
@@ -18,11 +18,11 @@
 
 
 if (STATIC_BUILD OR NOT USE_SYSTEM_GDCM)
-  # If using gcc, build GDCM with the "-fPIC" argument to allow its
-  # embedding into the shared library containing the Orthanc plugin
   if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
+    # If using gcc, build GDCM with the "-fPIC" argument to allow its
+    # embedding into the shared library containing the Orthanc plugin
     set(AdditionalFlags "-fPIC")
   elseif (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
     # This definition is necessary to compile
@@ -47,13 +47,33 @@
     list(APPEND Flags -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
   endif()
 
+  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+    # Trick to disable the compilation of socket++ by gdcm, which is
+    # incompatible with LSB, but fortunately only required for DICOM
+    # Networking
+    list(APPEND Flags -DGDCM_USE_SYSTEM_SOCKETXX=ON)
+
+    # Detect the number of CPU cores
+    include(ProcessorCount)
+    ProcessorCount(N)
+    if (NOT N EQUAL 0)
+      set(MAKE_PARALLEL -j${N})
+    endif()
+      
+    # For Linux Standard Base, avoid building incompatible target gdcmMEXD (*)
+    set(BUILD_COMMAND BUILD_COMMAND
+      ${CMAKE_MAKE_PROGRAM} ${MAKE_PARALLEL}
+      gdcmMSFF gdcmcharls gdcmDICT gdcmDSED gdcmIOD gdcmjpeg8
+      gdcmjpeg12 gdcmjpeg16 gdcmopenjpeg gdcmzlib gdcmCommon gdcmexpat)
+  endif()
+
   include(ExternalProject)
   externalproject_add(GDCM
     URL "http://www.orthanc-server.com/downloads/third-party/gdcm-2.6.0.tar.gz"
     URL_MD5 "978afe57af448b1c97c9f116790aca9c"
     TIMEOUT 60
     CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} ${Flags}
-    #-DLIBRARY_OUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}
+    ${BUILD_COMMAND}    # Customize "make", only for Linux Standard Base (*)
     INSTALL_COMMAND ""  # Skip the install step
     )
 
@@ -74,13 +94,13 @@
     ${Prefix}gdcmjpeg8${Suffix}
     ${Prefix}gdcmjpeg12${Suffix}
     ${Prefix}gdcmjpeg16${Suffix}
-    ${Prefix}gdcmMEXD${Suffix}
     ${Prefix}gdcmopenjpeg${Suffix}
     ${Prefix}gdcmzlib${Suffix}
-    ${Prefix}socketxx${Suffix}
     ${Prefix}gdcmCommon${Suffix}
     ${Prefix}gdcmexpat${Suffix}
 
+    #${Prefix}socketxx${Suffix}
+    #${Prefix}gdcmMEXD${Suffix}  # DICOM Networking, unneeded by Orthanc plugins
     #${Prefix}gdcmgetopt${Suffix}
     #${Prefix}gdcmuuid${Suffix}
     )