forked from opencog/opencog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindXercesC.cmake
78 lines (64 loc) · 2.39 KB
/
FindXercesC.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# - Try to find Xerces-C
# This script is improved over the previous one in that it will
# also find the version.
#
# Adapted from:
# http://cezarfx.blogspot.com/2009/09/using-xerces-version-with-cmake.html
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# Once done this will define
#
# XERCESC_FOUND - system has Xerces-C
# XERCESC_INCLUDE - the Xerces-C include directory
# XERCESC_LIBRARIES - Link these to use Xerces-C
# XERCESC_VERSION - Xerces-C found version
IF (XERCESC_INCLUDE AND XERCESC_LIBRARIES)
# in cache already
SET(XERCESC_FIND_QUIETLY TRUE)
ENDIF (XERCESC_INCLUDE AND XERCESC_LIBRARIES)
FIND_PATH(
XERCESC_INCLUDE
NAMES xercesc/util/XercesVersion.hpp
PATHS c:/Libs/xerces-c_2_8_0 ${XERCES_INCLUDE_DIR}
PATH_SUFFIXES xercesc)
FIND_LIBRARY(
XERCESC_LIBRARIES
NAMES xerces-c xerces-c_2
PATHS ${XERCES_LIBRARY_DIR})
IF (XERCESC_INCLUDE AND XERCESC_LIBRARIES)
SET(XERCESC_FOUND TRUE)
ELSE (XERCESC_INCLUDE AND XERCESC_LIBRARIES)
SET(XERCESC_FOUND FALSE)
ENDIF (XERCESC_INCLUDE AND XERCESC_LIBRARIES)
IF(XERCESC_FOUND)
FIND_PATH(XVERHPPPATH NAMES XercesVersion.hpp PATHS
${XERCESC_INCLUDE}/xercesc/util NO_DEFAULT_PATH)
IF ( ${XVERHPPPATH} STREQUAL XVERHPPPATH-NOTFOUND )
SET(XERCES_VERSION "0")
ELSE( ${XVERHPPPATH} STREQUAL XVERHPPPATH-NOTFOUND )
FILE(READ ${XVERHPPPATH}/XercesVersion.hpp XVERHPP)
STRING(REGEX MATCHALL "\n *#define XERCES_VERSION_MAJOR +[0-9]+" XVERMAJ
${XVERHPP})
STRING(REGEX MATCH "\n *#define XERCES_VERSION_MINOR +[0-9]+" XVERMIN
${XVERHPP})
STRING(REGEX MATCH "\n *#define XERCES_VERSION_REVISION +[0-9]+" XVERREV
${XVERHPP})
STRING(REGEX REPLACE "\n *#define XERCES_VERSION_MAJOR +" ""
XVERMAJ ${XVERMAJ})
STRING(REGEX REPLACE "\n *#define XERCES_VERSION_MINOR +" ""
XVERMIN ${XVERMIN})
STRING(REGEX REPLACE "\n *#define XERCES_VERSION_REVISION +" ""
XVERREV ${XVERREV})
SET(XERCESC_VERSION ${XVERMAJ}.${XVERMIN}.${XVERREV})
ENDIF ( ${XVERHPPPATH} STREQUAL XVERHPPPATH-NOTFOUND )
IF(NOT XERCESC_FIND_QUIETLY)
MESSAGE(STATUS "Found Xerces-C: ${XERCESC_LIBRARIES}")
MESSAGE(STATUS " : ${XERCESC_INCLUDE}")
MESSAGE(STATUS " Version: ${XERCESC_VERSION}")
ENDIF(NOT XERCESC_FIND_QUIETLY)
ELSE(XERCESC_FOUND)
MESSAGE(WARNING "Could not find Xerces-C !")
ENDIF(XERCESC_FOUND)
MARK_AS_ADVANCED(XERCESC_INCLUDE XERCESC_LIBRARIES)