Chris Hillery has proposed merging lp:~zorba-coders/zorba/find-icu-version into 
lp:zorba.

Requested reviews:
  Chris Hillery (ceejatec)
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/find-icu-version/+merge/103197
-- 
https://code.launchpad.net/~zorba-coders/zorba/find-icu-version/+merge/103197
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'cmake_modules/FindICU.cmake'
--- cmake_modules/FindICU.cmake	2012-04-23 10:46:38 +0000
+++ cmake_modules/FindICU.cmake	2012-04-24 01:16:23 +0000
@@ -51,6 +51,38 @@
   MESSAGE(STATUS "Could not find ICU library")
 endif (ICU_LIBRARY)
 
+# Discover the version.
+IF (NOT ICU_INCLUDE STREQUAL "")
+  FIND_PATH(ICUVERHPPPATH NAMES unicode/fuvernum.h PATHS ${ICU_INCLUDE}
+    NO_DEFAULT_PATH)
+
+  IF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
+    SET(ICU_VERSION "0")
+    MESSAGE(STATUS "Found ICU but unable to determine version - assuming version 0")
+  ELSE( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
+    FILE(READ ${ICUVERHPPPATH}/unicode/uvernum.h ICUVERHPP)
+  
+    STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MAJOR_NUM +[0-9]+" ICUVERMAJ 
+      ${ICUVERHPP}) 
+    STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MINOR_NUM +[0-9]+" ICUVERMIN 
+      ${ICUVERHPP})
+    STRING(REGEX
+      MATCH "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +[0-9]+" ICUVERPATCH 
+      ${ICUVERHPP})
+  
+    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MAJOR_NUM +" "" 
+      ICUVERMAJ ${ICUVERMAJ})
+    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MINOR_NUM +" "" 
+      ICUVERMIN ${ICUVERMIN})
+    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +" "" 
+      ICUVERPATCH ${ICUVERPATCH})
+  
+    SET(ICU_VERSION ${ICUVERMAJ}.${ICUVERMIN}.${ICUVERPATCH})
+    MESSAGE(STATUS "ICU Version: ${ICU_VERSION}")
+  
+  ENDIF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
+ENDIF (NOT ICU_INCLUDE STREQUAL "")
+
 
 # Copy the results to the output variables.
 if(ICU_INCLUDE AND ICU_LIBRARY)
@@ -107,4 +139,5 @@
   set(ICU_I18N_LIBRARIES)
   set(ICU_DATA_LIBRARIES)
   set(ICU_INCLUDE_DIRS)
+  set(ICU_VERSION 0)
 endif(ICU_INCLUDE AND ICU_LIBRARY)

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to