Commit 012666ff authored by Pino Toscano's avatar Pino Toscano

cmake: rewrite FindHUNSPELL.cmake to use pkg-config

Rewrite the FindHUNSPELL.cmake, mainly to make use of pkg-config:
this way it is easier to adapt to new upstream versions, as the library
name is provided by the pkg-config file.  Also, the switch to
pkg-config gives a different include directory (i.e. directly where
hunspell.hxx is), so adapt lokalize accordingly.

Other changes to the module are:
- drop HUNSPELL_DEFINITIONS, unused
- HUNSPELL_INCLUDE_DIR -> HUNSPELL_INCLUDE_DIRS, like usual convention
- remove the silent/cache handling, it is not needed
- lowercase all the cmake commands
- pick the version from pkg-config
parent 374e6331
......@@ -2,24 +2,52 @@
# Once done this will define
#
# HUNSPELL_FOUND - system has HUNSPELL
# HUNSPELL_INCLUDE_DIR - the HUNSPELL include directory
# HUNSPELL_INCLUDE_DIRS - the HUNSPELL include directory
# HUNSPELL_LIBRARIES - The libraries needed to use HUNSPELL
# HUNSPELL_DEFINITIONS - Compiler switches required for using HUNSPELL
# Copyright (c) 2017, Pino Toscano <pino@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
IF (HUNSPELL_INCLUDE_DIR AND HUNSPELL_LIBRARIES)
# Already in cache, be silent
SET(HUNSPELL_FIND_QUIETLY TRUE)
ENDIF (HUNSPELL_INCLUDE_DIR AND HUNSPELL_LIBRARIES)
FIND_PATH(HUNSPELL_INCLUDE_DIR hunspell/hunspell.hxx )
FIND_LIBRARY(HUNSPELL_LIBRARIES NAMES hunspell-2.0 hunspell-1.6 hunspell-1.5 hunspell-1.4.1 hunspell-1.4 hunspell-1.3 hunspell-1.2 hunspell)
find_package(PkgConfig)
pkg_check_modules(PKG_HUNSPELL QUIET hunspell)
# handle the QUIETLY and REQUIRED arguments and set HUNSPELL_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HUNSPELL DEFAULT_MSG HUNSPELL_LIBRARIES HUNSPELL_INCLUDE_DIR)
find_path(HUNSPELL_INCLUDE_DIRS
NAMES hunspell.hxx
PATH_SUFFIXES hunspell
HINTS ${PKG_HUNSPELL_INCLUDE_DIRS}
)
find_library(HUNSPELL_LIBRARIES
NAMES ${PKG_HUNSPELL_LIBRARIES} hunspell hunspell-1.6 hunspell-1.5 hunspell-1.4 hunspell-1.3 hunspell-1.2
HINTS ${PKG_HUNSPELL_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HUNSPELL
REQUIRED_VARS HUNSPELL_LIBRARIES HUNSPELL_INCLUDE_DIRS
VERSION_VAR PKG_HUNSPELL_VERSION
)
MARK_AS_ADVANCED(HUNSPELL_INCLUDE_DIR HUNSPELL_LIBRARIES)
mark_as_advanced(HUNSPELL_INCLUDE_DIRS HUNSPELL_LIBRARIES)
......@@ -9,7 +9,7 @@ endif(NOT WIN32)
if(HUNSPELL_FOUND)
add_definitions(-DHAVE_HUNSPELL)
include_directories(
${HUNSPELL_INCLUDE_DIR}
${HUNSPELL_INCLUDE_DIRS}
)
endif(HUNSPELL_FOUND)
......
......@@ -40,7 +40,7 @@ QString enhanceLangCode(const QString& langCode)
#ifdef HAVE_HUNSPELL
#include <hunspell/hunspell.hxx>
#include <hunspell.hxx>
#include <QTextCodec>
struct SpellerAndCodec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment