summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-07-30 20:23:41 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-08-05 16:15:33 +0300
commitbbc684f3fa4cd0ba0e1c228dbdd447fe2bbf5c98 (patch)
treeb0d50be49f940024ae965b1e8be3b441369c796a
parentf86f0226dd7f87fef97378cff225754ae5d69c90 (diff)
downloadqtlocation-mapboxgl-upstream/icu-no-format-number.tar.gz
-rw-r--r--CMakeLists.txt5
-rw-r--r--cmake/mason-dependencies.cmake4
-rw-r--r--platform/default/src/mbgl/util/format_number.cpp5
-rw-r--r--platform/linux/config.cmake32
4 files changed, 30 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index df2e4940fd..286babb8a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,7 @@ option(WITH_OSMESA "Use OSMesa headless backend" OFF)
option(WITH_EGL "Use EGL backend" OFF)
option(WITH_NODEJS "Download test dependencies like NPM and Node.js" ON)
option(WITH_ERROR "Add -Werror flag to build (turns warnings into errors)" ON)
+option(WITH_ICU_I18N "Assume ICU with i18n support" ON)
if (WITH_ERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
@@ -75,6 +76,10 @@ set_source_files_properties(src/mbgl/util/version.cpp PROPERTIES COMPILE_DEFINIT
include(cmake/mason-dependencies.cmake)
+if(WITH_ICU_18N)
+ add_definitions(-DMBGL_ICU_I18N=1)
+endif()
+
if(WITH_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake
index 5ec6a44a79..db7f6ab685 100644
--- a/cmake/mason-dependencies.cmake
+++ b/cmake/mason-dependencies.cmake
@@ -8,7 +8,9 @@ elseif(MBGL_PLATFORM STREQUAL "linux")
mason_use(libuv VERSION 1.9.1)
mason_use(libpng VERSION 1.6.25)
mason_use(libjpeg-turbo VERSION 1.5.0)
- mason_use(icu VERSION 63.1-min-static-data)
+ if(WITH_ICU_I18N)
+ mason_use(icu VERSION 63.1-min-static-data)
+ endif()
if(WITH_EGL)
mason_use(swiftshader VERSION 2018-05-31)
diff --git a/platform/default/src/mbgl/util/format_number.cpp b/platform/default/src/mbgl/util/format_number.cpp
index 7cc863818a..0adab6eb47 100644
--- a/platform/default/src/mbgl/util/format_number.cpp
+++ b/platform/default/src/mbgl/util/format_number.cpp
@@ -23,7 +23,12 @@ std::string formatNumber(double number, const std::string& localeId, const std::
.toString();
} else {
ustr = icu::number::NumberFormatter::with()
+#if WITH_ICU_I18N
.precision(icu::number::Precision::minMaxFraction(minFractionDigits, maxFractionDigits))
+#else
+ (void)minFractionDigits;
+ (void)maxFractionDigits;
+#endif
.locale(locale)
.formatDouble(number, status)
.toString();
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index aa65ddb606..c75cc6cd7f 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -86,21 +86,23 @@ macro(mbgl_platform_core)
target_add_mason_package(mbgl-core PUBLIC libjpeg-turbo)
target_add_mason_package(mbgl-core PRIVATE icu)
- # Ignore warning caused by ICU header unistr.h in some CI environments
- set_source_files_properties(platform/default/src/mbgl/util/format_number.cpp PROPERTIES COMPILE_FLAGS -Wno-error=shadow)
-
- # Link all ICU libraries (by default only libicuuc is linked)
- find_library(LIBICUI18N NAMES icui18n HINTS ${MASON_PACKAGE_icu_INCLUDE_DIRS}/../lib)
- find_library(LIBICUUC NAMES icuuc HINTS ${MASON_PACKAGE_icu_INCLUDE_DIRS}/../lib)
- find_library(LIBICUDATA NAMES icudata HINTS ${MASON_PACKAGE_icu_INCLUDE_DIRS}/../lib)
-
- target_link_libraries(mbgl-core
- PRIVATE ${LIBICUI18N}
- PRIVATE ${LIBICUUC}
- PRIVATE ${LIBICUDATA}
- PRIVATE nunicode
- PUBLIC -lz
- )
+ if(WITH_ICU_I18N)
+ # Ignore warning caused by ICU header unistr.h in some CI environments
+ set_source_files_properties(platform/default/src/mbgl/util/format_number.cpp PROPERTIES COMPILE_FLAGS -Wno-error=shadow)
+
+ # Link all ICU libraries (by default only libicuuc is linked)
+ find_library(LIBICUI18N NAMES icui18n HINTS ${MASON_PACKAGE_icu_INCLUDE_DIRS}/../lib)
+ find_library(LIBICUUC NAMES icuuc HINTS ${MASON_PACKAGE_icu_INCLUDE_DIRS}/../lib)
+ find_library(LIBICUDATA NAMES icudata HINTS ${MASON_PACKAGE_icu_INCLUDE_DIRS}/../lib)
+
+ target_link_libraries(mbgl-core
+ PRIVATE ${LIBICUI18N}
+ PRIVATE ${LIBICUUC}
+ PRIVATE ${LIBICUDATA}
+ PRIVATE nunicode
+ PUBLIC -lz
+ )
+ endif()
if(WITH_CXX11ABI)
# Statically link libstdc++ when we're using the new STL ABI