summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/default/src/mbgl/i18n/number_format.cpp23
-rw-r--r--platform/linux/linux.cmake23
2 files changed, 30 insertions, 16 deletions
diff --git a/platform/default/src/mbgl/i18n/number_format.cpp b/platform/default/src/mbgl/i18n/number_format.cpp
index ded4495202..6a975926d7 100644
--- a/platform/default/src/mbgl/i18n/number_format.cpp
+++ b/platform/default/src/mbgl/i18n/number_format.cpp
@@ -1,10 +1,16 @@
#include <mbgl/i18n/number_format.hpp>
+#if !defined(MBGL_USE_BUILTIN_ICU)
#include <unicode/numberformatter.h>
+#include <unicode/uvernum.h>
+#endif
+
+#include <string>
namespace mbgl {
namespace platform {
+#if !defined(MBGL_USE_BUILTIN_ICU)
std::string formatNumber(double number,
const std::string& localeId,
const std::string& currency,
@@ -22,28 +28,21 @@ std::string formatNumber(double number,
.unit(icu::CurrencyUnit(ucurrency.getBuffer(), status))
.locale(locale)
.formatDouble(number, status)
-#if U_ICU_VERSION_MAJOR_NUM >= 62
.toString(status);
-#else
- .toString();
-#endif
} else {
ustr = icu::number::NumberFormatter::with()
-#if U_ICU_VERSION_MAJOR_NUM >= 62
.precision(icu::number::Precision::minMaxFraction(minFractionDigits, maxFractionDigits))
-#else
- .rounding(icu::number::Rounder::minMaxFraction(minFractionDigits, maxFractionDigits))
-#endif
.locale(locale)
.formatDouble(number, status)
-#if U_ICU_VERSION_MAJOR_NUM >= 62
.toString(status);
-#else
- .toString();
-#endif
}
return ustr.toUTF8String(formatted);
}
+#else
+std::string formatNumber(double number, const std::string&, const std::string&, uint8_t, uint8_t) {
+ return std::to_string(number);
+}
+#endif
} // namespace platform
} // namespace mbgl
diff --git a/platform/linux/linux.cmake b/platform/linux/linux.cmake
index bf89601a57..7412b09f8a 100644
--- a/platform/linux/linux.cmake
+++ b/platform/linux/linux.cmake
@@ -1,6 +1,6 @@
find_package(CURL REQUIRED)
-find_package(ICU REQUIRED i18n)
-find_package(ICU REQUIRED uc)
+find_package(ICU OPTIONAL_COMPONENTS i18n)
+find_package(ICU OPTIONAL_COMPONENTS uc)
find_package(JPEG REQUIRED)
find_package(OpenGL REQUIRED GLX)
find_package(PNG REQUIRED)
@@ -65,6 +65,20 @@ target_include_directories(
include(${PROJECT_SOURCE_DIR}/vendor/nunicode.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/sqlite.cmake)
+if(NOT ${ICU_FOUND} OR "${ICU_VERSION}" VERSION_LESS 62.0)
+ message("-- ICU not found or too old, using builtin.")
+
+ set(MBGL_USE_BUILTIN_ICU TRUE)
+ include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake)
+
+ set_source_files_properties(
+ ${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/i18n/number_format.cpp
+ PROPERTIES
+ COMPILE_DEFINITIONS
+ MBGL_USE_BUILTIN_ICU
+ )
+endif()
+
target_link_libraries(
mbgl-core
PRIVATE
@@ -72,8 +86,9 @@ target_link_libraries(
${JPEG_LIBRARIES}
${LIBUV_LIBRARIES}
${X11_LIBRARIES}
- ICU::i18n
- ICU::uc
+ $<$<NOT:$<BOOL:${MBGL_USE_BUILTIN_ICU}>>:ICU::i18n>
+ $<$<NOT:$<BOOL:${MBGL_USE_BUILTIN_ICU}>>:ICU::uc>
+ $<$<BOOL:${MBGL_USE_BUILTIN_ICU}>:mbgl-vendor-icu>
OpenGL::GLX
PNG::PNG
mbgl-vendor-nunicode