Merge branch 'release-4.0'
[kiteware-cmake.git] / Modules / FindGnuplot.cmake
blob07cfbd39f136b9b20d927b2f742fdb0d098e4603
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 FindGnuplot
6 -----------
8 This module looks for gnuplot.
10 Result Variables
11 ^^^^^^^^^^^^^^^^
13 ``GNUPLOT_FOUND``
14   System has Gnuplot.
16 ``GNUPLOT_EXECUTABLE``
17   The Gnuplot executable.
19 ``GNUPLOT_VERSION_STRING``
20   The version of Gnuplot found.
22   .. note:: Version string detection will not work for old versions like 3.7.1.
23 #]=======================================================================]
25 include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
26 include(${CMAKE_CURRENT_LIST_DIR}/FindMsys.cmake)
28 find_program(GNUPLOT_EXECUTABLE
29   NAMES
30   gnuplot
31   pgnuplot
32   wgnupl32
33   PATHS
34   ${CYGWIN_INSTALL_PATH}/bin
35   ${MSYS_INSTALL_PATH}/usr/bin
38 if (GNUPLOT_EXECUTABLE)
39     execute_process(COMMAND "${GNUPLOT_EXECUTABLE}" --version
40                   OUTPUT_VARIABLE GNUPLOT_OUTPUT_VARIABLE
41                   ERROR_QUIET
42                   OUTPUT_STRIP_TRAILING_WHITESPACE)
44     string(REGEX REPLACE "^gnuplot ([0-9\\.]+)( patchlevel )?" "\\1." GNUPLOT_VERSION_STRING "${GNUPLOT_OUTPUT_VARIABLE}")
45     string(REGEX REPLACE "\\.$" "" GNUPLOT_VERSION_STRING "${GNUPLOT_VERSION_STRING}")
46     unset(GNUPLOT_OUTPUT_VARIABLE)
47 endif()
49 # for compatibility
50 set(GNUPLOT ${GNUPLOT_EXECUTABLE})
52 include(FindPackageHandleStandardArgs)
53 find_package_handle_standard_args(Gnuplot
54                                   REQUIRED_VARS GNUPLOT_EXECUTABLE
55                                   VERSION_VAR GNUPLOT_VERSION_STRING)
57 mark_as_advanced( GNUPLOT_EXECUTABLE )