~ubuntu-branches/debian/sid/kexi/sid

« back to all changes in this revision

Viewing changes to cmake/modules/FindKexiMarble.cmake

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2017-06-24 20:10:10 UTC
  • Revision ID: package-import@ubuntu.com-20170624201010-5lrzd5r2vwthwifp
Tags: upstream-3.0.1.1
ImportĀ upstreamĀ versionĀ 3.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# - Try to find the Marble Library
 
2
# Once done this will define
 
3
#
 
4
#  MARBLE_FOUND - system has Marble
 
5
#  MARBLE_INCLUDE_DIR - the Marble include directory
 
6
#  MARBLE_LIBRARIES - Libraries needed to use Marble
 
7
#  MARBLE_VERSION - This contains combined MAJOR.MINOR.PATCH version (eg. 0.19.2);
 
8
#                   Can be missing if version could not be found
 
9
#
 
10
#  Versions mapping can be found at: https://marble.kde.org/changelog.php
 
11
#
 
12
# Redistribution and use is allowed according to the terms of the BSD license.
 
13
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
14
#
 
15
 
 
16
#=============================================================================
 
17
# Copyright 2006-2009 Kitware, Inc.
 
18
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
 
19
# Copyright 2009-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
 
20
#
 
21
# Distributed under the OSI-approved BSD License (the "License");
 
22
# see accompanying file Copyright.txt for details.
 
23
#
 
24
# This software is distributed WITHOUT ANY WARRANTY; without even the
 
25
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
26
# See the License for more information.
 
27
#=============================================================================
 
28
 
 
29
function(from_hex HEX DEC)
 
30
  string(TOUPPER "${HEX}" HEX)
 
31
  set(_res 0)
 
32
  string(LENGTH "${HEX}" _strlen)
 
33
 
 
34
  while (_strlen GREATER 0)
 
35
    math(EXPR _res "${_res} * 16")
 
36
    string(SUBSTRING "${HEX}" 0 1 NIBBLE)
 
37
    string(SUBSTRING "${HEX}" 1 -1 HEX)
 
38
    if (NIBBLE STREQUAL "A")
 
39
      math(EXPR _res "${_res} + 10")
 
40
    elseif (NIBBLE STREQUAL "B")
 
41
      math(EXPR _res "${_res} + 11")
 
42
    elseif (NIBBLE STREQUAL "C")
 
43
      math(EXPR _res "${_res} + 12")
 
44
    elseif (NIBBLE STREQUAL "D")
 
45
      math(EXPR _res "${_res} + 13")
 
46
    elseif (NIBBLE STREQUAL "E")
 
47
      math(EXPR _res "${_res} + 14")
 
48
    elseif (NIBBLE STREQUAL "F")
 
49
      math(EXPR _res "${_res} + 15")
 
50
    else()
 
51
      math(EXPR _res "${_res} + ${NIBBLE}")
 
52
    endif()
 
53
 
 
54
    string(LENGTH "${HEX}" _strlen)
 
55
  endwhile()
 
56
 
 
57
  set(${DEC} ${_res} PARENT_SCOPE)
 
58
endfunction()
 
59
 
 
60
if ( MARBLE_INCLUDE_DIR AND MARBLE_GLOBAL_HEADER AND MARBLE_LIBRARIES )
 
61
   # in cache already
 
62
   set( MARBLE_FIND_QUIETLY TRUE )
 
63
endif ()
 
64
 
 
65
find_path( MARBLE_INCLUDE_DIR NAMES marble/MarbleMap.h PATH_SUFFIXES marble)
 
66
find_file( MARBLE_GLOBAL_HEADER NAMES marble/MarbleGlobal.h PATH_SUFFIXES marble)
 
67
find_library( MARBLE_LIBRARIES NAMES marblewidget-qt5 )
 
68
 
 
69
if(MARBLE_GLOBAL_HEADER)
 
70
    file(STRINGS ${MARBLE_GLOBAL_HEADER}
 
71
         marble_version_line
 
72
         REGEX "^#define[\t ]+MARBLE_VERSION[\t ]+0x([0-9a-fA-F])+.*")
 
73
 
 
74
    string(REGEX REPLACE
 
75
            "^.*MARBLE_VERSION[\t ]+0x([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F]).*$"
 
76
            "\\1;\\2;\\3" marble_version_list "${marble_version_line}")
 
77
 
 
78
    list(GET marble_version_list 0 MARBLE_VERSION_MAJOR)
 
79
    from_hex("${MARBLE_VERSION_MAJOR}" MARBLE_VERSION_MAJOR)
 
80
 
 
81
    list(GET marble_version_list 1 MARBLE_VERSION_MINOR)
 
82
    from_hex("${MARBLE_VERSION_MINOR}" MARBLE_VERSION_MINOR)
 
83
 
 
84
    list(GET marble_version_list 2 MARBLE_VERSION_PATCH)
 
85
    from_hex("${MARBLE_VERSION_PATCH}" MARBLE_VERSION_PATCH)
 
86
 
 
87
    set(MARBLE_VERSION "${MARBLE_VERSION_MAJOR}.${MARBLE_VERSION_MINOR}.${MARBLE_VERSION_PATCH}" CACHE STRING "Found Marble version")
 
88
endif()
 
89
 
 
90
include( FindPackageHandleStandardArgs )
 
91
 
 
92
if(MARBLE_VERSION)
 
93
    if(DEFINED MARBLE_MIN_VERSION AND ${MARBLE_VERSION} VERSION_LESS ${MARBLE_MIN_VERSION})
 
94
        set(MARBLE_FOUND FALSE)
 
95
        unset(MARBLE_INCLUDE_DIR)
 
96
        unset(MARBLE_LIBRARIES)
 
97
    else()
 
98
        find_package_handle_standard_args( Marble
 
99
            REQUIRED_VARS
 
100
                MARBLE_INCLUDE_DIR
 
101
                MARBLE_LIBRARIES
 
102
            VERSION_VAR
 
103
                MARBLE_VERSION
 
104
            FAIL_MESSAGE
 
105
                "Could not find Marble"
 
106
        )
 
107
    endif()
 
108
else()
 
109
    find_package_handle_standard_args( marble
 
110
            DEFAULT_MSG
 
111
            MARBLE_INCLUDE_DIR
 
112
            MARBLE_LIBRARIES )
 
113
endif()
 
114
 
 
115
mark_as_advanced(MARBLE_GLOBAL_HEADER MARBLE_VERSION_MAJOR MARBLE_VERSION_MINOR MARBLE_VERSION_PATCH)