4
4
5
5
macro (Python_BUILD_EXTENSION Python_BUILD_VERSION)
6
6
7
+ # Unfortunately, we can't use the cache because it treats 2 and 3 the same, so
8
+ # we wouldn't be able to compile against both.
9
+ foreach (_python_var
10
+ PYTHONINTERP_FOUND PYTHON_EXECUTABLE PYTHON_VERSION_STRING
11
+ PYTHON_VERSION_MAJOR PYTHON_VERSION_MINOR PYTHON_VERSION_PATCH)
12
+ unset (${_python_var} )
13
+ unset (${_python_var} CACHE )
14
+ endforeach (_python_var)
15
+ foreach (_python_var
16
+ PYTHONLIBS_FOUND PYTHONLIBS_VERSION_STRING PYTHON_DEBUG_LIBRARIES
17
+ PYTHON_INCLUDE_DIR PYTHON_INCLUDE_DIRS PYTHON_INCLUDE_PATH PYTHON_LIBRARIES
18
+ PYTHON_LIBRARY PYTHON_LIBRARY_DEBUG)
19
+ unset (${_python_var} )
20
+ unset (${_python_var} CACHE )
21
+ endforeach (_python_var)
22
+
7
23
set (Python_ADDITIONAL_VERSIONS ${Python_BUILD_VERSION} )
8
24
find_package (PythonInterp)
9
25
set (PYTHON${Python_BUILD_VERSION} INTERP_FOUND ${PYTHONINTERP_FOUND} )
@@ -21,6 +37,16 @@ set(PYTHON${Python_BUILD_VERSION}_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
21
37
set (PYTHON${Python_BUILD_VERSION} _LIBRARIES ${PYTHON_LIBRARIES} )
22
38
find_program (CYTHON_EXECUTABLE cython)
23
39
40
+ if (NOT ${PYTHON${Python_BUILD_VERSION} _VERSION_MAJOR} EQUAL ${Python_BUILD_VERSION} )
41
+ message (FATAL_ERROR "Unable to find Python ${Python_BUILD_VERSION} interpreter." )
42
+ endif ()
43
+ if (NOT ${PYTHON${Python_BUILD_VERSION} _VERSION_STRING} EQUAL ${PYTHON${Python_BUILD_VERSION} LIBS_VERSION_STRING})
44
+ message (FATAL_ERROR
45
+ "Unable to find consistent Python ${Python_BUILD_VERSION} libraries. "
46
+ "Python interpreter is ${PYTHON${Python_BUILD_VERSION} _VERSION_STRING}, "
47
+ "but libraries are ${PYTHON${Python_BUILD_VERSION} LIBS_VERSION_STRING}." )
48
+ endif ()
49
+
24
50
# Figure out installation path
25
51
execute_process (COMMAND
26
52
${PYTHON${Python_BUILD_VERSION} _EXECUTABLE}
0 commit comments