summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindTinyXML.cmake
blob: 5e9539e2d6c79d98de3fb7109e27e2571d5c699e (plain)
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
#.rst:
# FindTinyXML
# -----------
# Finds the TinyXML library
#
# This will define the following variables::
#
# TINYXML_FOUND - system has TinyXML
# TINYXML_INCLUDE_DIRS - the TinyXML include directory
# TINYXML_LIBRARIES - the TinyXML libraries
# TINYXML_DEFINITIONS - the TinyXML definitions
#
# and the following imported targets::
#
#   TinyXML::TinyXML   - The TinyXML library

if(PKG_CONFIG_FOUND)
  pkg_check_modules(PC_TINYXML tinyxml QUIET)
endif()

find_path(TINYXML_INCLUDE_DIR tinyxml.h
                              PATH_SUFFIXES tinyxml
                              PATHS ${PC_TINYXML_INCLUDEDIR})
find_library(TINYXML_LIBRARY_RELEASE NAMES tinyxml tinyxmlSTL
                                     PATH_SUFFIXES tinyxml
                                     PATHS ${PC_TINYXML_LIBDIR})
find_library(TINYXML_LIBRARY_DEBUG NAMES tinyxmld tinyxmlSTLd
                                   PATH_SUFFIXES tinyxml
                                   PATHS ${PC_TINYXML_LIBDIR})
set(TINYXML_VERSION ${PC_TINYXML_VERSION})

include(SelectLibraryConfigurations)
select_library_configurations(TINYXML)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML
                                  REQUIRED_VARS TINYXML_LIBRARY TINYXML_INCLUDE_DIR
                                  VERSION_VAR TINYXML_VERSION)

if(TINYXML_FOUND)
  set(TINYXML_LIBRARIES ${TINYXML_LIBRARY})
  set(TINYXML_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR})
  if(WIN32)
    set(TINYXML_DEFINITIONS -DTIXML_USE_STL=1)
  endif()

  if(NOT TARGET TinyXML::TinyXML)
    add_library(TinyXML::TinyXML UNKNOWN IMPORTED)
    if(TINYXML_LIBRARY_RELEASE)
      set_target_properties(TinyXML::TinyXML PROPERTIES
                                             IMPORTED_CONFIGURATIONS RELEASE
                                             IMPORTED_LOCATION "${TINYXML_LIBRARY_RELEASE}")
    endif()
    if(TINYXML_LIBRARY_DEBUG)
      set_target_properties(TinyXML::TinyXML PROPERTIES
                                             IMPORTED_CONFIGURATIONS DEBUG
                                             IMPORTED_LOCATION "${TINYXML_LIBRARY_DEBUG}")
    endif()
    set_target_properties(TinyXML::TinyXML PROPERTIES
                                           INTERFACE_INCLUDE_DIRECTORIES "${TINYXML_INCLUDE_DIR}")
    if(WIN32)
      set_target_properties(TinyXML::TinyXML PROPERTIES
                                             INTERFACE_COMPILE_DEFINITIONS TIXML_USE_STL=1)
    endif()
  endif()
endif()

mark_as_advanced(TINYXML_INCLUDE_DIR TINYXML_LIBRARY)