diff OrthancFramework/Sources/Toolbox.cpp @ 5257:0b183bb77c83

Avoid the use of "externalproject_add()" to build the sample plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Apr 2023 11:54:08 +0200
parents 0ea402b4d901
children f66b8d70917e
line wrap: on
line diff
--- a/OrthancFramework/Sources/Toolbox.cpp	Sat Apr 08 11:38:01 2023 +0200
+++ b/OrthancFramework/Sources/Toolbox.cpp	Wed Apr 12 11:54:08 2023 +0200
@@ -36,6 +36,10 @@
 #  error Cannot access the version of JsonCpp
 #endif
 
+#if !defined(ORTHANC_ENABLE_ICU)
+#  define ORTHANC_ENABLE_ICU 1
+#endif
+
 
 /**
  * We use deprecated "Json::Reader", "Json::StyledWriter" and
@@ -142,7 +146,7 @@
 }
 
 
-#if defined(ORTHANC_STATIC_ICU)
+#if defined(ORTHANC_STATIC_ICU) && (ORTHANC_ENABLE_ICU == 1)
 #  if (ORTHANC_STATIC_ICU == 1 && ORTHANC_ENABLE_LOCALE == 1)
 #    include <OrthancFrameworkResources.h>
 #    include <unicode/udata.h>
@@ -626,11 +630,15 @@
                                      bool hasCodeExtensions)
   {
 #if ORTHANC_STATIC_ICU == 1
+#  if ORTHANC_ENABLE_ICU == 0
+    throw OrthancException(ErrorCode_NotImplemented, "ICU is disabled for this target");
+#  else
     if (globalIcuData_.empty())
     {
       throw OrthancException(ErrorCode_BadSequenceOfCalls,
                              "Call Toolbox::InitializeGlobalLocale()");
     }
+#  endif
 #endif
 
     // The "::skip" flag makes boost skip invalid UTF-8
@@ -685,11 +693,15 @@
                                        Encoding targetEncoding)
   {
 #if ORTHANC_STATIC_ICU == 1
+#  if ORTHANC_ENABLE_ICU == 0
+    throw OrthancException(ErrorCode_NotImplemented, "ICU is disabled for this target");
+#  else
     if (globalIcuData_.empty())
     {
       throw OrthancException(ErrorCode_BadSequenceOfCalls,
                              "Call Toolbox::InitializeGlobalLocale()");
     }
+#  endif
 #endif
 
     // The "::skip" flag makes boost skip invalid UTF-8
@@ -1525,7 +1537,7 @@
   
   static void InitializeIcu()
   {
-#if ORTHANC_STATIC_ICU == 1
+#if (ORTHANC_STATIC_ICU == 1) && (ORTHANC_ENABLE_ICU == 1)
     if (globalIcuData_.empty())
     {
       LOG(INFO) << "Setting up the ICU common data";
@@ -1693,10 +1705,14 @@
     bool error = (globalLocale_.get() == NULL);
 
 #if ORTHANC_STATIC_ICU == 1
+#  if ORTHANC_ENABLE_ICU == 0
+    throw OrthancException(ErrorCode_NotImplemented, "ICU is disabled for this target");
+#  else
     if (globalIcuData_.empty())
     {
       error = true;
     }
+#  endif
 #endif
     
     if (error)