diff options
author | David Cole <david.cole@kitware.com> | 2012-01-25 16:19:09 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-01-25 16:19:09 (GMT) |
commit | 55e7d4071f15f4a39df49ca930ca5686c8ff1494 (patch) | |
tree | baa5c0e7fafc6f83630f26a52695808a5d4d8b1b /Modules | |
parent | 1226207a6e93c1ef480c1ce7859cae1977be7eab (diff) | |
parent | 7f81c48bdd7901a310744c3b65a8a975cd9cf1a6 (diff) | |
download | CMake-55e7d4071f15f4a39df49ca930ca5686c8ff1494.zip CMake-55e7d4071f15f4a39df49ca930ca5686c8ff1494.tar.gz CMake-55e7d4071f15f4a39df49ca930ca5686c8ff1494.tar.bz2 |
Merge topic 'improve-findexpat'
7f81c48 FindEXPAT: support version number
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindEXPAT.cmake | 24 |
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) |