aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindTinyXML.cmake
blob: 9b17c52629e0b43a18635212351475c2a5db4b32 (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
#.rst:
# FindTinyXML
# -----------
# Finds the TinyXML library
#
# The following imported targets are created::
#
#   ${APP_NAME_LC}::TinyXML   - The TinyXML library

if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
  find_package(PkgConfig)

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

  find_path(TINYXML_INCLUDE_DIR tinyxml.h
                                PATH_SUFFIXES tinyxml
                                HINTS ${PC_TINYXML_INCLUDEDIR})
  find_library(TINYXML_LIBRARY_RELEASE NAMES tinyxml tinyxmlSTL
                                       PATH_SUFFIXES tinyxml
                                       HINTS ${PC_TINYXML_LIBDIR})
  find_library(TINYXML_LIBRARY_DEBUG NAMES tinyxmld tinyxmlSTLd
                                     PATH_SUFFIXES tinyxml
                                     HINTS ${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)
    add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
    if(TINYXML_LIBRARY_RELEASE)
      set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
                                                                       IMPORTED_CONFIGURATIONS RELEASE
                                                                       IMPORTED_LOCATION_RELEASE "${TINYXML_LIBRARY_RELEASE}")
    endif()
    if(TINYXML_LIBRARY_DEBUG)
      set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
                                                                       IMPORTED_LOCATION_DEBUG "${TINYXML_LIBRARY_DEBUG}")
      set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY
                                                                            IMPORTED_CONFIGURATIONS DEBUG)
    endif()
    set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
                                                                     INTERFACE_INCLUDE_DIRECTORIES "${TINYXML_INCLUDE_DIR}")
    if(WIN32 OR WINDOWS_STORE)
      set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
                                                                       INTERFACE_COMPILE_DEFINITIONS TIXML_USE_STL)
    endif()
  else()
    if(TinyXML_FIND_REQUIRED)
      message(FATAL_ERROR "TinyXML library not found.")
    endif()
  endif()
endif()