Skip to content

[SR-1358] Improved FindICU.cmake for more systems and static linking #43967

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-1358
Radar None
Original Reporter ewmailing (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement, Android, CMake, ICU, Linux
Assignee None
Priority Medium

md5: 57487fce257e295f9be5f65704802b72

Issue Description:

This patch modifies FindICU.cmake and a few other files to support more systems and more configurations.

The existing ICU infrastructure was insufficient for multiple things.

  • It relied on pkg-config, which is problematic on systems that don't
    ship pkg-config (e.g. Ubuntu 12.04, Windows?)
  • It didn't allow an easy way for specifying alternative locations for ICU
    which is needed if you need to supply a non-system installed version.
    This form is also useful when you want to supply a static library
    version. (I will be submitting related issues about Android and SteamOS.)
  • It didn't handle linking when ICU was a static library. (libicudata is
    needed)
  • pkg-config also doesn't handle libicudata
  • pkg-config also can present problems for cross-compiling. (Android was
    also taken into account for this patch.)

This change fixes all these problems so Swift can be built on systems
like SteamOS/Steam-Runtime which don't supply libICU (and is based on
Ubuntu 12.04 which lacks a pkg-config). This allows you to supply
some other libICU which is a static library, and the Swift build system
will do the right thing. (It does not force static linking. So if you want static linking, only provide the static library.)

An explicit setting of ICU_ROOT (cmake -DICU_ROOT=/path/to/icu_root) or
setting an environmental variable called ICU_ROOT will allow alternative
paths to be searched.

I do want to point out that there is a popular FindICU.cmake floating out there that already handles this stuff and is pretty mature. I’m wondering a bit why you rewrote this from scratch considering ICU is a non-trivial library to deal with.

My patch is here:
ewmailing@f9cbb94

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions