tinyxml2-config.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. cmake_minimum_required(VERSION 3.15)
  2. set(tinyxml2_known_comps static shared)
  3. set(tinyxml2_comp_static NO)
  4. set(tinyxml2_comp_shared NO)
  5. foreach (tinyxml2_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
  6. if (tinyxml2_comp IN_LIST tinyxml2_known_comps)
  7. set(tinyxml2_comp_${tinyxml2_comp} YES)
  8. else ()
  9. set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
  10. "tinyxml2 does not recognize component `${tinyxml2_comp}`.")
  11. set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
  12. return()
  13. endif ()
  14. endforeach ()
  15. if (tinyxml2_comp_static AND tinyxml2_comp_shared)
  16. set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
  17. "tinyxml2 `static` and `shared` components are mutually exclusive.")
  18. set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
  19. return()
  20. endif ()
  21. set(tinyxml2_static_targets "${CMAKE_CURRENT_LIST_DIR}/tinyxml2-static-targets.cmake")
  22. set(tinyxml2_shared_targets "${CMAKE_CURRENT_LIST_DIR}/tinyxml2-shared-targets.cmake")
  23. macro(tinyxml2_load_targets type)
  24. if (NOT EXISTS "${tinyxml2_${type}_targets}")
  25. set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
  26. "tinyxml2 `${type}` libraries were requested but not found.")
  27. set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
  28. return()
  29. endif ()
  30. include("${tinyxml2_${type}_targets}")
  31. endmacro()
  32. if (tinyxml2_comp_static)
  33. tinyxml2_load_targets(static)
  34. elseif (tinyxml2_comp_shared)
  35. tinyxml2_load_targets(shared)
  36. elseif (DEFINED tinyxml2_SHARED_LIBS AND tinyxml2_SHARED_LIBS)
  37. tinyxml2_load_targets(shared)
  38. elseif (DEFINED tinyxml2_SHARED_LIBS AND NOT tinyxml2_SHARED_LIBS)
  39. tinyxml2_load_targets(static)
  40. elseif (BUILD_SHARED_LIBS)
  41. if (EXISTS "${tinyxml2_shared_targets}")
  42. tinyxml2_load_targets(shared)
  43. else ()
  44. tinyxml2_load_targets(static)
  45. endif ()
  46. else ()
  47. if (EXISTS "${tinyxml2_static_targets}")
  48. tinyxml2_load_targets(static)
  49. else ()
  50. tinyxml2_load_targets(shared)
  51. endif ()
  52. endif ()