Ryan Prichard | 7aea7e9 | 2022-01-13 17:30:17 -0800 | [diff] [blame] | 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 | # file Copyright.txt or https://cmake.org/licensing for details. |
| 3 | |
| 4 | #[=======================================================================[.rst: |
| 5 | FindGnuplot |
| 6 | ----------- |
| 7 | |
| 8 | this module looks for gnuplot |
| 9 | |
| 10 | |
| 11 | |
| 12 | Once done this will define |
| 13 | |
| 14 | :: |
| 15 | |
| 16 | GNUPLOT_FOUND - system has Gnuplot |
| 17 | GNUPLOT_EXECUTABLE - the Gnuplot executable |
| 18 | GNUPLOT_VERSION_STRING - the version of Gnuplot found (since CMake 2.8.8) |
| 19 | |
| 20 | |
| 21 | |
| 22 | GNUPLOT_VERSION_STRING will not work for old versions like 3.7.1. |
| 23 | #]=======================================================================] |
| 24 | |
| 25 | include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) |
| 26 | include(${CMAKE_CURRENT_LIST_DIR}/FindMsys.cmake) |
| 27 | |
| 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 |
| 36 | ) |
| 37 | |
| 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) |
| 43 | |
| 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() |
| 48 | |
| 49 | # for compatibility |
| 50 | set(GNUPLOT ${GNUPLOT_EXECUTABLE}) |
| 51 | |
| 52 | include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) |
| 53 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gnuplot |
| 54 | REQUIRED_VARS GNUPLOT_EXECUTABLE |
| 55 | VERSION_VAR GNUPLOT_VERSION_STRING) |
| 56 | |
| 57 | mark_as_advanced( GNUPLOT_EXECUTABLE ) |