1 # ============================================================================ 2 # Copyright (c) 2011-2012 University of Pennsylvania 3 # Copyright (c) 2013-2016 Andreas Schuh 6 # See COPYING file for license information or visit 7 # https://cmake-basis.github.io/download.html#license 8 # ============================================================================ 10 ############################################################################## 11 # @file InterpTools.cmake 12 # @brief Script interpreter tools. 15 ############################################################################## 24 ## @addtogroup CMakeUtilities 28 # ---------------------------------------------------------------------------- 29 ## @brief Get version of Python interpreter. 31 # @param [out] ARGV1 If given, the named variable is set to the version string 32 # of the Python interpreter. Otherwise, the variables 33 # @c PYTHON_VERSION_STRING, @c PYTHON_VERSION_MAJOR, 34 # @c PYTHON_VERSION_MINOR, and @c PYTHON_VERSION_PATCH are 35 # set in the scope of the caller. 37 if (PYTHON_EXECUTABLE)
39 COMMAND "${PYTHON_EXECUTABLE}" -E -c
"import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" 45 string (REPLACE
";" "." VERSION_STRING
"${VERSION}")
50 string (REGEX REPLACE
"\\.0$" "" VERSION_STRING
"${VERSION_STRING}")
53 # sys.version predates sys.version_info 55 COMMAND "${PYTHON_EXECUTABLE}" -E -c
"import sys; sys.stdout.write(sys.version)" 61 string (REGEX REPLACE
" .*" "" VERSION_STRING
"${VERSION}")
62 string (REGEX REPLACE
"^([0-9]+)\\.[0-9]+.*" "\\1" VERSION_MAJOR "${VERSION_STRING}")
63 string (REGEX REPLACE
"^[0-9]+\\.([0-9])+.*" "\\1" VERSION_MINOR "${VERSION_STRING}")
64 if (VERSION_STRING MATCHES
"^[0-9]+\\.[0-9]+\\.[0-9]+.*")
65 string (REGEX REPLACE
"^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION_STRING}")
70 # sys.version was first documented for Python 1.5 71 set (VERSION_STRING
"1.4")
78 set (VERSION_STRING "0.0")
84 set (${ARGV0}
"${VERSION_STRING}" PARENT_SCOPE)
93 # ---------------------------------------------------------------------------- 94 ## @brief Get version of Jython interpreter. 96 # @param [out] ARGV1 If given, the named variable is set to the version string 97 # of the Jython interpreter. Otherwise, the variables 98 # @c JYTHON_VERSION_STRING, @c JYTHON_VERSION_MAJOR, 99 # @c JYTHON_VERSION_MINOR, and @c JYTHON_VERSION_PATCH are 100 # set in the scope of the caller. 102 if (JYTHON_EXECUTABLE)
104 COMMAND "${JYTHON_EXECUTABLE}" -c
"import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" 110 string (REPLACE
";" "." VERSION_STRING
"${VERSION}")
114 if (VERSION_PATCH EQUAL 0)
115 string (REGEX REPLACE
"\\.0$" "" VERSION_STRING
"${VERSION_STRING}")
118 # sys.version predates sys.version_info 120 COMMAND "${JYTHON_EXECUTABLE}" -c
"import sys; sys.stdout.write(sys.version)" 126 string (REGEX REPLACE
" .*" "" VERSION_STRING
"${VERSION}")
127 string (REGEX REPLACE
"^([0-9]+)\\.[0-9]+.*" "\\1" VERSION_MAJOR
"${VERSION_STRING}")
128 string (REGEX REPLACE
"^[0-9]+\\.([0-9])+.*" "\\1" VERSION_MINOR
"${VERSION_STRING}")
129 if (VERSION_STRING MATCHES
"^[0-9]+\\.[0-9]+\\.[0-9]+.*")
130 string (REGEX REPLACE
"^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH
"${VERSION_STRING}")
132 set (VERSION_PATCH
"0")
135 set (VERSION_STRING
"0.0")
136 set (VERSION_MAJOR
"0")
137 set (VERSION_MINOR
"0")
138 set (VERSION_PATCH
"0")
142 set (VERSION_STRING
"0.0")
143 set (VERSION_MAJOR
"0")
144 set (VERSION_MINOR
"0")
145 set (VERSION_PATCH
"0")
148 set (${ARGV0}
"${VERSION_STRING}" PARENT_SCOPE)
150 set (JYTHON_VERSION_STRING
"${VERSION_STRING}" PARENT_SCOPE)
151 set (JYTHON_VERSION_MAJOR
"${VERSION_MAJOR}" PARENT_SCOPE)
152 set (JYTHON_VERSION_MINOR
"${VERSION_MINOR}" PARENT_SCOPE)
157 # ---------------------------------------------------------------------------- 158 ## @brief Get version of Perl interpreter. 160 # @param [out] ARGV1 If given, the named variable is set to the version string 161 # of the Perl interpreter. Otherwise, the variables 162 # @c PERL_VERSION_STRING, @c PERL_VERSION_MAJOR, 163 # @c PERL_VERSION_MINOR, and @c PERL_VERSION_PATCH are 164 # set in the scope of the caller. 167 execute_process (
COMMAND "${PERL_EXECUTABLE}" --version OUTPUT_VARIABLE
VERSION)
171 if (VERSION MATCHES
"[( ]v([0-9]+)\\.([0-9]+)\\.([0-9]+)[ )]")
172 set (VERSION_MAJOR
"${CMAKE_MATCH_1}")
173 set (VERSION_MINOR
"${CMAKE_MATCH_2}")
174 set (VERSION_PATCH
"${CMAKE_MATCH_3}")
175 set (VERSION_STRING
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
177 set (VERSION_STRING
"0.0")
178 set (VERSION_MAJOR
"0")
179 set (VERSION_MINOR
"0")
180 set (VERSION_PATCH
"0")
183 set (${ARGV0}
"${VERSION_STRING}" PARENT_SCOPE)
192 # ---------------------------------------------------------------------------- 193 ## @brief Get version of Bash interpreter. 195 # @param [out] ARGV1 If given, the named variable is set to the version string 196 # of the Bash interpreter. Otherwise, the variables 197 # @c BASH_VERSION_STRING, @c BASH_VERSION_MAJOR, 198 # @c BASH_VERSION_MINOR, and @c BASH_VERSION_PATCH are 199 # set in the scope of the caller. 202 execute_process (
COMMAND "${BASH_EXECUTABLE}" --version OUTPUT_VARIABLE VERSION)
206 if (VERSION MATCHES
"version ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
207 set (VERSION_MAJOR
"${CMAKE_MATCH_1}")
208 set (VERSION_MINOR
"${CMAKE_MATCH_2}")
209 set (VERSION_PATCH
"${CMAKE_MATCH_3}")
210 set (VERSION_STRING
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
212 set (VERSION_STRING
"0.0")
213 set (VERSION_MAJOR
"0")
214 set (VERSION_MINOR
"0")
215 set (VERSION_PATCH
"0")
218 set (${ARGV0}
"${VERSION_STRING}" PARENT_SCOPE)
229 # end of Doxygen group const unsigned int VERSION_MAJOR
The major version number.
cmake PERL_VERSION_STRING
function basis_get_bash_version(out ARGV1)
Get version of Bash interpreter.
cmake BASH_VERSION_STRING
cmake PYTHON_VERSION_MINOR
cmake PYTHON_VERSION_PATCH
function basis_get_perl_version(out ARGV1)
Get version of Perl interpreter.
function basis_get_python_version(out ARGV1)
Get version of Python interpreter.
string VERSION
Project version.
cmake PYTHON_VERSION_MAJOR
cmake JYTHON_VERSION_PATCH
function basis_get_jython_version(out ARGV1)
Get version of Jython interpreter.
const unsigned int VERSION_MINOR
The minor version number.
const unsigned int VERSION_PATCH
The patch number.
cmake PYTHON_VERSION_STRING