Skip to content

Commit 1aba9f3

Browse files
committed
py3k: Clear cached CMake vars so that 2+3 builds work.
Signed-off-by: Elliott Sales de Andrade <[email protected]>
1 parent 3579e20 commit 1aba9f3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

wrappers/python/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44

55
macro(Python_BUILD_EXTENSION Python_BUILD_VERSION)
66

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+
723
set(Python_ADDITIONAL_VERSIONS ${Python_BUILD_VERSION})
824
find_package(PythonInterp)
925
set(PYTHON${Python_BUILD_VERSION}INTERP_FOUND ${PYTHONINTERP_FOUND})
@@ -21,6 +37,16 @@ set(PYTHON${Python_BUILD_VERSION}_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
2137
set(PYTHON${Python_BUILD_VERSION}_LIBRARIES ${PYTHON_LIBRARIES})
2238
find_program(CYTHON_EXECUTABLE cython)
2339

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+
2450
# Figure out installation path
2551
execute_process(COMMAND
2652
${PYTHON${Python_BUILD_VERSION}_EXECUTABLE}

0 commit comments

Comments
 (0)