File: FindMatplotlib.cmake

package info (click to toggle)
freecad 0.16%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 160,336 kB
  • ctags: 87,760
  • sloc: cpp: 433,808; python: 214,747; xml: 9,030; ansic: 6,204; fortran: 3,878; lex: 492; yacc: 238; sh: 143; makefile: 17
file content (45 lines) | stat: -rw-r--r-- 2,112 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# - Find the matplotlib libraries
# This module finds IF matplotlib is installed, and sets the following variables
# indicating where it is.
#
#  MATPLOTLIB_FOUND            - was matplotlib found
#  MATPLOTLIB_VERSION          - the version of matplotlib found as a string
#  MATPLOTLIB_VERSION_MAJOR    - the major version number of matplotlib
#  MATPLOTLIB_VERSION_MINOR    - the minor version number of matplotlib
#  MATPLOTLIB_VERSION_PATCH    - the patch version number of matplotlib
#  MATPLOTLIB_PATH_DIRS        - path to the matplotlib include files

IF(PYTHONINTERP_FOUND)
    # Try to import matplotlib into Python interpreter. Python
    # interpreter was found previously as required package, so
    # don't take care about this.
    execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
        "import matplotlib as m; print(m.__version__); print(m.__path__[0]);"
        RESULT_VARIABLE _MATPLOTLIB_SEARCH_SUCCESS
        OUTPUT_VARIABLE _MATPLOTLIB_VALUES
        ERROR_VARIABLE _MATPLOTLIB_ERROR_VALUE
        OUTPUT_STRIP_TRAILING_WHITESPACE)

    IF(_MATPLOTLIB_SEARCH_SUCCESS MATCHES 0)
        set(MATPLOTLIB_FOUND TRUE)

        # Convert the process output into a list
        string(REGEX REPLACE ";" "\\\\;" _MATPLOTLIB_VALUES ${_MATPLOTLIB_VALUES})
        string(REGEX REPLACE "\n" ";" _MATPLOTLIB_VALUES ${_MATPLOTLIB_VALUES})
        list(GET _MATPLOTLIB_VALUES 0 MATPLOTLIB_VERSION)
        list(GET _MATPLOTLIB_VALUES 1 MATPLOTLIB_PATH_DIRS)

        # Make sure all directory separators are '/'
        string(REGEX REPLACE "\\\\" "/" MATPLOTLIB_PATH_DIRS ${MATPLOTLIB_PATH_DIRS})

        # Get the major and minor version numbers
        string(REGEX REPLACE "\\." ";" _MATPLOTLIB_VERSION_LIST ${MATPLOTLIB_VERSION})
        list(GET _MATPLOTLIB_VERSION_LIST 0 MATPLOTLIB_VERSION_MAJOR)
        list(GET _MATPLOTLIB_VERSION_LIST 1 MATPLOTLIB_VERSION_MINOR)
        list(GET _MATPLOTLIB_VERSION_LIST 2 MATPLOTLIB_VERSION_PATCH)
    ELSE()
        set(MATPLOTLIB_FOUND FALSE)
    ENDIF()
ELSE()
    set(MATPLOTLIB_FOUND FALSE)
ENDIF()