FindGnuplot.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file LICENSE.rst or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindGnuplot
  5. -----------
  6. Finds the Gnuplot command-line graphing utility for generating two- and
  7. three-dimensional plots (``gnuplot``):
  8. .. code-block:: cmake
  9. find_package(Gnuplot [<version>] [...])
  10. Result Variables
  11. ^^^^^^^^^^^^^^^^
  12. This module defines the following variables:
  13. ``Gnuplot_FOUND``
  14. .. versionadded:: 3.3
  15. Boolean indicating whether (the requested version of) Gnuplot was found.
  16. ``Gnuplot_VERSION``
  17. .. versionadded:: 4.2
  18. The version of Gnuplot found.
  19. .. note::
  20. Version detection is available only for Gnuplot 4 and later. Earlier
  21. versions did not provide version output.
  22. Cache Variables
  23. ^^^^^^^^^^^^^^^
  24. The following cache variables may also be set:
  25. ``GNUPLOT_EXECUTABLE``
  26. Absolute path to the ``gnuplot`` executable.
  27. Deprecated Variables
  28. ^^^^^^^^^^^^^^^^^^^^
  29. The following variables are provided for backward compatibility:
  30. ``GNUPLOT_FOUND``
  31. .. deprecated:: 4.2
  32. Use ``Gnuplot_FOUND``, which has the same value.
  33. Boolean indicating whether (the requested version of) Gnuplot was found.
  34. ``GNUPLOT_VERSION_STRING``
  35. .. deprecated:: 4.2
  36. Superseded by the ``Gnuplot_VERSION``.
  37. The version of Gnuplot found.
  38. Examples
  39. ^^^^^^^^
  40. Finding Gnuplot and executing it in a process:
  41. .. code-block:: cmake
  42. find_package(Gnuplot)
  43. if(Gnuplot_FOUND)
  44. execute_process(COMMAND ${GNUPLOT_EXECUTABLE} --help)
  45. endif()
  46. #]=======================================================================]
  47. include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
  48. include(${CMAKE_CURRENT_LIST_DIR}/FindMsys.cmake)
  49. find_program(GNUPLOT_EXECUTABLE
  50. NAMES
  51. gnuplot
  52. pgnuplot
  53. wgnupl32
  54. PATHS
  55. ${CYGWIN_INSTALL_PATH}/bin
  56. ${MSYS_INSTALL_PATH}/usr/bin
  57. )
  58. if (GNUPLOT_EXECUTABLE)
  59. execute_process(COMMAND "${GNUPLOT_EXECUTABLE}" --version
  60. OUTPUT_VARIABLE GNUPLOT_OUTPUT_VARIABLE
  61. ERROR_QUIET
  62. OUTPUT_STRIP_TRAILING_WHITESPACE)
  63. string(REGEX REPLACE "^gnuplot ([0-9\\.]+)( patchlevel )?" "\\1." Gnuplot_VERSION "${GNUPLOT_OUTPUT_VARIABLE}")
  64. string(REGEX REPLACE "\\.$" "" Gnuplot_VERSION "${Gnuplot_VERSION}")
  65. set(GNUPLOT_VERSION_STRING "${Gnuplot_VERSION}")
  66. unset(GNUPLOT_OUTPUT_VARIABLE)
  67. endif()
  68. # for compatibility
  69. set(GNUPLOT ${GNUPLOT_EXECUTABLE})
  70. include(FindPackageHandleStandardArgs)
  71. find_package_handle_standard_args(Gnuplot
  72. REQUIRED_VARS GNUPLOT_EXECUTABLE
  73. VERSION_VAR Gnuplot_VERSION)
  74. mark_as_advanced( GNUPLOT_EXECUTABLE )