Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
bde7b5aa
Commit
bde7b5aa
authored
Jan 27, 2012
by
Rolf Eike Beer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FindPythonInterp: try harder to get a version number
parent
208569f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
Modules/FindPythonInterp.cmake
Modules/FindPythonInterp.cmake
+15
-2
No files found.
Modules/FindPythonInterp.cmake
View file @
bde7b5aa
...
...
@@ -88,8 +88,19 @@ endif()
# determine python version string
if
(
PYTHON_EXECUTABLE
)
execute_process
(
COMMAND
"
${
PYTHON_EXECUTABLE
}
"
--version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE
)
if
(
_VERSION MATCHES
"^Python [0-9]+
\\
.[0-9]+.*"
)
execute_process
(
COMMAND
"
${
PYTHON_EXECUTABLE
}
"
--version
ERROR_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
OUTPUT_QUIET
ERROR_STRIP_TRAILING_WHITESPACE
)
if
(
_PYTHON_VERSION_RESULT
)
execute_process
(
COMMAND
"
${
PYTHON_EXECUTABLE
}
"
-V
ERROR_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
OUTPUT_QUIET
ERROR_STRIP_TRAILING_WHITESPACE
)
endif
(
_PYTHON_VERSION_RESULT
)
if
(
NOT _PYTHON_VERSION_RESULT AND _VERSION MATCHES
"^Python [0-9]+
\\
.[0-9]+.*"
)
string
(
REPLACE
"Python "
""
PYTHON_VERSION_STRING
"
${
_VERSION
}
"
)
string
(
REGEX REPLACE
"^([0-9]+)
\\
.[0-9]+.*"
"
\\
1"
PYTHON_VERSION_MAJOR
"
${
PYTHON_VERSION_STRING
}
"
)
string
(
REGEX REPLACE
"^[0-9]+
\\
.([0-9])+.*"
"
\\
1"
PYTHON_VERSION_MINOR
"
${
PYTHON_VERSION_STRING
}
"
)
...
...
@@ -97,6 +108,8 @@ if(PYTHON_EXECUTABLE)
string
(
REGEX REPLACE
"^[0-9]+
\\
.[0-9]+
\\
.([0-9]+).*"
"
\\
1"
PYTHON_VERSION_PATCH
"
${
PYTHON_VERSION_STRING
}
"
)
endif
()
endif
()
unset
(
_PYTHON_VERSION_RESULT
)
unset
(
_VERSION
)
endif
(
PYTHON_EXECUTABLE
)
# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment