summaryrefslogtreecommitdiff
path: root/Modules/FindEXPAT.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindEXPAT.cmake')
-rw-r--r--Modules/FindEXPAT.cmake46
1 files changed, 22 insertions, 24 deletions
diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake
index c681a0dfd..09963fcda 100644
--- a/Modules/FindEXPAT.cmake
+++ b/Modules/FindEXPAT.cmake
@@ -1,28 +1,29 @@
-# - Find expat
-# Find the native EXPAT headers and libraries.
-#
-# EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
-# EXPAT_LIBRARIES - List of libraries when using expat.
-# EXPAT_FOUND - True if expat found.
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
-#=============================================================================
-# Copyright 2006-2009 Kitware, Inc.
+#.rst:
+# FindEXPAT
+# ---------
#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
+# Find expat
+#
+# Find the native EXPAT headers and libraries.
#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
+# ::
+#
+# EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
+# EXPAT_LIBRARIES - List of libraries when using expat.
+# EXPAT_FOUND - True if expat found.
+
+find_package(PkgConfig QUIET)
+
+pkg_check_modules(PC_EXPAT QUIET expat)
# Look for the header file.
-find_path(EXPAT_INCLUDE_DIR NAMES expat.h)
+find_path(EXPAT_INCLUDE_DIR NAMES expat.h HINTS ${PC_EXPAT_INCLUDE_DIRS})
# Look for the library.
-find_library(EXPAT_LIBRARY NAMES expat libexpat)
+find_library(EXPAT_LIBRARY NAMES expat libexpat HINTS ${PC_EXPAT_LIBRARY_DIRS})
if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str
@@ -31,11 +32,10 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
unset(EXPAT_VERSION_STRING)
foreach(VPART MAJOR MINOR MICRO)
foreach(VLINE ${expat_version_str})
- if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION")
- string(REGEX REPLACE "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$" "\\1"
- EXPAT_VERSION_PART "${VLINE}")
+ if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
+ set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
if(EXPAT_VERSION_STRING)
- set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}")
+ string(APPEND EXPAT_VERSION_STRING ".${EXPAT_VERSION_PART}")
else()
set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}")
endif()
@@ -44,8 +44,6 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
endforeach()
endif ()
-# handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if
-# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT
REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR