support ICU as Qt4 does

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2015-12-13 06:26:59 +02:00
parent fc9d1b36ef
commit 8e4381e946
3 changed files with 51 additions and 2 deletions

View file

@ -82,6 +82,9 @@ add_feature_info(fontconfig WITH_FONTCONFIG "an open source something")
option(WITH_FREETYPE "Build freetype2 support" ON)
add_feature_info(freetype2 WITH_FREETYPE "an open source something")
option(WITH_ICU "Build icu support" ON)
add_feature_info(icu WITH_ICU "an open source something")
# TODO: enable when building against external harfbuzz works
option(WITH_HARFBUZZ "Build harfbuzz support" OFF)
add_feature_info(harfbuzz WITH_HARFBUZZ "an open source something")
@ -297,6 +300,14 @@ set_package_properties(Freetype PROPERTIES
TYPE RECOMMENDED
)
find_package(ICU)
set_package_properties(ICU PROPERTIES
PURPOSE "ICU locales support"
DESCRIPTION "Mature, widely used libraries providing Unicode and Globalization support"
URL "http://site.icu-project.org/"
TYPE RECOMMENDED
)
# currently unused
find_package(HarfBuzz)
set_package_properties(HarfBuzz PROPERTIES

View file

@ -0,0 +1,39 @@
# - Try to find International Components for Unicode
# Once done this will define
#
# ICU_FOUND - system has ICU
# ICU_INCLUDES - the ICU include directory
# ICU_LIBRARIES - The libraries needed to use ICU
#
# Copyright (c) 2015, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
if(ICU_INCLUDES AND ICU_LIBRARIES)
set(ICU_FIND_QUIETLY TRUE)
endif()
find_path(ICU_INCLUDES
NAMES
unistr.h
PATH_SUFFIXES unicode
HINTS
$ENV{ICUDIR}/include
/usr/include
/usr/local/include
${INCLUDE_INSTALL_DIR}
)
find_library(ICU_LIBRARIES
icui18n
HINTS
$ENV{ICUDIR}/lib
/usr/lib
/usr/local/lib
${LIB_INSTALL_DIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ICU DEFAULT_MSG ICU_INCLUDES ICU_LIBRARIES)
mark_as_advanced(ICU_INCLUDES ICU_LIBRARIES)

View file

@ -133,8 +133,7 @@ else()
)
endif()
# TODO: look for ICU package
if(ICU_FOUND)
if(WITH_ICU AND ICU_FOUND)
set(CORE_SOURCES
${CORE_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/tools/qlocale_icu.cpp