FindLibXML2.cmake
2.52 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
# - Try to find libxml2
# Once done this will define
#
# LibXML2_FOUND - system has xml2
# LibXML2_INCLUDE_DIRS - the xml2 include directory
# LibXML2_LIBRARIES - Link these to use xml2
# LibXML2_DEFINITIONS - Compiler switches required for using xml2
#
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
# Modified for other libraries by Lasse Kärkkäinen <tronic>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (LibXML2_LIBRARIES AND LibXML2_INCLUDE_DIRS)
# in cache already
set(LibXML2_FOUND TRUE)
else (LibXML2_LIBRARIES AND LibXML2_INCLUDE_DIRS)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(libxml-2.0 _LibXML2_INCLUDEDIR _LibXML2_LIBDIR _LibXML2_LDFLAGS _LibXML2_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_LIBXML2 libxml-2.0)
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_path(LibXML2_INCLUDE_DIR
NAMES
libxml/xpath.h
PATHS
${_LibXML2_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
libxml2
)
find_library(LibXML2_LIBRARY
NAMES
xml2
PATHS
${_LibXML2_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
if (LibXML2_LIBRARY)
set(LibXML2_FOUND TRUE)
endif (LibXML2_LIBRARY)
set(LibXML2_INCLUDE_DIRS
${LibXML2_INCLUDE_DIR}
)
if (LibXML2_FOUND)
set(LibXML2_LIBRARIES
${LibXML2_LIBRARIES}
${LibXML2_LIBRARY}
)
endif (LibXML2_FOUND)
if (LibXML2_INCLUDE_DIRS AND LibXML2_LIBRARIES)
set(LibXML2_FOUND TRUE)
endif (LibXML2_INCLUDE_DIRS AND LibXML2_LIBRARIES)
if (LibXML2_FOUND)
if (NOT LibXML2_FIND_QUIETLY)
message(STATUS "Found libxml2: ${LibXML2_LIBRARY}")
endif (NOT LibXML2_FIND_QUIETLY)
else (LibXML2_FOUND)
if (LibXML2_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libxml2")
endif (LibXML2_FIND_REQUIRED)
endif (LibXML2_FOUND)
# show the LibXML2_INCLUDE_DIRS and LibXML2_LIBRARIES variables only in the advanced view
mark_as_advanced(LibXML2_INCLUDE_DIRS LibXML2_LIBRARIES)
endif (LibXML2_LIBRARIES AND LibXML2_INCLUDE_DIRS)