FindGmsh.cmake 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # FindGmsh
  2. # --------
  3. #
  4. # Find the Gmsh exe (Only for Gmsh provided by FastCAE)
  5. #
  6. # Result Variables
  7. # ^^^^^^^^^^^^^^^^
  8. #
  9. # The following variables will be defined:
  10. #
  11. # ``Gmsh_FOUND`` True if Gmsh found on the local system
  12. #
  13. # ``Gmsh_VERSION`` Gmsh Version(x.x.x)
  14. #
  15. # ``Gmsh_VERSION_MAJOR`` Gmsh Major Version
  16. #
  17. # ``Gmsh_VERSION_MINOR`` Gmsh Minor Version
  18. #
  19. # ``Gmsh_VERSION_PATCH`` Gmsh Patch Version
  20. #
  21. # ``Gmsh_DIRS`` Location of Gmsh(root dir)
  22. #
  23. # ``Gmsh_EXECUTABLE`` Location of Gmsh program
  24. #
  25. # 防止重复引入
  26. if(Gmsh_ALREADY_INCLUDED)
  27. return()
  28. endif()
  29. set(Gmsh_ALREADY_INCLUDED 1)
  30. # find_path 搜索包含某个文件的路径
  31. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  32. find_path(Gmsh_DIRS
  33. NAMES
  34. gmsh.exe gmsh
  35. PATHS
  36. ${CMAKE_SOURCE_DIR}/extlib/Gmsh
  37. NO_SYSTEM_ENVIRONMENT_PATH
  38. NO_CMAKE_SYSTEM_PATH
  39. )
  40. set(Gmsh_VERSION_MAJOR 4)
  41. set(Gmsh_VERSION_MINOR 8)
  42. set(Gmsh_VERSION_PATCH 0)
  43. set(Gmsh_VERSION "${Gmsh_VERSION_MAJOR}.${Gmsh_VERSION_MINOR}.${Gmsh_VERSION_PATCH}")
  44. if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  45. set(Gmsh_EXECUTABLE "${Gmsh_DIRS}/gmsh.exe")
  46. else()
  47. set(Gmsh_EXECUTABLE "${Gmsh_DIRS}/gmsh")
  48. endif()
  49. include(FindPackageHandleStandardArgs)
  50. # 如果找到所有需要的变量,并且版本匹配,则将Gmsh_FOUND变量设置为TRUE
  51. find_package_handle_standard_args(Gmsh
  52. FOUND_VAR
  53. Gmsh_FOUND
  54. REQUIRED_VARS
  55. Gmsh_DIRS
  56. Gmsh_EXECUTABLE
  57. VERSION_VAR
  58. Gmsh_VERSION
  59. )