Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindHSPELL.cmake
1 # - Try to find Hspell
2 # Once done this will define
3 #
4 #  HSPELL_FOUND - system has Hspell
5 #  HSPELL_INCLUDE_DIR - the Hspell include directory
6 #  HSPELL_LIBRARIES - The libraries needed to use Hspell
7 #  HSPELL_DEFINITIONS - Compiler switches required for using Hspell
8 #
9 #  HSPELL_VERSION_STRING - The version of Hspell found (x.y)
10 #  HSPELL_MAJOR_VERSION  - the major version of Hspell
11 #  HSPELL_MINOR_VERSION  - The minor version of Hspell
12
13 #=============================================================================
14 # Copyright 2006-2009 Kitware, Inc.
15 # Copyright 2006 Alexander Neundorf <neundorf@kde.org>
16 #
17 # Distributed under the OSI-approved BSD License (the "License");
18 # see accompanying file Copyright.txt for details.
19 #
20 # This software is distributed WITHOUT ANY WARRANTY; without even the
21 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 # See the License for more information.
23 #=============================================================================
24 # (To distribute this file outside of CMake, substitute the full
25 #  License text for the above reference.)
26
27 find_path(HSPELL_INCLUDE_DIR hspell.h)
28
29 find_library(HSPELL_LIBRARIES NAMES hspell)
30
31 if (HSPELL_INCLUDE_DIR)
32     file(STRINGS "${HSPELL_INCLUDE_DIR}/hspell.h" HSPELL_H REGEX "#define HSPELL_VERSION_M(AJO|INO)R [0-9]+")
33     string(REGEX REPLACE ".*#define HSPELL_VERSION_MAJOR ([0-9]+).*" "\\1" HSPELL_VERSION_MAJOR "${HSPELL_H}")
34     string(REGEX REPLACE ".*#define HSPELL_VERSION_MINOR ([0-9]+).*" "\\1" HSPELL_VERSION_MINOR "${HSPELL_H}")
35     set(HSPELL_VERSION_STRING "${HSPELL_VERSION_MAJOR}.${HSPELL_VERSION_MINOR}")
36     unset(HSPELL_H)
37 endif()
38
39 # handle the QUIETLY and REQUIRED arguments and set HSPELL_FOUND to TRUE if
40 # all listed variables are TRUE
41 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
42 FIND_PACKAGE_HANDLE_STANDARD_ARGS(HSPELL
43                                   REQUIRED_VARS HSPELL_LIBRARIES HSPELL_INCLUDE_DIR
44                                   VERSION_VAR HSPELL_VERSION_STRING)
45
46 mark_as_advanced(HSPELL_INCLUDE_DIR HSPELL_LIBRARIES)
47