summaryrefslogtreecommitdiffstats
path: root/Modules/FindEXPAT.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2012-01-23 19:53:22 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2012-01-23 19:54:04 (GMT)
commit7f81c48bdd7901a310744c3b65a8a975cd9cf1a6 (patch)
tree0ad73d37b2251d0f17f767df00ccbc59b7e7246f /Modules/FindEXPAT.cmake
parent86c9604f98b2271401cf7a53c251be51af15278c (diff)
downloadCMake-7f81c48bdd7901a310744c3b65a8a975cd9cf1a6.zip
CMake-7f81c48bdd7901a310744c3b65a8a975cd9cf1a6.tar.gz
CMake-7f81c48bdd7901a310744c3b65a8a975cd9cf1a6.tar.bz2
FindEXPAT: support version number
Diffstat (limited to 'Modules/FindEXPAT.cmake')
-rw-r--r--Modules/FindEXPAT.cmake24
1 files changed, 23 insertions, 1 deletions
diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake
index 8551fd6..1bf0743 100644
--- a/Modules/FindEXPAT.cmake
+++ b/Modules/FindEXPAT.cmake
@@ -24,10 +24,32 @@ FIND_PATH(EXPAT_INCLUDE_DIR NAMES expat.h)
# Look for the library.
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)
+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})
+ 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(EXPAT_VERSION_STRING)
+ set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}")
+ else(EXPAT_VERSION_STRING)
+ set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}")
+ endif(EXPAT_VERSION_STRING)
+ endif()
+ endforeach(VLINE)
+ endforeach(VPART)
+endif (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
+
# 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 DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT
+ REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR
+ VERSION_VAR EXPAT_VERSION_STRING)
# Copy the results to the output variables.
IF(EXPAT_FOUND)