1
# - Try to find the Marble Library
2
# Once done this will define
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
10
# Versions mapping can be found at: https://marble.kde.org/changelog.php
12
# Redistribution and use is allowed according to the terms of the BSD license.
13
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
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>
21
# Distributed under the OSI-approved BSD License (the "License");
22
# see accompanying file Copyright.txt for details.
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
#=============================================================================
29
function(from_hex HEX DEC)
30
string(TOUPPER "${HEX}" HEX)
32
string(LENGTH "${HEX}" _strlen)
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")
51
math(EXPR _res "${_res} + ${NIBBLE}")
54
string(LENGTH "${HEX}" _strlen)
57
set(${DEC} ${_res} PARENT_SCOPE)
60
if ( MARBLE_INCLUDE_DIR AND MARBLE_GLOBAL_HEADER AND MARBLE_LIBRARIES )
62
set( MARBLE_FIND_QUIETLY TRUE )
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 )
69
if(MARBLE_GLOBAL_HEADER)
70
file(STRINGS ${MARBLE_GLOBAL_HEADER}
72
REGEX "^#define[\t ]+MARBLE_VERSION[\t ]+0x([0-9a-fA-F])+.*")
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}")
78
list(GET marble_version_list 0 MARBLE_VERSION_MAJOR)
79
from_hex("${MARBLE_VERSION_MAJOR}" MARBLE_VERSION_MAJOR)
81
list(GET marble_version_list 1 MARBLE_VERSION_MINOR)
82
from_hex("${MARBLE_VERSION_MINOR}" MARBLE_VERSION_MINOR)
84
list(GET marble_version_list 2 MARBLE_VERSION_PATCH)
85
from_hex("${MARBLE_VERSION_PATCH}" MARBLE_VERSION_PATCH)
87
set(MARBLE_VERSION "${MARBLE_VERSION_MAJOR}.${MARBLE_VERSION_MINOR}.${MARBLE_VERSION_PATCH}" CACHE STRING "Found Marble version")
90
include( FindPackageHandleStandardArgs )
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)
98
find_package_handle_standard_args( Marble
105
"Could not find Marble"
109
find_package_handle_standard_args( marble
115
mark_as_advanced(MARBLE_GLOBAL_HEADER MARBLE_VERSION_MAJOR MARBLE_VERSION_MINOR MARBLE_VERSION_PATCH)