changeset 132:d20ad6561d2e

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Aug 2017 21:41:37 +0200
parents 0e4d107e754e
children e221494b8ab9 c2895ac08582
files CMakeLists.txt NEWS Orthanc/Resources/CMake/BoostConfiguration.cmake Orthanc/Resources/CMake/Compiler.cmake Orthanc/Resources/CMake/LibIconvConfiguration.cmake Resources/SyncOrthancFolder.py
diffstat 6 files changed, 161 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Aug 11 17:54:50 2017 +0200
+++ b/CMakeLists.txt	Mon Aug 21 21:41:37 2017 +0200
@@ -33,6 +33,7 @@
 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
 set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
+SET(USE_SYSTEM_LIBICONV ON CACHE BOOL "Use the system version of libiconv")
 set(USE_SYSTEM_LIBPQ ON CACHE BOOL "Use the system version of the PostgreSQL client library")
 set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
 
@@ -42,6 +43,7 @@
 
 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Orthanc)
 set(ORTHANC_DISABLE_PATCH ON)  # No need for the "patch" command-line tool
+set(USE_BOOST_ICONV ON)
 include(CheckIncludeFiles)
 include(CheckIncludeFileCXX)
 include(CheckLibraryExists)
@@ -49,8 +51,9 @@
 include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
 include(${ORTHANC_ROOT}/Resources/CMake/AutoGeneratedCode.cmake)
 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
+include(${ORTHANC_ROOT}/Resources/CMake/LibIconvConfiguration.cmake)
 include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
-include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/PostgreSQLConfiguration.cmake)
 
 if (BUILD_UNIT_TESTS)
--- a/NEWS	Fri Aug 11 17:54:50 2017 +0200
+++ b/NEWS	Mon Aug 21 21:41:37 2017 +0200
@@ -4,6 +4,7 @@
 * Upgrade to PostgreSQL 9.6.1 client library for static builds
 * Performance warning if runtime debug assertions are turned on
 * Fix issue 62 (use correct type for lo_read() value)
+* Support of OpenBSD
 
 
 Release 2.0 (2015/12/02)
--- a/Orthanc/Resources/CMake/BoostConfiguration.cmake	Fri Aug 11 17:54:50 2017 +0200
+++ b/Orthanc/Resources/CMake/BoostConfiguration.cmake	Mon Aug 21 21:41:37 2017 +0200
@@ -55,6 +55,7 @@
       ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
+      ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "PNaCl" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl32" OR
       ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl64")
@@ -64,7 +65,6 @@
       ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/thread.cpp
       )
     add_definitions(
-      -DBOOST_LOCALE_WITH_ICONV=1
       -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
       -DBOOST_LOCALE_NO_STD_BACKEND=1
       )
@@ -84,17 +84,6 @@
       ${BOOST_FILESYSTEM_SOURCES_DIR}/windows_file_codecvt.cpp
       )
 
-    # Starting with release 0.8.2, Orthanc statically links against
-    # libiconv, even on Windows. Indeed, the "WCONV" library of
-    # Windows XP seems not to support properly several codepages
-    # (notably "Latin3", "Hebrew", and "Arabic").
-
-    if (USE_BOOST_ICONV)
-      include(${ORTHANC_ROOT}/Resources/CMake/LibIconvConfiguration.cmake)
-    else()
-      add_definitions(-DBOOST_LOCALE_WITH_WCONV=1)
-    endif()
-
     add_definitions(
       -DBOOST_LOCALE_NO_POSIX_BACKEND=1
       -DBOOST_LOCALE_NO_STD_BACKEND=1
@@ -110,7 +99,8 @@
     message(FATAL_ERROR "Support your platform here")
   endif()
 
-  if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+  if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
+      ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
     list(APPEND BOOST_SOURCES
       ${BOOST_SOURCES_DIR}/libs/filesystem/src/utf8_codecvt_facet.cpp
       )
@@ -155,6 +145,7 @@
         ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
         ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
         ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
+        ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR
         ${CMAKE_SYSTEM_NAME} STREQUAL "PNaCl" OR
         ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl32" OR
         ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl64")
--- a/Orthanc/Resources/CMake/Compiler.cmake	Fri Aug 11 17:54:50 2017 +0200
+++ b/Orthanc/Resources/CMake/Compiler.cmake	Mon Aug 21 21:41:37 2017 +0200
@@ -7,7 +7,8 @@
 endif()
 
 if (CMAKE_COMPILER_IS_GNUCXX)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long -Wno-implicit-function-declaration")  
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long")
+
   # --std=c99 makes libcurl not to compile
   # -pedantic gives a lot of warnings on OpenSSL 
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-variadic-macros")
@@ -56,11 +57,27 @@
 endif()
 
 
+if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
+    ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+  # In FreeBSD/OpenBSD, the "/usr/local/" folder contains the ports and need to be imported
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include")
+  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
+  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib")
+endif()
+
+
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
     ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
-    ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
-  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
+    ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
+    ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+
+  if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+    # The "--no-undefined" linker flag makes the shared libraries
+    # (plugins ModalityWorklists and ServeFolders) fail to compile on OpenBSD
+    set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
+  endif()
 
   if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR 
       ENABLE_PLUGINS_VERSION_SCRIPT)
@@ -70,22 +87,39 @@
   # 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 rt)
+  link_libraries(uuid pthread)
+
+  if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+    link_libraries(rt)
+  endif()
+
+  if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND
+      NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+    link_libraries(dl)
+  endif()
 
   if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+    # The "--as-needed" linker flag is not available on FreeBSD
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
+  endif()
+
+  if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND
+      NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+    # FreeBSD/OpenBSD have just one single interface for file
+    # handling, which is 64bit clean, so there is no need to define macro
+    # for LFS (Large File Support).
+    # https://ohse.de/uwe/articles/lfs.html
     add_definitions(
       -D_LARGEFILE64_SOURCE=1 
       -D_FILE_OFFSET_BITS=64
       )
-    link_libraries(dl)
   endif()
 
   CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H)
   if (NOT HAVE_UUID_H)
-    message(FATAL_ERROR "Please install the uuid-dev package")
+    message(FATAL_ERROR "Please install the uuid-dev package (or e2fsprogs if OpenBSD)")
   endif()
 
 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
@@ -145,6 +179,8 @@
     message(FATAL_ERROR "Please install the uuid-dev package")
   endif()
 
+else()
+  message(FATAL_ERROR "Support your platform here")
 endif()
 
 
@@ -155,15 +191,6 @@
 endif()
 
 
-if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
-  # In FreeBSD, the "/usr/local/" folder contains the ports and need to be imported
-  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include")
-  SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include")
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
-  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib")
-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")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Orthanc/Resources/CMake/LibIconvConfiguration.cmake	Mon Aug 21 21:41:37 2017 +0200
@@ -0,0 +1,108 @@
+if (NOT USE_BOOST_ICONV)
+  message("Not using libiconv")
+
+  if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+    # Starting with release 0.8.2, Orthanc statically links against
+    # libiconv, even on Windows. Indeed, the "WCONV" library of
+    # Windows XP seems not to support properly several codepages
+    # (notably "Latin3", "Hebrew", and "Arabic"). The flag
+    # "USE_BOOST_ICONV" allows to force the use of "WCONV".
+    add_definitions(-DBOOST_LOCALE_WITH_WCONV=1)
+  else()
+    message(FATAL_ERROR "Support your platform here")
+  endif()
+
+else()
+  message("Using libiconv")
+
+  add_definitions(
+    -DBOOST_LOCALE_WITH_ICONV=1
+    )
+
+  if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICONV)
+    set(LIBICONV_SOURCES_DIR ${CMAKE_BINARY_DIR}/libiconv-1.15)
+    set(LIBICONV_URL "http://www.orthanc-server.com/downloads/third-party/libiconv-1.15.tar.gz")
+    set(LIBICONV_MD5 "ace8b5f2db42f7b3b3057585e80d9808")
+
+    DownloadPackage(${LIBICONV_MD5} ${LIBICONV_URL} "${LIBICONV_SOURCES_DIR}")
+
+    # Disable the support of libiconv that is shipped by default with
+    # the C standard library on Linux. Setting this macro redirects
+    # calls from "iconv*()" to "libiconv*()" in the source code of
+    # "libiconv-1.15".
+    add_definitions(-DLIBICONV_PLUG=1)
+
+    # https://groups.google.com/d/msg/android-ndk/AS1nkxnk6m4/EQm09hD1tigJ
+    add_definitions(
+      -DBUILDING_LIBICONV=1
+      -DIN_LIBRARY=1
+      -DLIBDIR=""
+      -DICONV_CONST=
+      )
+
+    configure_file(
+      ${LIBICONV_SOURCES_DIR}/srclib/localcharset.h
+      ${LIBICONV_SOURCES_DIR}/include
+      COPYONLY)
+
+    set(HAVE_VISIBILITY 0)
+    set(ICONV_CONST ${ICONV_CONST})
+    set(USE_MBSTATE_T 1)
+    set(BROKEN_WCHAR_H 0)
+    set(EILSEQ)
+    set(HAVE_WCHAR_T 1)
+    configure_file(
+      ${LIBICONV_SOURCES_DIR}/include/iconv.h.build.in
+      ${LIBICONV_SOURCES_DIR}/include/iconv.h
+      )
+    unset(HAVE_VISIBILITY)
+    unset(ICONV_CONST)
+    unset(USE_MBSTATE_T)
+    unset(BROKEN_WCHAR_H)
+    unset(EILSEQ)
+    unset(HAVE_WCHAR_T)
+
+    # Create an empty "config.h" for libiconv
+    file(WRITE ${LIBICONV_SOURCES_DIR}/include/config.h "")
+
+    include_directories(
+      ${LIBICONV_SOURCES_DIR}/include
+      )
+
+    set(LIBICONV_SOURCES
+      ${LIBICONV_SOURCES_DIR}/lib/iconv.c  
+      ${LIBICONV_SOURCES_DIR}/lib/relocatable.c
+      ${LIBICONV_SOURCES_DIR}/libcharset/lib/localcharset.c  
+      ${LIBICONV_SOURCES_DIR}/libcharset/lib/relocatable.c
+      )
+
+    source_group(ThirdParty\\libiconv REGULAR_EXPRESSION ${LIBICONV_SOURCES_DIR}/.*)
+
+    if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+      add_definitions(-DHAVE_WORKING_O_NOFOLLOW=0)
+    else()
+      add_definitions(-DHAVE_WORKING_O_NOFOLLOW=1)
+    endif()
+
+  else() 
+    CHECK_INCLUDE_FILE_CXX(iconv.h HAVE_ICONV_H)
+    if (NOT HAVE_ICONV_H)
+      message(FATAL_ERROR "Please install the libiconv-dev package")
+    endif()
+
+    # Check whether the support for libiconv is bundled within the
+    # standard library
+    CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV_LIB)
+    if (NOT HAVE_ICONV_LIB)
+      # No builtin support for libiconv, try and find an external library.
+      # Open question: Does this make sense on any platform?
+      CHECK_LIBRARY_EXISTS(iconv iconv_open "" HAVE_ICONV_LIB_2)
+      if (NOT HAVE_ICONV_LIB_2)
+        message(FATAL_ERROR "Please install the libiconv-dev package")
+      else()
+        link_libraries(iconv)
+      endif()
+    endif()
+
+  endif()
+endif()
--- a/Resources/SyncOrthancFolder.py	Fri Aug 11 17:54:50 2017 +0200
+++ b/Resources/SyncOrthancFolder.py	Mon Aug 21 21:41:37 2017 +0200
@@ -24,6 +24,7 @@
     'Resources/CMake/DownloadPackage.cmake',
     'Resources/CMake/GoogleTestConfiguration.cmake',
     'Resources/CMake/JsonCppConfiguration.cmake',
+    'Resources/CMake/LibIconvConfiguration.cmake',
     'Resources/EmbedResources.py',
     'Resources/MinGW-W64-Toolchain32.cmake',
     'Resources/MinGW-W64-Toolchain64.cmake',