• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# - Try to find LIBEXPAT
2# Once done this will define
3#
4#  LIBEXPAT_FOUND - system has LIBEXPAT
5#  LIBEXPAT_INCLUDE_DIR - the LIBEXPAT include directory
6#  LIBEXPAT_LIBRARIES - the libraries needed to use LIBEXPAT
7#  LIBEXPAT_DEFINITIONS - Compiler switches required for using LIBEXPAT
8
9if (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES)
10
11    # in cache already
12    SET(LIBEXPAT_FOUND TRUE)
13
14else (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES)
15
16    IF (WIN32)
17		file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _progFiles)
18		find_FILE(LIBEXPAT_DIR expat Source/lib/expat.h
19   			PATHS
20   			"${_progFiles}"
21		)
22        if (LIBEXPAT_DIR)
23            set (_LIBEXPATIncDir  ${LIBEXPAT_DIR}/Source/lib)
24            set (_LIBEXPATLinkDir ${LIBEXPAT_DIR}/libs)
25        endif (LIBEXPAT_DIR)
26    ELSE (WIN32)
27        # use pkg-config to get the directories and then use these values
28        # in the FIND_PATH() and FIND_LIBRARY() calls
29        INCLUDE(UsePkgConfig)
30        PKGCONFIG(LIBEXPAT-2.0 _LIBEXPATIncDir _LIBEXPATLinkDir _LIBEXPATLinkFlags _LiIconvCflags)
31        SET(LIBEXPAT_DEFINITIONS ${_LIBEXPATCflags})
32    ENDIF (WIN32)
33
34    FIND_PATH(LIBEXPAT_INCLUDE_DIR expat.h
35      PATHS
36     ${_LIBEXPATIncDir}
37      PATH_SUFFIXES LIBEXPAT
38    )
39
40    FIND_LIBRARY(LIBEXPAT_LIBRARIES NAMES expat libexpat
41      PATHS
42      ${_LIBEXPATLinkDir}
43    )
44
45    if (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES)
46       set(LIBEXPAT_FOUND TRUE)
47    endif (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES)
48
49    if (LIBEXPAT_FOUND)
50      if (NOT LIBEXPAT_FIND_QUIETLY)
51        message(STATUS "Found libexpat: ${LIBEXPAT_LIBRARIES}")
52      endif (NOT LIBEXPAT_FIND_QUIETLY)
53    else (LIBEXPAT_FOUND)
54      if (LIBEXPAT_FIND_REQUIRED)
55        message(SEND_ERROR "Could NOT find libexpat")
56      endif (LIBEXPAT_FIND_REQUIRED)
57    endif (LIBEXPAT_FOUND)
58
59    MARK_AS_ADVANCED(LIBEXPAT_INCLUDE_DIR LIBEXPAT_LIBRARIES)
60
61endif (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES)
62