[CMake] [BSD-2] CMake module to find ICU

Overview

FindICU.cmake

A CMake module to find International Components for Unicode (ICU) Library

Note that CMake, since its version 3.7.0, includes a FindICU module that does NOT work in the same way at all (they are not compatible). Make sure, if you use the present module, to include it and give it the priority by redefining CMAKE_MODULE_PATH accordingly.

Information

Prerequisites

Only one:

  • CMake >= 2.8.3 (for new version of find_package_handle_standard_args)
  • CMake >= 2.8.5 to build static or shared resource bundles

License

License: BSD-2 clause

Usage

Variables set for your project

  • ICU_FOUND: were all of your specified components found?
  • ICU_INCLUDE_DIRS: ICU include directory
  • ICU_LIBRARIES: ICU libraries
  • ICU_VERSION: complete version of ICU (x.y.z)
  • ICU_VERSION_MAJOR: major version of ICU
  • ICU_VERSION_MINOR: minor version of ICU
  • ICU_VERSION_PATCH: patch version of ICU
  • ICU_<COMPONENT>_FOUND: was <COMPONENT> found? (FALSE for non specified component if it is not a dependency)
  • ICU_C_FLAGS: C compiler flags
  • ICU_CXX_FLAGS: C++ compiler flags
  • ICU_CPP_FLAGS: C Preprocessor flags
  • ICU_C_SHARED_FLAGS: C flags for building shared libraries
  • ICU_CXX_SHARED_FLAGS: C++ flags for building shared libraries
  • ICU_CPP_SHARED_FLAGS: C Preprocessor flags for building shared libraries

Note: all ICU_*_FLAGS variables will be defined as empty strings if icu-config does not exist or cannot be found

Functions

Create resource bundles

icu_generate_resource_bundle(
    NAME <name>
    FILES <list of files>
    [ FORMAT <name> ]
    [ PACKAGE ] [ TYPE <name> ] [ DEPENDS <list of dependencies> ] [ NO_SHARED_FLAGS ]
    [ DESTINATION <location> ]
)
  • NAME (string): mandatory, name of package (used to name dummy targets and output file)
  • PACKAGE (boolean): mandatory to package the resource bundles into an archive or library (static as dynamic)
  • FILES (;-list of strings): the text files to "compile" into resource bundles
  • TYPE (string): implies PACKAGE to be present. Value is one among:
    • default: "common" (other name: "archive") to package the resource bundles as a .dat file
    • "static" to integrate all ressource bundles to targets designed by DEPENDS parameter (as a static library)
    • "library" (other name: "dll") to assemble all ressource bundles into a separate and loadable library (.dll/.so)
  • DEPENDS (;-list of strings): only when TYPE is "library", "dll" or "static", a list of targets (add_executable for example) to link to
  • FORMAT (string): default is ICU4C binary format, else one of "java" of "xliff"
  • NO_SHARED_FLAGS (boolean): if set, skip appending ICU_C(XX)_SHARED_FLAGS to each target given as DEPENDS (only when TYPE is "static", "library" or "dll")
  • DESTINATION (string): a directory where to install output files

See tests/RB/c_*pkg* for examples.

How to use

For developpers

  • You just need to copy the file FindICU.cmake at top of your project directory (you don't need sources for tests)
  • Tell to CMake to search this non-standard module in your project directory by adding near top to your CMakeLists.txt: set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
  • Just after, call find_package() once: find_package(ICU)

Notes:

  • if ICU is required by your project, append the keyword REQUIRED (find_package(ICU REQUIRED)). On the opposite, if ICU is optional, the keyword QUIET can be used to silently try to find ICU.
  • for a project which depends on a minimum version of ICU, add it just after 'ICU' (eg mandatory ICU >= 4.4: find_package(ICU 4.4 REQUIRED))
  • note that ICU is a set of several libraries and by default, you only link to the ICU's base component called uc. To link to any additionnal part of ICU, you have to list them behind the COMPONENTS keyword (eg: find_package(ICU COMPONENTS io i18n)). If not, you will issue linking (undefined symbol) errors. These components are:
    • the uc base (Unicode) component (string, case, normalisation, breakiterator) is always enabled (it can safely be omitted from COMPONENTS)
    • the io component is needed if you use ustdio (C) or ustream (C++). Note: io rely on i18n, its use imply to add i18n to COMPONENTS
    • the i18n component is required for charset conversions, formatting, collation, string search, transliteration, regexp, calendar/timezone
    • the le/lx for LayoutEngine/ParagraphLayout

For end users

If ICU is located in a non-regular place, add a -DICU_ROOT_DIR=<PATH> option to your cmake command line.

Sample

For a binary which implies ICU >= 4.4:

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
find_package(ICU 4.4 COMPONENTS io i18n REQUIRED)

include_directories(${ICU_INCLUDE_DIRS})

add_executable(tables tables.c)
target_link_libraries(tables ${ICU_LIBRARIES})

For CMake >= 3.0.0, you can also use an imported target. The same example becomes:

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
find_package(ICU 4.4 COMPONENTS io i18n REQUIRED)

add_executable(tables tables.c)
target_link_libraries(tables ICU::ICU)
Issues
  • genrb not found crashes CMake

    genrb not found crashes CMake

    I've experienced this issue on Fedora Core 23 and an RHEL system. CMake Error at /various/directories/cmake/FindICU.cmake:329 (message): genrb not found Call Stack (most recent call first): CMakeLists.txt:11 (find_package)

    make: *** No targets specified and no makefile found. Stop.

    My find_package does not say that ICU is required, so it seems undesirable for CMake to exit. Here is my line from CMakeLists.txt: find_package(ICU COMPONENTS i18n)

    On a Red Hat or derived system, it appears that the libicu package has the shared libraries, the libicu-devel package has the headers, and the icu package has genrb. For my C++ project, it seems that I only need libicu-devel and libicu installed, so it would be nice if FindICU.cmake didn't fail if genrb isn't found.

    Thanks!

    opened by tepperly 3
  • No full text license, means debian undistributable

    No full text license, means debian undistributable

    Hi,

    I need the full text license in order to distribute your package for debian.

    And also use your full name (pseudonym are not allowed). jlup is not a french société so I could not include under debian.

    In french: Je ne peux pas distribuer si c'est un pseudonyme. Si tu veux garder ton anonymat cree une association ou affecte ton code à une association... Mais la je peux rien faire.

    opened by bastien-roucaries 1
Owner
julp
Main languages: * C * PHP * Elixir * CMake DBMS: * MySQL * PostgreSQL Sensitizations: * security * Unicode Development platform: FreeBSD
julp
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 77 Jul 3, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 72 Apr 14, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
CMake module for downloading an external project's source at configure time

DownloadProject Platform Build status Linux Mac OSX Windows (VS2015) This repository contains a generalized implementation for downloading an external

Crascit Pty Ltd 426 Aug 9, 2022
CMake module to speed up builds.

cotire Cotire (compile time reducer) is a CMake module that speeds up the build process of CMake based build systems by fully automating techniques as

Sascha Kratky 1.3k Aug 11, 2022
CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp

FindIDL CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp. Introduction Requirements Usage find_package() add_idl() ad

Apriorit Inc. 16 Jul 26, 2022
CMake module for building Windows Installer packages with WiX toolset

FindWiX CMake module for building Windows Installer packages with WiX toolset Introduction Requirements Usage find_package() wix_add_project() WiX com

Apriorit Inc. 11 Aug 5, 2022
CMake module for Mathematica.

FindMathematica FindMathematica is a CMake module that tries to find a Wolfram Language installation and provides CMake functions for its C/C++ interf

Sascha Kratky 50 Jul 31, 2022
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Setup-free CMake dependency management CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper

CPM.cmake 1.3k Aug 7, 2022
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 59 Jul 7, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 385 Aug 2, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 37 Dec 30, 2021
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 156 Jun 20, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 105 Jul 18, 2022
custom lua godot engine module

Godot Lua Module Table of contents: About Features TODO Compiling Examples Contributing And Feature Requests About This is a Godot engine module that

Trey Moller 44 Jul 21, 2022
CMake project for BL602 RISC-V processor

bl602_cmake_base CMake project for BL602 RISC-V processor How to build NOTE : This project uses a pre-compiled version of the Buffalo SDK (bl_iot_sdk)

null 9 Jan 6, 2022
A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

Alexander Widerberg 1.3k Aug 13, 2022
NeoWorld is a resampler using the CMake build system

NeoWorld is a resampler using the CMake build system. It's designed for utsu, OpenUTAU, and UTAU.

null 4 Jun 24, 2022
A CMake addon that avoids you writing boilerplate code for resource management.

SHader INJ(I)ector SHINJI (originally SHader INJector) is a CMake addon that avoids you writing boilerplate code for resource management and exposes s

Lorenzo Rutayisire 6 Mar 21, 2022