1#.rst: 2# FindOrcania 3# ----------- 4# 5# Find Orcania 6# 7# Find Orcania headers and libraries. 8# 9# :: 10# 11# ORCANIA_FOUND - True if Orcania found. 12# ORCANIA_INCLUDE_DIRS - Where to find orcania.h. 13# ORCANIA_LIBRARIES - List of libraries when using Orcania. 14# ORCANIA_VERSION_STRING - The version of Orcania found. 15 16#============================================================================= 17# Copyright 2018 Silvio Clecio <silvioprog@gmail.com> 18# Copyright 2018 Nicolas Mora <mail@babelouest.org> 19# 20# This program is free software; you can redistribute it and/or 21# modify it under the terms of the GNU Lesser General Public License 22# as published by the Free Software Foundation; 23# version 2.1 of the License. 24# 25# This library is distributed in the hope that it will be useful, 26# but WITHOUT ANY WARRANTY; without even the implied warranty of 27# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28# GNU GENERAL PUBLIC LICENSE for more details. 29# 30# You should have received a copy of the GNU General Public 31# License along with this library. If not, see <http://www.gnu.org/licenses/>. 32#============================================================================= 33 34find_package(PkgConfig QUIET) 35pkg_check_modules(PC_ORCANIA QUIET liborcania) 36 37find_path(ORCANIA_INCLUDE_DIR 38 NAMES orcania.h 39 HINTS ${PC_ORCANIA_INCLUDEDIR} ${PC_ORCANIA_INCLUDE_DIRS}) 40 41find_library(ORCANIA_LIBRARY 42 NAMES orcania liborcania 43 HINTS ${PC_ORCANIA_LIBDIR} ${PC_ORCANIA_LIBRARY_DIRS}) 44 45set(ORCANIA_VERSION_STRING 0.0.0) 46if (PC_ORCANIA_VERSION) 47 set(ORCANIA_VERSION_STRING ${PC_ORCANIA_VERSION}) 48elseif (ORCANIA_INCLUDE_DIR AND EXISTS "${ORCANIA_INCLUDE_DIR}/orcania.h") 49 set(regex_orcania_version "^#define[ \t]+ORCANIA_VERSION[ \t]+([^\"]+).*") 50 file(STRINGS "${ORCANIA_INCLUDE_DIR}/orcania.h" orcania_version REGEX "${regex_orcania_version}") 51 string(REGEX REPLACE "${regex_orcania_version}" "\\1" ORCANIA_VERSION_STRING "${orcania_version}") 52 unset(regex_orcania_version) 53 unset(orcania_version) 54 if (NOT ORCANIA_VERSION_STRING) 55 set(regex_orcania_version "^#define[ \t]+ORCANIA_VERSION[ \t]+([^\"]+).*") 56 file(STRINGS "${ORCANIA_INCLUDE_DIR}/orcania-cfg.h" orcania_version REGEX "${regex_orcania_version}") 57 string(REGEX REPLACE "${regex_orcania_version}" "\\1" ORCANIA_VERSION_STRING "${orcania_version}") 58 unset(regex_orcania_version) 59 unset(orcania_version) 60 endif () 61endif () 62 63include(FindPackageHandleStandardArgs) 64find_package_handle_standard_args(Orcania 65 REQUIRED_VARS ORCANIA_LIBRARY ORCANIA_INCLUDE_DIR 66 VERSION_VAR ORCANIA_VERSION_STRING) 67 68if (ORCANIA_FOUND) 69 set(ORCANIA_LIBRARIES ${ORCANIA_LIBRARY}) 70 set(ORCANIA_INCLUDE_DIRS ${ORCANIA_INCLUDE_DIR}) 71endif () 72 73mark_as_advanced(ORCANIA_INCLUDE_DIR ORCANIA_LIBRARY) 74