File: FindPythonVersion.cmake

package info (click to toggle)
cegui-mk2 0.8.7%2Bgit20220615-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,816 kB
  • sloc: cpp: 306,263; python: 1,175; ansic: 812; sh: 616; xml: 191; java: 162; makefile: 21
file content (24 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 execute_process(
      COMMAND
        ${PYTHON_EXECUTABLE} -c "import sys;print (str(sys.version_info[0]) + '.' + str(sys.version_info[1]) + '.' + str(sys.version_info[2]))"
        OUTPUT_VARIABLE PYTHON_VERSION_STRING
        OUTPUT_STRIP_TRAILING_WHITESPACE
        RESULT_VARIABLE RUN_RESULT
 )
set( PYTHON_VERSION_FOUND FALSE)
string(COMPARE EQUAL ${RUN_RESULT} "0" RUN_SUCCESS)
if (RUN_SUCCESS)
   set( PYTHON_VERSION_FOUND TRUE)
   string(REPLACE "." " " _PY_LIST  ${PYTHON_VERSION_STRING} )
   list(LENGTH _PY_LIST _PY_LIST_LEN)
   if ( _PY_LIST_LEN GREATER 0)
      list(GET _PY_LIST 0 PYTHON_VERSION_STRING_MAJOR)
   endif()
   if ( _PY_LIST_LEN GREATER 1)
      list(GET _PY_LIST 0 PYTHON_VERSION_STRING_MINOR)
   endif()
   if ( _PY_LIST_LEN GREATER 2)
      list(GET _PY_LIST 0 PYTHON_VERSION_STRING_MICRO)
   endif()
endif()