FindTecIO.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # FindTecIO
  2. # --------
  3. #
  4. # Find the TecIO libraries(Only for TecIO provided by FastCAE)
  5. #
  6. # Result Variables
  7. # ^^^^^^^^^^^^^^^^
  8. #
  9. # The following variables will be defined:
  10. #
  11. # ``TecIO_FOUND`` True if TecIO found on the local system
  12. #
  13. # ``TecIO_VERSION`` TecIO Version(x.x.x)
  14. #
  15. # ``TecIO_VERSION_MAJOR`` TecIO Major Version
  16. #
  17. # ``TecIO_VERSION_MINOR`` TecIO Minor Version
  18. #
  19. # ``TecIO_VERSION_PATCH`` TecIO Patch Version
  20. #
  21. # ``TecIO_DIRS`` Location of TecIO(root dir)
  22. #
  23. # ``TecIO_INCLUDE_DIRS`` Location of TecIO header files
  24. #
  25. # ``TecIO_LIBRARY_DIRS`` Location of TecIO libraries
  26. #
  27. # ``TecIO_LIBRARIES`` List of the TecIO libraries found
  28. #
  29. # 防止重复引入
  30. if(GJDM_TecIO_ALREADY_INCLUDED)
  31. return()
  32. endif()
  33. set(GJDM_TecIO_ALREADY_INCLUDED 1)
  34. # find_path 搜索包含某个文件的路径
  35. # 如果在某个路径下发现了该文件,该结果会被存储到该变量中;如果没有找到,存储的结果将会是<VAR>-NOTFOUND
  36. find_path(TecIO_DIRS
  37. NAMES
  38. include/TECIO.h
  39. PATHS
  40. ${CMAKE_SOURCE_DIR}/extlib/TecIO
  41. NO_SYSTEM_ENVIRONMENT_PATH
  42. NO_CMAKE_SYSTEM_PATH
  43. )
  44. set(TecIO_VERSION_MAJOR 1)
  45. set(TecIO_VERSION_MINOR 4)
  46. set(TecIO_VERSION_PATCH 2)
  47. set(TecIO_VERSION "${TecIO_VERSION_MAJOR}.${TecIO_VERSION_MINOR}.${TecIO_VERSION_PATCH}")
  48. find_path(TecIO_INCLUDE_DIRS
  49. NAMES
  50. TECIO.h
  51. HINTS
  52. ${TecIO_DIRS}/include
  53. )
  54. find_path(TecIO_LIBRARY_DIRS
  55. NAMES
  56. tecio.lib libtecio.so
  57. HINTS
  58. ${TecIO_DIRS}/lib
  59. )
  60. set(TecIO_LIBRARIES GJDM::TECIO)
  61. add_library(GJDM::TECIO SHARED IMPORTED)
  62. set_property(TARGET GJDM::TECIO PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TecIO_INCLUDE_DIRS})
  63. set_property(TARGET GJDM::TECIO APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  64. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  65. set_target_properties(GJDM::TECIO PROPERTIES
  66. IMPORTED_LOCATION_RELEASE "${TecIO_LIBRARY_DIRS}/libtecio.so"
  67. #IMPORTED_SONAME_RELEASE "${TecIO_LIBRARY_DIRS}/libtecio.so"
  68. )
  69. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  70. set_target_properties(GJDM::TECIO PROPERTIES
  71. IMPORTED_IMPLIB_RELEASE "${TecIO_LIBRARY_DIRS}/tecio.lib"
  72. IMPORTED_LOCATION_RELEASE "${TecIO_DIRS}/bin/tecio.dll"
  73. )
  74. endif()
  75. include(FindPackageHandleStandardArgs)
  76. # 如果找到所有需要的变量,并且版本匹配,则将TecIO_FOUND变量设置为TRUE
  77. find_package_handle_standard_args(TecIO
  78. FOUND_VAR
  79. TecIO_FOUND
  80. REQUIRED_VARS
  81. TecIO_DIRS
  82. TecIO_INCLUDE_DIRS
  83. TecIO_LIBRARY_DIRS
  84. TecIO_LIBRARIES
  85. VERSION_VAR
  86. TecIO_VERSION
  87. )