FindCART.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # 防止重复引入
  2. if(CART_ALREADY_INCLUDED)
  3. return()
  4. endif()
  5. set(CART_ALREADY_INCLUDED 1)
  6. # find_path 搜索包含某个文件的路径
  7. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  8. find_path(CART_DIRS
  9. NAMES
  10. CARTDll.dll CARTDll.lib
  11. PATHS
  12. ${CMAKE_SOURCE_DIR}/extlib/CART
  13. NO_SYSTEM_ENVIRONMENT_PATH
  14. NO_CMAKE_SYSTEM_PATH
  15. )
  16. set(CART_VERSION_MAJOR 1)
  17. set(CART_VERSION_MINOR 0)
  18. set(CART_VERSION_PATCH 0)
  19. set(CART_VERSION "${CART_VERSION_MAJOR}.${CART_VERSION_MINOR}.${CART_VERSION_PATCH}")
  20. find_path(CART_LIBRARY_DIRS
  21. NAMES
  22. CARTDll.lib
  23. HINTS
  24. ${CART_DIRS}
  25. )
  26. find_path(CART_BINARY_DIRS
  27. NAMES
  28. CARTDll.dll
  29. HINTS
  30. ${CART_DIRS}
  31. )
  32. set(CART_LIBRARIES GJDM::CART)
  33. add_library(GJDM::CART SHARED IMPORTED)
  34. set_property(TARGET GJDM::CART PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CART_INCLUDE_DIRS})
  35. set_property(TARGET GJDM::CART APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  36. set_property(TARGET GJDM::CART APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
  37. set_target_properties(GJDM::CART PROPERTIES
  38. IMPORTED_IMPLIB_DEBUG "${CART_DIRS}/CARTDll.lib"
  39. IMPORTED_LOCATION_DEBUG "${CART_DIRS}/CARTDll.dll"
  40. IMPORTED_IMPLIB_RELEASE "${CART_DIRS}/CARTDll.lib"
  41. IMPORTED_LOCATION_RELEASE "${CART_DIRS}/CARTDll.dll "
  42. )
  43. include(FindPackageHandleStandardArgs)
  44. # 如果找到所有需要的变量,并且版本匹配,则将CART_FOUND变量设置为TRUE
  45. find_package_handle_standard_args(CART
  46. FOUND_VAR
  47. CART_FOUND
  48. REQUIRED_VARS
  49. CART_DIRS
  50. CART_BINARY_DIRS
  51. CART_LIBRARY_DIRS
  52. CART_LIBRARIES
  53. VERSION_VAR
  54. CART_VERSION
  55. )