cmake: rewrite Eigen3 and Exiv2 modules

note that Eigen3 does not provide a library. also everywhere Exiv2 package
is searched for a minimum version is specified and is newer than 0.12

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-02-25 18:07:49 +00:00
parent f0511e043c
commit 7ce7242ba9
3 changed files with 55 additions and 124 deletions

View file

@ -1,81 +1,36 @@
# - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
# - Try to find Eigen3
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
# EIGEN3_FOUND - system has Eigen3
# EIGEN3_INCLUDE_DIR - the Eigen3 include directory
#
# 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.
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_EIGEN3 QUIET eigen3)
if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
set(EIGEN3_INCLUDE_DIR ${PC_EIGEN3_INCLUDE_DIRS})
endif()
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
set(EIGEN3_VERSION ${PC_EIGEN3_VERSION})
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
if(NOT EIGEN3_VERSION_OK)
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
if (EIGEN3_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
else (EIGEN3_INCLUDE_DIR)
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
PATHS
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
if(NOT EIGEN3_INCLUDE_DIR)
find_path(EIGEN3_INCLUDE_DIR
NAMES signature_of_eigen3_matrix_library
PATH_SUFFIXES eigen3 eigen
HINTS $ENV{EIGEN3DIR}/include
)
endif()
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN3_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
mark_as_advanced(EIGEN3_INCLUDE_DIR)
endif(EIGEN3_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3
VERSION_VAR EIGEN3_VERSION
REQUIRED_VARS EIGEN3_INCLUDE_DIR
)
mark_as_advanced(EIGEN3_INCLUDE_DIR)

View file

@ -1,69 +1,44 @@
# - Try to find the Exiv2 library
#
# EXIV2_MIN_VERSION - You can set this variable to the minimum version you need
# before doing FIND_PACKAGE(Exiv2). The default is 0.12.
# - Try to find Exiv2 library
#
# Once done this will define
#
# EXIV2_FOUND - system has libexiv2
# EXIV2_INCLUDE_DIR - the libexiv2 include directory
# EXIV2_LIBRARIES - Link these to use libexiv2
# EXIV2_DEFINITIONS - Compiler switches required for using libexiv2
# EXIV2_FOUND - system has Exiv2
# EXIV2_INCLUDE_DIR - the Exiv2 include directory
# EXIV2_LIBRARIES - the libraries needed to use Exiv2
# EXIV2_DEFINITIONS - compiler switches required for using Exiv2
#
# The minimum required version of Exiv2 can be specified using the
# standard syntax, e.g. find_package(Exiv2 0.17)
#
# For compatibility, also the variable EXIV2_MIN_VERSION can be set to the minimum version
# you need before doing FIND_PACKAGE(Exiv2). The default is 0.12.
# Copyright (c) 2010, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2008, Gilles Caulier, <caulier.gilles@gmail.com>
# 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.
# Support EXIV2_MIN_VERSION for compatibility:
if(NOT Exiv2_FIND_VERSION)
set(Exiv2_FIND_VERSION "${EXIV2_MIN_VERSION}")
endif(NOT Exiv2_FIND_VERSION)
# the minimum version of exiv2 we require
if(NOT Exiv2_FIND_VERSION)
set(Exiv2_FIND_VERSION "0.12")
endif(NOT Exiv2_FIND_VERSION)
if(NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
include(FindPkgConfig)
pkg_check_modules(PC_EXIV2 QUIET exiv2)
set(EXIV2_DEFINITIONS ${PC_EXIV2_CFLAGS_OTHER})
set(EXIV2_VERSION ${PC_EXIV2_VERSION})
set(EXIV2_INCLUDE_DIR ${PC_EXIV2_INCLUDE_DIRS})
set(EXIV2_LIBRARIES ${PC_EXIV2_LIBRARIES})
endif()
set(EXIV2_VERSION ${PC_EXIV2_VERSION})
set(EXIV2_DEFINITIONS ${PC_EXIV2_CFLAGS_OTHER})
find_path(EXIV2_INCLUDE_DIR
NAMES
exiv2/exif.hpp
HINTS
${PC_EXIV2_INCLUDEDIR}
${PC_EXIV2_INCLUDE_DIRS}
)
if(NOT EXIV2_INCLUDE_DIR OR NOT EXIV2_LIBRARIES)
find_path(EXIV2_INCLUDE_DIR
NAMES exiv2/exif.hpp
HINTS $ENV{EXIV2DIR}/include
)
find_library(EXIV2_LIBRARY
NAMES
exiv2
libexiv2
HINTS
${PC_EXIV2_LIBDIR}
${PC_EXIV2_LIBRARY_DIRS}
)
set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}")
find_library(EXIV2_LIBRARIES
NAMES exiv2
HINTS $ENV{EXIV2DIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Exiv2 REQUIRED_VARS EXIV2_LIBRARY EXIV2_INCLUDE_DIR
VERSION_VAR EXIV2_VERSION)
mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARY)
find_package_handle_standard_args(Exiv2
VERSION_VAR EXIV2_VERSION
REQUIRED_VARS EXIV2_LIBRARIES EXIV2_INCLUDE_DIR
)
mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARIES)

View file

@ -1,11 +1,12 @@
# - Try to find IBUS
#
# Once done this will define
#
# IBUS_FOUND - system has IBUS
# IBUS_INCLUDE_DIR - the IBUS include directory
# IBUS_LIBRARIES - the libraries needed to use IBUS
# IBUS_DEFINITIONS - compiler switches required for using IBUS
#
# Copyright (c) 2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.