2016-09-27 19:01:08 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 15:17:36 +00:00
|
|
|
#.rst:
|
|
|
|
# FindEXPAT
|
|
|
|
# ---------
|
|
|
|
#
|
|
|
|
# Find expat
|
|
|
|
#
|
2006-10-19 16:57:28 +00:00
|
|
|
# Find the native EXPAT headers and libraries.
|
|
|
|
#
|
2013-10-15 15:17:36 +00:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
|
|
|
|
# EXPAT_LIBRARIES - List of libraries when using expat.
|
|
|
|
# EXPAT_FOUND - True if expat found.
|
2006-10-19 16:57:28 +00:00
|
|
|
|
2016-08-30 21:37:10 +00:00
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
|
|
|
|
pkg_check_modules(PC_EXPAT QUIET expat)
|
|
|
|
|
2006-10-19 16:57:28 +00:00
|
|
|
# Look for the header file.
|
2016-08-30 21:37:10 +00:00
|
|
|
find_path(EXPAT_INCLUDE_DIR NAMES expat.h HINTS ${PC_EXPAT_INCLUDE_DIRS})
|
2006-10-19 16:57:28 +00:00
|
|
|
|
|
|
|
# Look for the library.
|
2016-08-30 21:37:10 +00:00
|
|
|
find_library(EXPAT_LIBRARY NAMES expat libexpat HINTS ${PC_EXPAT_LIBRARY_DIRS})
|
2007-07-19 13:00:51 +00:00
|
|
|
|
2012-01-23 19:53:22 +00:00
|
|
|
if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
|
|
|
|
file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str
|
|
|
|
REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$")
|
|
|
|
|
|
|
|
unset(EXPAT_VERSION_STRING)
|
|
|
|
foreach(VPART MAJOR MINOR MICRO)
|
|
|
|
foreach(VLINE ${expat_version_str})
|
2014-04-06 19:30:00 +00:00
|
|
|
if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
|
|
|
|
set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
|
2012-01-23 19:53:22 +00:00
|
|
|
if(EXPAT_VERSION_STRING)
|
2016-07-27 22:41:13 +00:00
|
|
|
string(APPEND EXPAT_VERSION_STRING ".${EXPAT_VERSION_PART}")
|
2012-08-13 17:50:14 +00:00
|
|
|
else()
|
2012-01-23 19:53:22 +00:00
|
|
|
set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2012-01-23 19:53:22 +00:00
|
|
|
endif()
|
2012-08-13 17:50:14 +00:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
|
|
|
endif ()
|
2012-01-23 19:53:22 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-01-23 19:53:22 +00:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT
|
|
|
|
REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR
|
|
|
|
VERSION_VAR EXPAT_VERSION_STRING)
|
2006-10-19 16:57:28 +00:00
|
|
|
|
|
|
|
# Copy the results to the output variables.
|
2012-08-13 17:47:32 +00:00
|
|
|
if(EXPAT_FOUND)
|
|
|
|
set(EXPAT_LIBRARIES ${EXPAT_LIBRARY})
|
|
|
|
set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2006-10-19 16:57:28 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
mark_as_advanced(EXPAT_INCLUDE_DIR EXPAT_LIBRARY)
|