aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-05-12 14:58:09 +1000
committerfuzzard <fuzzard@kodi.tv>2024-06-22 13:17:14 +1000
commit0ec9b32e31b06a17d988c1fda94c2a1160a2f29f (patch)
treec55e7568a1ab76ce0e42c675366c1a6807e900d5 /cmake
parent307176ab65d3e8fd481d794bddb9ca5736e6d390 (diff)
[cmake][modules] FindTinyXML cleanup and use core_target_link_libraries
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindTinyXML.cmake88
1 files changed, 39 insertions, 49 deletions
diff --git a/cmake/modules/FindTinyXML.cmake b/cmake/modules/FindTinyXML.cmake
index c0daa9978e..9b17c52629 100644
--- a/cmake/modules/FindTinyXML.cmake
+++ b/cmake/modules/FindTinyXML.cmake
@@ -3,68 +3,58 @@
# -----------
# Finds the TinyXML library
#
-# This will define the following variables::
+# The following imported targets are created::
#
-# 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
+# ${APP_NAME_LC}::TinyXML - The TinyXML library
-find_package(PkgConfig)
+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()
+ 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
+ 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})
-find_library(TINYXML_LIBRARY_DEBUG NAMES tinyxmld tinyxmlSTLd
- PATH_SUFFIXES tinyxml
- HINTS ${PC_TINYXML_LIBDIR})
-set(TINYXML_VERSION ${PC_TINYXML_VERSION})
+ set(TINYXML_VERSION ${PC_TINYXML_VERSION})
-include(SelectLibraryConfigurations)
-select_library_configurations(TINYXML)
+ 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)
+ 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_FOUND)
+ add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
if(TINYXML_LIBRARY_RELEASE)
- set_target_properties(TinyXML::TinyXML PROPERTIES
- IMPORTED_CONFIGURATIONS RELEASE
- IMPORTED_LOCATION "${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(TinyXML::TinyXML PROPERTIES
- IMPORTED_CONFIGURATIONS DEBUG
- IMPORTED_LOCATION "${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(TinyXML::TinyXML PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${TINYXML_INCLUDE_DIR}")
- if(WIN32)
- set_target_properties(TinyXML::TinyXML PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS TIXML_USE_STL=1)
+ 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()
-
-mark_as_advanced(TINYXML_INCLUDE_DIR TINYXML_LIBRARY)