FindQuaZIP.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # FindQuaZIP
  2. # --------
  3. #
  4. # Find the QuaZIP libraries(Only for QuaZIP provided by FastCAE)
  5. #
  6. # Result Variables
  7. # ^^^^^^^^^^^^^^^^
  8. #
  9. # The following variables will be defined:
  10. #
  11. # ``QuaZIP_FOUND`` True if QuaZIP found on the local system
  12. #
  13. # ``QuaZIP_VERSION`` QuaZIP Version(x.x.x)
  14. #
  15. # ``QuaZIP_VERSION_MAJOR`` QuaZIP Major Version
  16. #
  17. # ``QuaZIP_VERSION_MINOR`` QuaZIP Minor Version
  18. #
  19. # ``QuaZIP_VERSION_PATCH`` QuaZIP Patch Version
  20. #
  21. # ``QuaZIP_DIRS`` Location of QuaZIP(root dir)
  22. #
  23. # ``QuaZIP_INCLUDE_DIRS`` Location of QuaZIP header files
  24. #
  25. # ``QuaZIP_LIBRARY_DIRS`` Location of QuaZIP libraries
  26. #
  27. # ``QuaZIP_LIBRARIES`` List of the QuaZIP libraries found
  28. #
  29. # ``QuaZIP_BINARY_DIRS`` Location of VTK binary
  30. #
  31. # 防止重复引入
  32. if(GJDM_QuaZIP_ALREADY_INCLUDED)
  33. return()
  34. endif()
  35. set(GJDM_QuaZIP_ALREADY_INCLUDED 1)
  36. # find_path 搜索包含某个文件的路径
  37. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  38. find_path(QuaZIP_DIRS
  39. NAMES
  40. include/quazip5/quazip.h
  41. PATHS
  42. ${CMAKE_SOURCE_DIR}/extlib/QuaZIP
  43. NO_SYSTEM_ENVIRONMENT_PATH
  44. NO_CMAKE_SYSTEM_PATH
  45. )
  46. set(QuaZIP_VERSION_MAJOR 0)
  47. set(QuaZIP_VERSION_MINOR 7)
  48. set(QuaZIP_VERSION_PATCH 3)
  49. set(QuaZIP_VERSION "${QuaZIP_VERSION_MAJOR}.${QuaZIP_VERSION_MINOR}.${QuaZIP_VERSION_PATCH}")
  50. find_path(QuaZIP_INCLUDE_DIRS
  51. NAMES
  52. quazip.h
  53. HINTS
  54. ${QuaZIP_DIRS}/include/quazip5
  55. )
  56. find_path(QuaZIP_LIBRARY_DIRS
  57. NAMES
  58. quazip5.lib libquazip5.so
  59. HINTS
  60. ${QuaZIP_DIRS}/lib
  61. )
  62. find_path(QuaZIP_BINARY_DIRS
  63. NAMES
  64. quazip5.dll libquazip5.so
  65. HINTS
  66. ${QuaZIP_DIRS}/lib
  67. )
  68. set(QuaZIP_LIBRARIES GJDM::QUAZIP)
  69. add_library(GJDM::QUAZIP SHARED IMPORTED)
  70. set_property(TARGET GJDM::QUAZIP PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${QuaZIP_INCLUDE_DIRS})
  71. set_property(TARGET GJDM::QUAZIP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  72. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  73. set_target_properties(GJDM::QUAZIP PROPERTIES
  74. IMPORTED_LOCATION_RELEASE "${QuaZIP_LIBRARY_DIRS}/libquazip5.so.1.0.0"
  75. IMPORTED_SONAME_RELEASE "libquazip5.so.1"
  76. )
  77. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  78. set_property(TARGET GJDM::QUAZIP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
  79. set_target_properties(GJDM::QUAZIP PROPERTIES
  80. IMPORTED_IMPLIB_RELEASE "${QuaZIP_LIBRARY_DIRS}/quazip5.lib"
  81. IMPORTED_LOCATION_RELEASE "${QuaZIP_BINARY_DIRS}/quazip5.dll"
  82. IMPORTED_IMPLIB_DEBUG "${QuaZIP_LIBRARY_DIRS}/quazip5d.lib"
  83. IMPORTED_LOCATION_DEBUG "${QuaZIP_BINARY_DIRS}/quazip5d.dll"
  84. )
  85. endif()
  86. include(FindPackageHandleStandardArgs)
  87. # 如果找到所有需要的变量,并且版本匹配,则将QuaZIP_FOUND变量设置为TRUE
  88. find_package_handle_standard_args(QuaZIP
  89. FOUND_VAR
  90. QuaZIP_FOUND
  91. REQUIRED_VARS
  92. QuaZIP_DIRS
  93. QuaZIP_INCLUDE_DIRS
  94. QuaZIP_LIBRARY_DIRS
  95. QuaZIP_LIBRARIES
  96. QuaZIP_BINARY_DIRS
  97. VERSION_VAR
  98. QuaZIP_VERSION
  99. )