Skip to content

Commit 309f9a1

Browse files
committed
[debuginfo-tests] Don't look for Python 3 if we already have it
LLDB already requires Python 3 on Windows, so I already configure it that way. For some reason CMake fails to find the one that Visual Studio automatically installs at this standard location: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python37_64/python.exe CMake prefers the python on path, which happens to be python 2.7. Reviewers: aprantl, jmorse Differential Revision: https://reviews.llvm.org/D69684
1 parent cb2c4bb commit 309f9a1

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

debuginfo-tests/CMakeLists.txt

+34-25
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,26 @@ set(DEBUGINFO_TEST_DEPS
1313
not
1414
)
1515

16-
# Wipe, uh, previous results
17-
unset(PYTHONINTERP_FOUND CACHE)
18-
unset(PYTHON_EXECUTABLE CACHE)
19-
unset(PYTHON_LIBRARY CACHE)
20-
unset(PYTHON_DLL CACHE)
21-
unset(PYTHON_INCLUDE_DIR CACHE)
22-
unset(PYTHON_VERSION_STRING CACHE)
23-
unset(PYTHON_VERSION_MAJOR CACHE)
24-
unset(PYTHON_VERSION_MINOR CACHE)
25-
unset(PYTHON_VERSION_PATCH CACHE)
26-
unset(PYTHONLIBS_VERSION_STRING CACHE)
16+
# If we don't already have Python 3, throw away any previous results and try to
17+
# find it again.
18+
set(DEBUGINFO_UNSET_PYTHON3 OFF)
19+
if (PYTHON_VERSION_MAJOR LESS 3)
20+
unset(PYTHONINTERP_FOUND CACHE)
21+
unset(PYTHON_EXECUTABLE CACHE)
22+
unset(PYTHON_LIBRARY CACHE)
23+
unset(PYTHON_DLL CACHE)
24+
unset(PYTHON_INCLUDE_DIR CACHE)
25+
unset(PYTHON_VERSION_STRING CACHE)
26+
unset(PYTHON_VERSION_MAJOR CACHE)
27+
unset(PYTHON_VERSION_MINOR CACHE)
28+
unset(PYTHON_VERSION_PATCH CACHE)
29+
unset(PYTHONLIBS_VERSION_STRING CACHE)
30+
31+
# Try to find python3. If it doesn't exist, dexter tests can't run.
32+
find_package(PythonInterp "3")
33+
set(DEBUGINFO_UNSET_PYTHON3 ON)
34+
endif()
2735

28-
# Try to find python3. If it doesn't exist, dexter tests can't run.
29-
find_package(PythonInterp "3")
3036
if (NOT DEFINED PYTHON_EXECUTABLE)
3137
message(FATAL_ERROR "Cannot run debuginfo-tests without python")
3238
elseif(PYTHON_VERSION_MAJOR LESS 3)
@@ -43,17 +49,20 @@ else()
4349
${CMAKE_CURRENT_BINARY_DIR}
4450
DEPENDS ${DEBUGINFO_TEST_DEPS}
4551
)
46-
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
52+
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
4753
endif()
4854

49-
# Prevent the rest of llvm observing our secret python3-ness
50-
unset(PYTHONINTERP_FOUND CACHE)
51-
unset(PYTHON_EXECUTABLE CACHE)
52-
unset(PYTHON_LIBRARY CACHE)
53-
unset(PYTHON_DLL CACHE)
54-
unset(PYTHON_INCLUDE_DIR CACHE)
55-
unset(PYTHON_VERSION_STRING CACHE)
56-
unset(PYTHON_VERSION_MAJOR CACHE)
57-
unset(PYTHON_VERSION_MINOR CACHE)
58-
unset(PYTHON_VERSION_PATCH CACHE)
59-
unset(PYTHONLIBS_VERSION_STRING CACHE)
55+
# Prevent the rest of llvm observing our secret python3-ness, if that wasn't
56+
# what was originally found.
57+
if (DEBUGINFO_UNSET_PYTHON3)
58+
unset(PYTHONINTERP_FOUND CACHE)
59+
unset(PYTHON_EXECUTABLE CACHE)
60+
unset(PYTHON_LIBRARY CACHE)
61+
unset(PYTHON_DLL CACHE)
62+
unset(PYTHON_INCLUDE_DIR CACHE)
63+
unset(PYTHON_VERSION_STRING CACHE)
64+
unset(PYTHON_VERSION_MAJOR CACHE)
65+
unset(PYTHON_VERSION_MINOR CACHE)
66+
unset(PYTHON_VERSION_PATCH CACHE)
67+
unset(PYTHONLIBS_VERSION_STRING CACHE)
68+
endif()

0 commit comments

Comments
 (0)