1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-04 17:16:26 +00:00
gnss-sdr/cmake/Modules/FindMATIO.cmake

181 lines
6.2 KiB
CMake
Raw Normal View History

2019-02-03 18:24:44 +00:00
# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors)
2018-12-12 00:37:37 +00:00
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
# FindMATIO
#
# Try to find MATIO library
#
# Once done this will define:
#
# MATIO_FOUND - True if MATIO found.
# MATIO_LIBRARIES - MATIO libraries.
# MATIO_INCLUDE_DIRS - where to find matio.h, etc..
# MATIO_VERSION_STRING - version number as a string (e.g.: "1.3.4")
#
2019-02-03 18:24:44 +00:00
# Provides the following imported target:
# Matio::matio
#
2018-12-12 00:37:37 +00:00
#=============================================================================
# Copyright 2015 Avtech Scientific <http://avtechscientific.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * 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.
#
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
# nor the names of their contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
# HOLDER 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(NOT COMMAND feature_summary)
include(FeatureSummary)
endif()
2018-12-12 00:37:37 +00:00
# Look for the header file.
find_path(MATIO_INCLUDE_DIR
NAMES matio.h
HINTS
${MATIO_ROOT}/include
$ENV{MATIO_ROOT}/include
DOC "The MATIO include directory"
)
# Look for the library.
find_library(MATIO_LIBRARY
NAMES matio
HINTS
${MATIO_ROOT}/lib
$ENV{MATIO_ROOT}/lib
${MATIO_ROOT}/lib64
$ENV{MATIO_ROOT}/lib64
/usr/lib/alpha-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/aarch64-linux-gnu
/usr/lib/arm-linux-gnueabi
/usr/lib/arm-linux-gnueabihf
/usr/lib/hppa-linux-gnu
/usr/lib/i386-linux-gnu
/usr/lib/m68k-linux-gnu
/usr/lib/mips-linux-gnu
/usr/lib/mips64el-linux-gnuabi64
/usr/lib/mipsel-linux-gnu
/usr/lib/powerpc-linux-gnuspe
/usr/lib/powerpc64-linux-gnu
/usr/lib/powerpc64le-linux-gnu
/usr/lib/riscv64-linux-gnu
/usr/lib/s390x-linux-gnu
/usr/lib/sh4-linux-gnu
/usr/lib/sparc64-linux-gnu
/usr/lib/x86_64-linux-gnux32
/usr/lib/x86_64-kfreebsd-gnu
/usr/lib/i386-kfreebsd-gnu
2018-12-12 00:37:37 +00:00
DOC "The MATIO library"
)
if(MATIO_INCLUDE_DIR)
# ---------------------------------------------------
# Extract version information from MATIO
# ---------------------------------------------------
# If the file is missing, set all values to 0
set(MATIO_MAJOR_VERSION 0)
set(MATIO_MINOR_VERSION 0)
set(MATIO_RELEASE_LEVEL 0)
# new versions of MATIO have `matio_pubconf.h`
if(EXISTS ${MATIO_INCLUDE_DIR}/matio_pubconf.h)
set(MATIO_CONFIG_FILE "matio_pubconf.h")
else()
set(MATIO_CONFIG_FILE "matioConfig.h")
endif()
if(MATIO_CONFIG_FILE)
# Read and parse MATIO config header file for version number
file(STRINGS "${MATIO_INCLUDE_DIR}/${MATIO_CONFIG_FILE}" _matio_HEADER_CONTENTS REGEX "#define MATIO_((MAJOR|MINOR)_VERSION)|(RELEASE_LEVEL) ")
foreach(line ${_matio_HEADER_CONTENTS})
if(line MATCHES "#define ([A-Z_]+) ([0-9]+)")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endif()
endforeach()
unset(_matio_HEADER_CONTENTS)
endif()
set(MATIO_VERSION_STRING "${MATIO_MAJOR_VERSION}.${MATIO_MINOR_VERSION}.${MATIO_RELEASE_LEVEL}")
endif()
mark_as_advanced(MATIO_INCLUDE_DIR MATIO_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MATIO REQUIRED_VARS MATIO_LIBRARY MATIO_INCLUDE_DIR VERSION_VAR MATIO_VERSION_STRING)
if(MATIO_FOUND)
set(MATIO_LIBRARIES ${MATIO_LIBRARY})
set(MATIO_INCLUDE_DIRS ${MATIO_INCLUDE_DIR})
else()
set(MATIO_LIBRARIES)
set(MATIO_INCLUDE_DIRS)
endif()
2019-02-03 18:24:44 +00:00
if(MATIO_FOUND AND MATIO_VERSION_STRING)
set_package_properties(MATIO PROPERTIES
DESCRIPTION "MATLAB MAT File I/O Library (found: v${MATIO_VERSION_STRING})"
)
else()
set_package_properties(MATIO PROPERTIES
DESCRIPTION "MATLAB MAT File I/O Library"
)
endif()
set_package_properties(MATIO PROPERTIES
URL "https://github.com/tbeu/matio"
)
2019-02-03 18:24:44 +00:00
if(MATIO_FOUND AND NOT TARGET Matio::matio)
add_library(Matio::matio SHARED IMPORTED)
set_target_properties(Matio::matio PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${MATIO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MATIO_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${MATIO_LIBRARY}"
)
endif()