浏览代码

FindHSPELL: add version support

Kovarththanan Rajaratnam 15 年之前
父节点
当前提交
810d9a30ef
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      Modules/FindHSPELL.cmake

+ 10 - 0
Modules/FindHSPELL.cmake

@@ -5,6 +5,10 @@
 #  HSPELL_INCLUDE_DIR - the HSPELL include directory
 #  HSPELL_INCLUDE_DIR - the HSPELL include directory
 #  HSPELL_LIBRARIES - The libraries needed to use HSPELL
 #  HSPELL_LIBRARIES - The libraries needed to use HSPELL
 #  HSPELL_DEFINITIONS - Compiler switches required for using HSPELL
 #  HSPELL_DEFINITIONS - Compiler switches required for using HSPELL
+#
+#  HSPELL_VERSION_STRING - The version of Hspell found (x.y)
+#  HSPELL_MAJOR_VERSION  - the major version of Hspell
+#  HSPELL_MINOR_VERSION  - The minor version of Hspell
 
 
 #=============================================================================
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.
 # Copyright 2006-2009 Kitware, Inc.
@@ -24,6 +28,12 @@ FIND_PATH(HSPELL_INCLUDE_DIR hspell.h)
 
 
 FIND_LIBRARY(HSPELL_LIBRARIES NAMES hspell)
 FIND_LIBRARY(HSPELL_LIBRARIES NAMES hspell)
 
 
+IF (HSPELL_INCLUDE_DIR)
+    FILE(READ "${HSPELL_INCLUDE_DIR}/hspell.h" HSPELL_H)
+    STRING(REGEX REPLACE ".*#define HSPELL_VERSION_MAJOR ([0-9]+).*" "\\1" HSPELL_VERSION_MAJOR "${HSPELL_H}")
+    STRING(REGEX REPLACE ".*#define HSPELL_VERSION_MINOR ([0-9]+).*" "\\1" HSPELL_VERSION_MINOR "${HSPELL_H}")
+ENDIF()
+
 # handle the QUIETLY and REQUIRED arguments and set HSPELL_FOUND to TRUE if 
 # handle the QUIETLY and REQUIRED arguments and set HSPELL_FOUND to TRUE if 
 # all listed variables are TRUE
 # all listed variables are TRUE
 INCLUDE(FindPackageHandleStandardArgs)
 INCLUDE(FindPackageHandleStandardArgs)