diff --git a/3party/freetype/CMakeLists.txt b/3party/freetype/CMakeLists.txt index 5120494b50..f860474cbe 100644 --- a/3party/freetype/CMakeLists.txt +++ b/3party/freetype/CMakeLists.txt @@ -6,3 +6,4 @@ target_include_directories(freetype $ $ ) +add_library(Freetype::Freetype ALIAS freetype) diff --git a/3party/icu/CMakeLists.txt b/3party/icu/CMakeLists.txt index 60b55d93de..9a716b353d 100644 --- a/3party/icu/CMakeLists.txt +++ b/3party/icu/CMakeLists.txt @@ -1,6 +1,6 @@ project(icu) -set(SRC +add_library(icuuc uconfig_local.h icu/icu4c/source/common/appendable.cpp icu/icu4c/source/common/bmpset.cpp @@ -170,6 +170,21 @@ set(SRC icu/icu4c/source/common/uvectr32.cpp icu/icu4c/source/common/uvectr64.h icu/icu4c/source/common/wintz.h +) + +target_include_directories(icuuc + PUBLIC + ./ + icu/icu4c/source/common +) + +target_compile_definitions(icuuc PUBLIC UCONFIG_USE_LOCAL) + +set_target_properties(icuuc PROPERTIES UNITY_BUILD OFF) + +add_library(ICU::uc ALIAS icuuc) + +add_library(icui18n icu/icu4c/source/i18n/anytrans.cpp icu/icu4c/source/i18n/anytrans.h icu/icu4c/source/i18n/astro.h @@ -375,18 +390,18 @@ set(SRC icu/icu4c/source/stubdata/stubdata.cpp ) -add_library(${PROJECT_NAME} ${SRC}) +target_compile_definitions(icui18n PUBLIC UCONFIG_USE_LOCAL) -target_compile_definitions(${PROJECT_NAME} - PUBLIC - UCONFIG_USE_LOCAL -) - -target_include_directories(${PROJECT_NAME} +target_include_directories(icui18n PUBLIC ./ - icu/icu4c/source/common icu/icu4c/source/i18n + PRIVATE + icu/icu4c/source/common ) -set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD OFF) +target_link_libraries(icui18n PRIVATE icuuc) + +set_target_properties(icui18n PROPERTIES UNITY_BUILD OFF) + +add_library(ICU::i18n ALIAS icui18n) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7b854f9d4..ce79125a2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,9 +310,14 @@ set(EXPAT_SHARED_LIBS OFF) add_subdirectory(3party/expat/expat) add_subdirectory(3party/agg) add_subdirectory(3party/bsdiff-courgette) -add_subdirectory(3party/freetype) add_subdirectory(3party/gflags) -add_subdirectory(3party/icu) +if (LINUX_DETECTED) + find_package(ICU COMPONENTS uc i18n data REQUIRED) + find_package(Freetype REQUIRED) +else() + add_subdirectory(3party/freetype) + add_subdirectory(3party/icu) +endif() add_subdirectory(3party/jansson) add_subdirectory(3party/liboauthcpp) add_subdirectory(3party/minizip) diff --git a/coding/CMakeLists.txt b/coding/CMakeLists.txt index 82ca04ba16..fcaff2e136 100644 --- a/coding/CMakeLists.txt +++ b/coding/CMakeLists.txt @@ -97,7 +97,8 @@ target_link_libraries(${PROJECT_NAME} expat jansson succinct - icu # For transliteration. + ICU::uc + ICU::i18n # For transliteration. oauthcpp # For base64_encode and base64_decode minizip ${LIBZ} diff --git a/coding/transliteration.cpp b/coding/transliteration.cpp index bb52809333..0a99b36703 100644 --- a/coding/transliteration.cpp +++ b/coding/transliteration.cpp @@ -13,6 +13,8 @@ #include #include +#include "std/target_os.hpp" + #include #include @@ -58,8 +60,12 @@ void Transliteration::Init(std::string const & icuDataDir) return; // This function should be called before the first ICU operation that will require the loading of - // an ICU data file. + // an ICU data file. On Linux, data file is loaded automatically from the shared library. +#ifndef OMIM_OS_LINUX u_setDataDirectory(icuDataDir.c_str()); +#else + UNUSED_VALUE(icuDataDir); +#endif for (auto const & lang : StringUtf8Multilang::GetSupportedLanguages()) { @@ -118,10 +124,7 @@ bool Transliteration::Transliterate(std::string const & transID, icu::UnicodeStr it->second->m_transliterator->transliterate(ustr); - if (ustr.isEmpty()) - return false; - - return true; + return !ustr.isEmpty(); } bool Transliteration::TransliterateForce(std::string const & str, std::string const & transliteratorId, diff --git a/coding/transliteration.hpp b/coding/transliteration.hpp index a6e8c16838..676705d8f8 100644 --- a/coding/transliteration.hpp +++ b/coding/transliteration.hpp @@ -7,10 +7,12 @@ #include #include -namespace icu -{ +// From ICU library, either 3party/icu or from the system's package. +#include + +U_NAMESPACE_BEGIN class UnicodeString; -} // namespace icu +U_NAMESPACE_END class Transliteration { diff --git a/drape/CMakeLists.txt b/drape/CMakeLists.txt index e0eedfa03d..5221eb5302 100644 --- a/drape/CMakeLists.txt +++ b/drape/CMakeLists.txt @@ -169,11 +169,11 @@ target_link_libraries(${PROJECT_NAME} geometry coding base - freetype + Freetype::Freetype vulkan_wrapper stb_image sdf_image - icu + ICU::i18n expat $<$:-framework\ OpenGL> $<$:OpenGL::GL> diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index b3057b0d3e..166ad928e9 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -54,7 +54,6 @@ #include "platform/platform.hpp" #include "coding/endianness.hpp" -#include "coding/transliteration.hpp" #include "base/file_name_utils.hpp" #include "base/timer.hpp" diff --git a/generator/pygen/CMakeLists.txt b/generator/pygen/CMakeLists.txt index cfa4e82909..4f26910972 100644 --- a/generator/pygen/CMakeLists.txt +++ b/generator/pygen/CMakeLists.txt @@ -29,7 +29,7 @@ omim_link_libraries( opening_hours freetype expat - icu + ICU::i18n jansson protobuf bsdiff diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index 5813657aa9..ea4826b20f 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -5,8 +5,6 @@ #include "coding/transliteration.hpp" -#include "coding/transliteration.hpp" - #include "base/assert.hpp" #include "base/dfa_helpers.hpp" #include "base/macros.hpp" diff --git a/indexer/transliteration_loader.cpp b/indexer/transliteration_loader.cpp index 5eaec80f87..098bd9106a 100644 --- a/indexer/transliteration_loader.cpp +++ b/indexer/transliteration_loader.cpp @@ -12,23 +12,24 @@ void InitTransliterationInstanceWithDefaultDirs() { + Platform const & pl = GetPlatform(); + #if defined(OMIM_OS_ANDROID) char const kICUDataFile[] = "icudt70l.dat"; - if (!GetPlatform().IsFileExistsByFullPath(GetPlatform().WritableDir() + kICUDataFile)) + if (!pl.IsFileExistsByFullPath(pl.WritableDir() + kICUDataFile)) { try { - ZipFileReader::UnzipFile(GetPlatform().ResourcesDir(), std::string("assets/") + kICUDataFile, - GetPlatform().WritableDir() + kICUDataFile); + ZipFileReader::UnzipFile(pl.ResourcesDir(), std::string("assets/") + kICUDataFile, + pl.WritableDir() + kICUDataFile); } catch (RootException const & e) { - LOG(LWARNING, - ("Can't get transliteration data file \"", kICUDataFile, "\", reason:", e.Msg())); + LOG(LWARNING, ("Can't get transliteration data file \"", kICUDataFile, "\", reason:", e.Msg())); } } - Transliteration::Instance().Init(GetPlatform().WritableDir()); + Transliteration::Instance().Init(pl.WritableDir()); #else - Transliteration::Instance().Init(GetPlatform().ResourcesDir()); + Transliteration::Instance().Init(pl.ResourcesDir()); #endif } diff --git a/kml/pykmlib/CMakeLists.txt b/kml/pykmlib/CMakeLists.txt index 6fa9119332..e85481054d 100644 --- a/kml/pykmlib/CMakeLists.txt +++ b/kml/pykmlib/CMakeLists.txt @@ -19,7 +19,7 @@ omim_link_libraries( coding geometry base - icu + ICU::i18n jansson oauthcpp protobuf diff --git a/map/framework.cpp b/map/framework.cpp index ee83525f2c..c0c0d9c268 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -412,7 +412,7 @@ Framework::Framework(FrameworkParams const & params) m_featuresFetcher.GetDataSource().AddObserver(editor); - LOG(LINFO, ("Editor initialized")); + LOG(LDEBUG, ("Editor initialized")); m_trafficManager.SetCurrentDataVersion(m_storage.GetCurrentDataVersion()); m_trafficManager.SetSimplifiedColorScheme(LoadTrafficSimplifiedColors()); diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 0fa43501e3..3b051caf7c 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -129,7 +129,6 @@ copy_resources( unicode_blocks.txt World.mwm WorldCoasts.mwm - icudt70l.dat 00_NotoNaskhArabic-Regular.ttf 00_NotoSansThai-Regular.ttf @@ -142,11 +141,16 @@ copy_resources( 07_roboto_medium.ttf ) +if (NOT PLATFORM_LINUX) + # On Linux, ICU data is loaded from the shared library. + copy_resources(icudt70l.dat) +endif() + if (PLATFORM_MAC) execute_process( COMMAND cp -r ${OMIM_ROOT}/tools/shaders_compiler/macos ${RESOURCES_FOLDER}/shaders_compiler ) -elseif(PLATFORM_LINUX) +elseif (PLATFORM_LINUX) execute_process( COMMAND cp -r ${OMIM_ROOT}/tools/shaders_compiler/linux ${RESOURCES_FOLDER}/shaders_compiler ) diff --git a/search/pysearch/CMakeLists.txt b/search/pysearch/CMakeLists.txt index 310667edd5..cc460b7f21 100644 --- a/search/pysearch/CMakeLists.txt +++ b/search/pysearch/CMakeLists.txt @@ -24,7 +24,7 @@ omim_link_libraries( coding base bsdiff - icu + ICU::i18n jansson oauthcpp opening_hours diff --git a/traffic/pytraffic/CMakeLists.txt b/traffic/pytraffic/CMakeLists.txt index ad93d24e7a..cab110c81a 100644 --- a/traffic/pytraffic/CMakeLists.txt +++ b/traffic/pytraffic/CMakeLists.txt @@ -42,7 +42,7 @@ omim_link_libraries( pugixml opening_hours succinct - icu + ICU::i18n ${Boost_LIBRARIES} ${LIBZ} )