Merge lp:~zorba-coders/zorba/find-icu-version into lp:zorba

Proposed by Chris Hillery
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 10792
Merged at revision: 10794
Proposed branch: lp:~zorba-coders/zorba/find-icu-version
Merge into: lp:zorba
Diff against target: 59 lines (+44/-0)
1 file modified
cmake_modules/FindICU.cmake (+44/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/find-icu-version
Reviewer Review Type Date Requested Status
Paul J. Lucas Approve
Chris Hillery Approve
Review via email: mp+103197@code.launchpad.net

Commit message

Set ICU_VERSION when finding ICU.

To post a comment you must log in.
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Older ICU versions don't have the uvernum.h header -- they used to use (just) uversion.h. Hence, your patch won't work on older versions (including 3.8.1 which is what the remote queue machine is running) which kind of defeats the point.

Why not use the icu-config --version command?

Revision history for this message
Chris Hillery (ceejatec) wrote :

Well, that's annoying. The comment in uvernum.h said that the #define was "stable" since 2.4, but I guess that doesn't include the file it's defined in.

I didn't use icu-config because the existing FindICU.cmake doesn't find the executables, only the include files and libraries. I don't know enough about ICU to know whether there are any complications in finding the binaries as well (there's several things that are different about finding the data files on cygwin, for instance).

If you can tell me how to find icu-config reliably, I'll change it; otherwise I guess I'll try to read either uvernum.h or uversion.h.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job find-icu-version-2012-04-24T01-24-59.02Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Approve, 1 Pending.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

I have no idea about finding the path to icu-config. I suppose try to read uvernum.h first -- if that fails, read uversion.h.

Revision history for this message
Chris Hillery (ceejatec) wrote :

Looking in either header file now.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job find-icu-version-2012-04-24T08-05-16.704Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Approve, 1 Pending.

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job find-icu-version-2012-04-24T14-04-59.969Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake_modules/FindICU.cmake'
2--- cmake_modules/FindICU.cmake 2012-04-23 10:46:38 +0000
3+++ cmake_modules/FindICU.cmake 2012-04-24 08:05:23 +0000
4@@ -51,6 +51,49 @@
5 MESSAGE(STATUS "Could not find ICU library")
6 endif (ICU_LIBRARY)
7
8+# Discover the version.
9+IF (NOT ICU_INCLUDE STREQUAL "")
10+ # ICU 3.x has the relevant #defines in uversion.h; 4.x uses uvernum.h.
11+ FIND_PATH(ICUVERHPPPATH NAMES unicode/uvernum.h unicode/uversion.h
12+ PATHS ${ICU_INCLUDE} NO_DEFAULT_PATH)
13+
14+ IF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
15+ SET(ICU_VERSION "0")
16+ MESSAGE(STATUS "Found ICU but unable to determine version - assuming version 0")
17+ ELSE( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
18+ SET (ICUVERHPP)
19+ # One of these files has to exist, or else ICUVERHPPPATH wouldn't be set.
20+ # If uvernum.h exists, it has the data we want; otherwise, that data is
21+ # in uversion.h.
22+ FOREACH (header uvernum.h uversion.h)
23+ SET (headerfile "${ICUVERHPPPATH}/unicode/${header}")
24+ IF (EXISTS "${headerfile}")
25+ FILE(READ "${headerfile}" ICUVERHPP)
26+ BREAK()
27+ ENDIF (EXISTS "${headerfile}")
28+ ENDFOREACH (header)
29+
30+ STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MAJOR_NUM +[0-9]+" ICUVERMAJ
31+ ${ICUVERHPP})
32+ STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MINOR_NUM +[0-9]+" ICUVERMIN
33+ ${ICUVERHPP})
34+ STRING(REGEX
35+ MATCH "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +[0-9]+" ICUVERPATCH
36+ ${ICUVERHPP})
37+
38+ STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MAJOR_NUM +" ""
39+ ICUVERMAJ ${ICUVERMAJ})
40+ STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MINOR_NUM +" ""
41+ ICUVERMIN ${ICUVERMIN})
42+ STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +" ""
43+ ICUVERPATCH ${ICUVERPATCH})
44+
45+ SET(ICU_VERSION ${ICUVERMAJ}.${ICUVERMIN}.${ICUVERPATCH})
46+ MESSAGE(STATUS "ICU Version: ${ICU_VERSION}")
47+
48+ ENDIF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
49+ENDIF (NOT ICU_INCLUDE STREQUAL "")
50+
51
52 # Copy the results to the output variables.
53 if(ICU_INCLUDE AND ICU_LIBRARY)
54@@ -107,4 +150,5 @@
55 set(ICU_I18N_LIBRARIES)
56 set(ICU_DATA_LIBRARIES)
57 set(ICU_INCLUDE_DIRS)
58+ set(ICU_VERSION 0)
59 endif(ICU_INCLUDE AND ICU_LIBRARY)

Subscribers

People subscribed via source and target branches