1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindLibKML
----------
Find the LibKML headers and libraries.
This module accept optional COMPONENTS to check supported sub modules::
LIBKML_BASE_LIBRARY
LIBKML_DOM_LIBRARY
LIBKML_ENGINE_LIBRARY
LIBKML_CONVENIENCE_LIBRARY
LIBKML_XSD_LIBRARY
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` target ``LIBKML::LibKML``, if found.
Result Variables
^^^^^^^^^^^^^^^^
This module defines the following variables:
``LIBKML_FOUND``
True if libkml found.
``LIBKML_INCLUDE_DIRS``
where to find header files.
``LIBKML_LIBRARIES``
List of libraries when using libkml.
``LIBKML_VERSION_STRING``
The version of libkml found.
#]=======================================================================]
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBKML QUIET libkml)
if(PC_LIBKML_VERSION)
endif()
endif()
find_path(LIBKML_INCLUDE_DIR
NAMES kml/engine.h kml/dom.h
HINTS ${PC_LIBKML_INCLUDE_DIRS})
mark_as_advanced(LIBKML_INCLUDE_DIR)
find_library(LIBKML_BASE_LIBRARY
NAMES kmlbase libkmlbase
NAMES_PER_DIR
HINTS ${PC_LIBKML_LIBRARY_DIRS} )
mark_as_advanced(LIBKML_BASE_LIBRARY)
set(libkml_known_components DOM CONVENIENCE ENGINE REGIONATOR)
foreach(_comp IN LISTS libkml_known_components)
if(${_comp} IN_LIST LibKML_FIND_COMPONENTS)
string(TOLOWER ${_comp} _name)
find_library(LIBKML_${_comp}_LIBRARY
NAMES kml${_name} libkml${_name}
NAMES_PER_DIR
HINTS ${PC_LIBKML_LIBRARY_DIRS} )
mark_as_advanced(LIBKML_${_comp}_LIBRARY)
endif()
endforeach()
set(libkml_helpers MINIZIP URIPARSER)
foreach(_helper IN LISTS libkml_helpers)
string(TOLOWER ${_helper} _name)
find_library(LIBKML_${_helper}_LIBRARY
NAMES ${_name} lib${_name}
NAMES_PER_DIR
HINTS ${PC_LIBKML_LIBRARY_DIRS} )
mark_as_advanced(LIBKML_${_helper}_LIBRARY)
endforeach()
if(LIBKML_INCLUDE_DIR AND NOT LIBKML_VERSION)
file(STRINGS ${LIBKML_INCLUDE_DIR}/kml/base/version.h libkml_version_h_string
REGEX "^#define[\t ]+LIBKML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+")
string(REGEX REPLACE ".*LIBKML_MAJOR_VERSION[\t ]+([0-9]+).*" "\\1" LIBKML_VERSION_MAJOR "${libkml_version_h_string}")
string(REGEX REPLACE ".*LIBKML_MINOR_VERSION[\t ]+([0-9]+).*" "\\1" LIBKML_VERSION_MINOR "${libkml_version_h_string}")
string(REGEX REPLACE ".*LIBKML_MICRO_VERSION[\t ]+([0-9]+).*" "\\1" LIBKML_VERSION_MICRO "${libkml_version_h_string}")
set(LIBKML_VERSION_STRING "${LIBKML_VERSION_MAJOR}.${LIBKML_VERSION_MINOR}.${LIBKML_VERSION_MICRO}")
endif()
set(libkml_required_vars LIBKML_BASE_LIBRARY LIBKML_INCLUDE_DIR)
foreach(_comp IN LISTS LibKML_FIND_COMPONENTS)
set(libkml_required_vars ${libkml_required_vars} "LIBKML_${_comp}_LIBRARY")
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibKML
FOUND_VAR LIBKML_FOUND
REQUIRED_VARS ${libkml_required_vars}
VERSION_VAR LIBKML_VERSION_STRING)
if(LIBKML_FOUND)
set(LIBKML_INCLUDE_DIRS "${LIBKML_INCLUDE_DIR}")
set(LIBKML_LIBRARIES "${LIBKML_BASE_LIBRARY}")
if(NOT TARGET LIBKML::LibKML)
add_library(LIBKML::LibKML UNKNOWN IMPORTED)
set_target_properties(LIBKML::LibKML PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIBKML_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C++"
IMPORTED_LOCATION "${LIBKML_BASE_LIBRARY}")
endif()
foreach(_comp IN LISTS libkml_known_components)
if(${_comp} IN_LIST LibKML_FIND_COMPONENTS)
list(APPEND LIBKML_LIBRARIES "${LIBKML_${_comp}_LIBRARY}")
if(NOT TARGET LIBKML::${_comp})
add_library(LIBKML::${_comp} UNKNOWN IMPORTED)
set_target_properties(LIBKML::${_comp} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C++"
IMPORTED_LOCATION "${LIBKML_${_comp}_LIBRARY}")
endif()
endif()
endforeach()
foreach(_helper IN LISTS libkml_helpers)
if(LIBKML_${_helper}_LIBRARY)
list(APPEND LIBKML_LIBRARIES "${LIBKML_${_helper}_LIBRARY}")
if(NOT TARGET LIBKML::${_helper})
add_library(LIBKML::${_helper} UNKNOWN IMPORTED)
set_target_properties(LIBKML::${_helper} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C++"
IMPORTED_LOCATION "${LIBKML_${_helper}_LIBRARY}")
endif()
endif()
endforeach()
endif()
|