FindQwt.cmake 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # FindQwt
  2. # 防止重复引入
  3. if(GJDM_Qwt_ALREADY_INCLUDED)
  4. return()
  5. endif()
  6. set(GJDM_Qwt_ALREADY_INCLUDED 1)
  7. # find_path 搜索包含某个文件的路径
  8. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  9. find_path(Qwt_DIRS
  10. NAMES
  11. include/qwt.h
  12. PATHS
  13. ${CMAKE_SOURCE_DIR}/extlib/Qwt
  14. NO_SYSTEM_ENVIRONMENT_PATH
  15. NO_CMAKE_SYSTEM_PATH
  16. )
  17. set(Qwt_VERSION_MAJOR 6)
  18. set(Qwt_VERSION_MINOR 1)
  19. set(Qwt_VERSION_PATCH 6)
  20. set(QwtPolar_VERSION_MAJOR 1)
  21. set(QwtPolar_VERSION_MINOR 1)
  22. set(QwtPolar_VERSION_PATCH 1)
  23. set(Qwt_VERSION "${Qwt_VERSION_MAJOR}.${Qwt_VERSION_MINOR}.${Qwt_VERSION_PATCH}")
  24. set(QwtPolar_VERSION "${QwtPolar_VERSION_MAJOR}.${QwtPolar_VERSION_MINOR}.${QwtPolar_VERSION_PATCH}")
  25. find_path(Qwt_INCLUDE_DIRS
  26. NAMES
  27. qwt.h
  28. HINTS
  29. ${Qwt_DIRS}/include
  30. )
  31. find_path(Qwt_LIBRARY_DIRS
  32. NAMES
  33. qwt.lib libqwt.so
  34. HINTS
  35. ${Qwt_DIRS}/lib
  36. )
  37. find_path(Qwt_BINARY_DIRS
  38. NAMES
  39. qwt.dll libqwt.so
  40. HINTS
  41. ${Qwt_DIRS}/lib
  42. )
  43. set(Qwt_LIBRARIES GJDM::QWT;GJDM::QWTPOLAR)
  44. add_library(GJDM::QWT SHARED IMPORTED)
  45. add_library(GJDM::QWTPOLAR SHARED IMPORTED)
  46. set_property(TARGET GJDM::QWT PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Qwt_INCLUDE_DIRS})
  47. set_property(TARGET GJDM::QWT APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  48. set_property(TARGET GJDM::QWT PROPERTY INTERFACE_LINK_LIBRARIES Qt5::Svg Qt5::OpenGL)
  49. set_property(TARGET GJDM::QWT PROPERTY INTERFACE_COMPILE_DEFINITIONS "QWT_DLL")
  50. set_property(TARGET GJDM::QWTPOLAR PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Qwt_INCLUDE_DIRS})
  51. set_property(TARGET GJDM::QWTPOLAR APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  52. set_property(TARGET GJDM::QWTPOLAR PROPERTY INTERFACE_LINK_LIBRARIES GJDM::QWT Qt5::PrintSupport)
  53. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  54. set_target_properties(GJDM::QWT PROPERTIES
  55. IMPORTED_LOCATION_RELEASE "${Qwt_LIBRARY_DIRS}/libqwt.so.${Qwt_VERSION_MAJOR}.${Qwt_VERSION_MINOR}.${Qwt_VERSION_PATCH}"
  56. IMPORTED_SONAME_RELEASE "libqwt.so.${Qwt_VERSION_MAJOR}"
  57. )
  58. set_target_properties(GJDM::QWTPOLAR PROPERTIES
  59. IMPORTED_LOCATION_RELEASE "${Qwt_LIBRARY_DIRS}/libqwtpolar.so.${QwtPolar_VERSION_MAJOR}.${QwtPolar_VERSION_MINOR}.${QwtPolar_VERSION_PATCH}"
  60. IMPORTED_SONAME_RELEASE "libqwtpolar.so.${QwtPolar_VERSION_MAJOR}"
  61. )
  62. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  63. set_property(TARGET GJDM::QWT APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
  64. set_property(TARGET GJDM::QWTPOLAR APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
  65. set_target_properties(GJDM::QWT PROPERTIES
  66. IMPORTED_IMPLIB_RELEASE "${Qwt_LIBRARY_DIRS}/qwt.lib"
  67. IMPORTED_LOCATION_RELEASE "${Qwt_BINARY_DIRS}/qwt.dll"
  68. IMPORTED_IMPLIB_DEBUG "${Qwt_LIBRARY_DIRS}/qwtd.lib"
  69. IMPORTED_LOCATION_DEBUG "${Qwt_BINARY_DIRS}/qwtd.dll"
  70. )
  71. set_target_properties(GJDM::QWTPOLAR PROPERTIES
  72. IMPORTED_IMPLIB_RELEASE "${Qwt_LIBRARY_DIRS}/qwtpolar.lib"
  73. IMPORTED_LOCATION_RELEASE "${Qwt_BINARY_DIRS}/qwtpolar.dll"
  74. IMPORTED_IMPLIB_DEBUG "${Qwt_LIBRARY_DIRS}/qwtpolard.lib"
  75. IMPORTED_LOCATION_DEBUG "${Qwt_BINARY_DIRS}/qwtpolard.dll"
  76. )
  77. endif()
  78. include(FindPackageHandleStandardArgs)
  79. # 如果找到所有需要的变量,并且版本匹配,则将Qwt_FOUND变量设置为TRUE
  80. find_package_handle_standard_args(Qwt
  81. FOUND_VAR
  82. Qwt_FOUND
  83. REQUIRED_VARS
  84. Qwt_DIRS
  85. Qwt_INCLUDE_DIRS
  86. Qwt_LIBRARY_DIRS
  87. Qwt_LIBRARIES
  88. Qwt_BINARY_DIRS
  89. VERSION_VAR
  90. Qwt_VERSION
  91. )