FindIR.cmake 1020 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # 防止重复引用
  2. if(IR_ALREADY_INCLUDED)
  3. return()
  4. endif()
  5. set(IR_ALREADY_INCLUDED 1)
  6. # find_path 搜索包含某个文件的路径
  7. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  8. find_path(IR_DIRS
  9. NAMES
  10. Optical-RMC-Code.exe
  11. PATHS
  12. ${CMAKE_SOURCE_DIR}/extlib/IR
  13. NO_SYSTEM_ENVIRONMENT_PATH
  14. NO_CMAKE_SYSTEM_PATH
  15. )
  16. # IR版本号设置
  17. set(IR_VERSION_MAJOR 1)
  18. set(IR_VERSION_MINOR 0)
  19. set(IR_VERSION_PATCH 0)
  20. set(IR_VERSION "${IR_VERSION_MAJOR}.${IR_VERSION_MINOR}.${IR_VERSION_PATCH}")
  21. if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  22. set(IR_EXECUTABLE "${IR_DIRS}/Optical-RMC-Code.exe")
  23. endif()
  24. include(FindPackageHandleStandardArgs)
  25. # 如果找到所有需要的变量,并且版本匹配,则将IR_FOUND变量设置为TRUE
  26. find_package_handle_standard_args(IR
  27. FOUND_VAR
  28. IR_FOUND
  29. REQUIRED_VARS
  30. IR_DIRS
  31. IR_EXECUTABLE
  32. VERSION_VAR
  33. IR_VERSION
  34. )