FindGmsh.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # 防止重复引入
  2. if(Gmsh_ALREADY_INCLUDED)
  3. return()
  4. endif()
  5. set(Gmsh_ALREADY_INCLUDED 1)
  6. # find_path 搜索包含某个文件的路径
  7. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  8. find_path(Gmsh_DIRS
  9. NAMES
  10. gmsh.exe gmsh
  11. PATHS
  12. ${CMAKE_SOURCE_DIR}/extlib/Gmsh
  13. NO_SYSTEM_ENVIRONMENT_PATH
  14. NO_CMAKE_SYSTEM_PATH
  15. )
  16. set(Gmsh_VERSION_MAJOR 4)
  17. set(Gmsh_VERSION_MINOR 8)
  18. set(Gmsh_VERSION_PATCH 0)
  19. set(Gmsh_VERSION "${Gmsh_VERSION_MAJOR}.${Gmsh_VERSION_MINOR}.${Gmsh_VERSION_PATCH}")
  20. # find_path(Gmsh_INCLUDE_DIRS
  21. # NAMES
  22. # gmsh.h
  23. # HINTS
  24. # ${Gmsh_DIRS}
  25. # )
  26. # find_path(Gmsh_LIBRARY_DIRS
  27. # NAMES
  28. # libgmsh.so.4.11
  29. # HINTS
  30. # ${Gmsh_DIRS}
  31. # )
  32. # set(Gmsh_LIBRARIES GJDM::Gmsh)
  33. if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  34. set(Gmsh_EXECUTABLE "${Gmsh_DIRS}/gmsh.exe")
  35. else()
  36. set(Gmsh_EXECUTABLE "${Gmsh_DIRS}/gmsh")
  37. endif()
  38. include(FindPackageHandleStandardArgs)
  39. # 如果找到所有需要的变量,并且版本匹配,则将Gmsh_FOUND变量设置为TRUE
  40. find_package_handle_standard_args(Gmsh
  41. FOUND_VAR
  42. Gmsh_FOUND
  43. REQUIRED_VARS
  44. Gmsh_DIRS
  45. Gmsh_EXECUTABLE
  46. VERSION_VAR
  47. Gmsh_VERSION
  48. )