[cosmetic] separate c-lang format commit
[xbmc.git] / cmake / modules / FindTinyXML.cmake
blob9b17c52629e0b43a18635212351475c2a5db4b32
1 #.rst:
2 # FindTinyXML
3 # -----------
4 # Finds the TinyXML library
6 # The following imported targets are created::
8 #   ${APP_NAME_LC}::TinyXML   - The TinyXML library
10 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
11   find_package(PkgConfig)
13   if(PKG_CONFIG_FOUND)
14     pkg_check_modules(PC_TINYXML tinyxml QUIET)
15   endif()
17   find_path(TINYXML_INCLUDE_DIR tinyxml.h
18                                 PATH_SUFFIXES tinyxml
19                                 HINTS ${PC_TINYXML_INCLUDEDIR})
20   find_library(TINYXML_LIBRARY_RELEASE NAMES tinyxml tinyxmlSTL
21                                        PATH_SUFFIXES tinyxml
22                                        HINTS ${PC_TINYXML_LIBDIR})
23   find_library(TINYXML_LIBRARY_DEBUG NAMES tinyxmld tinyxmlSTLd
24                                      PATH_SUFFIXES tinyxml
25                                      HINTS ${PC_TINYXML_LIBDIR})
26   set(TINYXML_VERSION ${PC_TINYXML_VERSION})
28   include(SelectLibraryConfigurations)
29   select_library_configurations(TINYXML)
31   include(FindPackageHandleStandardArgs)
32   find_package_handle_standard_args(TinyXML
33                                     REQUIRED_VARS TINYXML_LIBRARY TINYXML_INCLUDE_DIR
34                                     VERSION_VAR TINYXML_VERSION)
36   if(TINYXML_FOUND)
37     add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
38     if(TINYXML_LIBRARY_RELEASE)
39       set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
40                                                                        IMPORTED_CONFIGURATIONS RELEASE
41                                                                        IMPORTED_LOCATION_RELEASE "${TINYXML_LIBRARY_RELEASE}")
42     endif()
43     if(TINYXML_LIBRARY_DEBUG)
44       set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
45                                                                        IMPORTED_LOCATION_DEBUG "${TINYXML_LIBRARY_DEBUG}")
46       set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY
47                                                                             IMPORTED_CONFIGURATIONS DEBUG)
48     endif()
49     set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
50                                                                      INTERFACE_INCLUDE_DIRECTORIES "${TINYXML_INCLUDE_DIR}")
51     if(WIN32 OR WINDOWS_STORE)
52       set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
53                                                                        INTERFACE_COMPILE_DEFINITIONS TIXML_USE_STL)
54     endif()
55   else()
56     if(TinyXML_FIND_REQUIRED)
57       message(FATAL_ERROR "TinyXML library not found.")
58     endif()
59   endif()
60 endif()