cmake: rewrite ENCHANT and Taglib modules

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-03-25 02:05:59 +00:00
parent bc06c619e3
commit 1bf96c14b0
3 changed files with 68 additions and 73 deletions

View file

@ -1,47 +1,51 @@
# - Try to find the Enchant spell checker
#
# Once done this will define
#
# ENCHANT_FOUND - system has ENCHANT
# ENCHANT_INCLUDE_DIR - the ENCHANT include directory
# ENCHANT_LIBRARIES - Link these to use ENCHANT
# ENCHANT_DEFINITIONS - Compiler switches required for using ENCHANT
# Copyright (c) 2006, Zack Rusin, <zack@kde.org>
# ENCHANT_LIBRARIES - the libraries needed to use ENCHANT
# ENCHANT_DEFINITIONS - compiler switches required for using ENCHANT
#
# Copyright (c) 2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
set(ENCHANT_NAMES enchant-2 enchant)
if (ENCHANT_INCLUDE_DIR AND ENCHANT_LIBRARIES)
# in cache already
set(ENCHANT_FOUND TRUE)
else (ENCHANT_INCLUDE_DIR AND ENCHANT_LIBRARIES)
if (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if(NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(PC_ENCHANT QUIET enchant-2)
if (NOT PC_ENCHANT_FOUND)
pkg_check_modules(PC_ENCHANT QUIET enchant)
endif()
set(ENCHANT_DEFINITIONS ${PC_ENCHANT_CFLAGS_OTHER})
endif (NOT WIN32)
foreach(name ${ENCHANT_NAMES})
if(NOT PC_ENCHANT_FOUND)
pkg_check_modules(PC_ENCHANT QUIET ${name})
find_path(ENCHANT_INCLUDE_DIR
NAMES enchant++.h
HINTS ${PC_ENCHANT_INCLUDEDIR}
${PC_ENCHANT_INCLUDE_DIRS}
PATH_SUFFIXES enchant )
set(ENCHANT_INCLUDE_DIR ${PC_ENCHANT_INCLUDE_DIRS})
set(ENCHANT_LIBRARIES ${PC_ENCHANT_LIBRARIES})
endif()
endforeach()
endif()
find_library(ENCHANT_LIBRARIES NAMES enchant-2 enchant
HINTS ${PC_ENCHANT_LIBDIR}
${PC_ENCHANT_LIBRARY_DIRS} )
set(ENCHANT_VERSION ${PC_ENCHANT_VERSION})
set(ENCHANT_DEFINITIONS ${PC_ENCHANT_CFLAGS_OTHER})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ENCHANT DEFAULT_MSG ENCHANT_INCLUDE_DIR ENCHANT_LIBRARIES )
if(NOT ENCHANT_INCLUDE_DIR OR NOT ENCHANT_LIBRARIES)
find_path(ENCHANT_INCLUDE_DIR
NAMES enchant++.h
PATH_SUFFIXES ${ENCHANT_NAMES}
HINTS $ENV{ENCHANTDIR}/include
)
mark_as_advanced(ENCHANT_INCLUDE_DIR ENCHANT_LIBRARIES)
find_library(ENCHANT_LIBRARIES
NAMES ${ENCHANT_NAMES}
HINTS $ENV{ENCHANTDIR}/lib
)
endif()
endif (ENCHANT_INCLUDE_DIR AND ENCHANT_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ENCHANT
VERSION_VAR ENCHANT_VERSION
REQUIRED_VARS ENCHANT_LIBRARIES ENCHANT_INCLUDE_DIR
)
mark_as_advanced(ENCHANT_INCLUDE_DIR ENCHANT_LIBRARIES)

View file

@ -11,7 +11,6 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_LIBSPECTRE QUIET libspectre)

View file

@ -1,52 +1,44 @@
# - Try to find the Taglib library
# - Try to find the Taglib
#
# Once done this will define
#
# TAGLIB_FOUND - system has the taglib library
# TAGLIB_CFLAGS - the taglib cflags
# TAGLIB_LIBRARIES - The libraries needed to use taglib
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
# TAGLIB_FOUND - system has Taglib
# TAGLIB_LIBRARIES - the libraries needed to use Taglib
# TAGLIB_CFLAGS - the Taglib C flags
#
# Copyright (c) 2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(NOT TAGLIB_MIN_VERSION)
set(TAGLIB_MIN_VERSION "1.4")
endif(NOT TAGLIB_MIN_VERSION)
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_TAGLIB QUIET taglib)
#reset vars
set(TAGLIB_LIBRARIES)
set(TAGLIB_CFLAGS)
set(TAGLIB_INCLUDE_DIR ${PC_TAGLIB_INCLUDE_DIRS})
set(TAGLIB_LIBRARY ${PC_TAGLIB_LIBRARIES})
endif()
set(TAGLIB_VERSION ${PC_TAGLIB_VERSION})
set(TAGLIB_CFLAGS ${PC_TAGLIB_CFLAGS_OTHER})
if(NOT TAGLIB_INCLUDES OR NOT TAGLIB_LIBRARIES)
find_path(TAGLIB_INCLUDES
NAMES tag.h
PATH_SUFFIXES taglib
HINTS $ENV{TAGLIBDIR}/include
)
find_library(TAGLIB_LIBRARIES
NAMES tag
HINTS $ENV{TAGLIBDIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_path(TAGLIB_INCLUDES
NAMES
tag.h
PATH_SUFFIXES taglib
PATHS
${KDE4_INCLUDE_DIR}
${INCLUDE_INSTALL_DIR}
find_package_handle_standard_args(Taglib
VERSION_VAR TAGLIB_VERSION
REQUIRED_VARS TAGLIB_LIBRARIES TAGLIB_INCLUDES
)
find_library(TAGLIB_LIBRARIES
NAMES tag
PATHS
${KDE4_LIB_DIR}
${LIB_INSTALL_DIR}
)
find_package_handle_standard_args(Taglib DEFAULT_MSG
TAGLIB_INCLUDES TAGLIB_LIBRARIES
)
if(TAGLIB_FOUND)
if(NOT Taglib_FIND_QUIETLY AND TAGLIB_LIBRARIES)
message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
endif()
else(TAGLIB_FOUND)
if(Taglib_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Taglib")
endif()
endif(TAGLIB_FOUND)
mark_as_advanced(TAGLIB_INCLUDES TAGLIB_LIBRARIES)