FindQuaZIP.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # 防止重复引入
  2. if(GJDM_QuaZIP_ALREADY_INCLUDED)
  3. return()
  4. endif()
  5. set(GJDM_QuaZIP_ALREADY_INCLUDED 1)
  6. # find_path 搜索包含某个文件的路径
  7. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  8. find_path(QuaZIP_DIRS
  9. NAMES
  10. include/quazip5/quazip.h
  11. PATHS
  12. ${CMAKE_SOURCE_DIR}/extlib/QuaZIP
  13. NO_SYSTEM_ENVIRONMENT_PATH
  14. NO_CMAKE_SYSTEM_PATH
  15. )
  16. set(QuaZIP_VERSION_MAJOR 0)
  17. set(QuaZIP_VERSION_MINOR 7)
  18. set(QuaZIP_VERSION_PATCH 3)
  19. set(QuaZIP_VERSION "${QuaZIP_VERSION_MAJOR}.${QuaZIP_VERSION_MINOR}.${QuaZIP_VERSION_PATCH}")
  20. find_path(QuaZIP_INCLUDE_DIRS
  21. NAMES
  22. quazip.h
  23. HINTS
  24. ${QuaZIP_DIRS}/include/quazip5
  25. )
  26. find_path(QuaZIP_LIBRARY_DIRS
  27. NAMES
  28. quazip5.lib libquazip5.so
  29. HINTS
  30. ${QuaZIP_DIRS}/lib
  31. )
  32. find_path(QuaZIP_BINARY_DIRS
  33. NAMES
  34. quazip5.dll libquazip5.so
  35. HINTS
  36. ${QuaZIP_DIRS}/lib
  37. )
  38. set(QuaZIP_LIBRARIES GJDM::QUAZIP)
  39. add_library(GJDM::QUAZIP SHARED IMPORTED)
  40. set_property(TARGET GJDM::QUAZIP PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${QuaZIP_INCLUDE_DIRS})
  41. set_property(TARGET GJDM::QUAZIP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  42. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  43. set_target_properties(GJDM::QUAZIP PROPERTIES
  44. IMPORTED_LOCATION_RELEASE "${QuaZIP_LIBRARY_DIRS}/libquazip5.so.1.0.0"
  45. IMPORTED_SONAME_RELEASE "libquazip5.so.1"
  46. )
  47. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  48. set_property(TARGET GJDM::QUAZIP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
  49. set_target_properties(GJDM::QUAZIP PROPERTIES
  50. IMPORTED_IMPLIB_RELEASE "${QuaZIP_LIBRARY_DIRS}/quazip5.lib"
  51. IMPORTED_LOCATION_RELEASE "${QuaZIP_BINARY_DIRS}/quazip5.dll"
  52. IMPORTED_IMPLIB_DEBUG "${QuaZIP_LIBRARY_DIRS}/quazip5d.lib"
  53. IMPORTED_LOCATION_DEBUG "${QuaZIP_BINARY_DIRS}/quazip5d.dll"
  54. )
  55. endif()
  56. include(FindPackageHandleStandardArgs)
  57. # 如果找到所有需要的变量,并且版本匹配,则将QuaZIP_FOUND变量设置为TRUE
  58. find_package_handle_standard_args(QuaZIP
  59. FOUND_VAR
  60. QuaZIP_FOUND
  61. REQUIRED_VARS
  62. QuaZIP_DIRS
  63. QuaZIP_INCLUDE_DIRS
  64. QuaZIP_LIBRARY_DIRS
  65. QuaZIP_LIBRARIES
  66. QuaZIP_BINARY_DIRS
  67. VERSION_VAR
  68. QuaZIP_VERSION
  69. )