summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-02-01 19:48:47 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-02-01 19:48:47 (GMT)
commit9603ee91154e222042118f5b056bc422c89b0abf (patch)
treed00bdd6a0769ad15e09e85eab48dd905ad920b1f
parentba963564344d95e28ac2bcdf5a7d5147d1ab143a (diff)
parent9d7a00104f6efa4f13cf2a5c69c79b9d6f6e261d (diff)
downloadCMake-9603ee91154e222042118f5b056bc422c89b0abf.zip
CMake-9603ee91154e222042118f5b056bc422c89b0abf.tar.gz
CMake-9603ee91154e222042118f5b056bc422c89b0abf.tar.bz2
Merge topic 'improve-libxml2'
9d7a001 FindLibXml2: detect version when PkgConfig is not used
-rw-r--r--Modules/FindLibXml2.cmake17
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake
index a797b12..48a5498 100644
--- a/Modules/FindLibXml2.cmake
+++ b/Modules/FindLibXml2.cmake
@@ -45,15 +45,22 @@ FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint)
# for backwards compat. with KDE 4.0.x:
SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}")
+IF(PC_LIBXML_VERSION)
+ SET(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION})
+ELSEIF(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h")
+ FILE(STRINGS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h" libxml2_version_str
+ REGEX "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\".*\"")
+
+ STRING(REGEX REPLACE "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
+ LIBXML2_VERSION_STRING "${libxml2_version_str}")
+ UNSET(libxml2_version_str)
+ENDIF()
+
# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2
REQUIRED_VARS LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR
- VERSION_VAR PC_LIBXML_VERSION)
-
-IF(LIBXML2_FOUND)
- SET(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION})
-ENDIF()
+ VERSION_VAR LIBXML2_VERSION_STRING)
MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE)