Skip to content

Commit 8b34fea

Browse files
check if the Python target is defined
1 parent 6ee7fce commit 8b34fea

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lldb/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ if (LLDB_ENABLE_PYTHON)
8787
set(LLDB_PYTHON_EXT_SUFFIX "_d${LLDB_PYTHON_EXT_SUFFIX}")
8888
endif()
8989
endif()
90-
get_target_property(_Python3_LIB_PATH Python3::Python IMPORTED_LIBRARY_LOCATION)
91-
if(_Python3_LIB_PATH)
92-
get_filename_component(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME "${_Python3_LIB_PATH}" NAME)
90+
if(TARGET Python3::Python)
91+
get_target_property(_Python3_LIB_PATH Python3::Python IMPORTED_LIBRARY_LOCATION)
92+
if(_Python3_LIB_PATH)
93+
get_filename_component(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME "${_Python3_LIB_PATH}" NAME)
94+
endif()
9395
endif()
9496
endif ()
9597

lldb/tools/driver/Driver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,8 @@ inline std::wstring GetPathToExecutableW() {
455455
/// `false` otherwise.
456456
bool AddPythonDLLToSearchPath() {
457457
std::wstring modulePath = GetPathToExecutableW();
458-
if (modulePath.empty()) {
458+
if (modulePath.empty())
459459
return false;
460-
}
461460

462461
SmallVector<char, MAX_PATH> utf8Path;
463462
if (sys::windows::UTF16ToUTF8(modulePath.c_str(), modulePath.length(),
@@ -501,8 +500,8 @@ void SetupPythonRuntimeLibrary() {
501500
if (AddPythonDLLToSearchPath())
502501
return;
503502
#endif
504-
llvm::errs() << "error: unable to find "
505-
<< LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME << ".\n";
503+
llvm::errs() << "error: unable to find '"
504+
<< LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME << "'.\n";
506505
return;
507506
#elif defined(LLDB_PYTHON_DLL_RELATIVE_PATH)
508507
if (!AddPythonDLLToSearchPath())

0 commit comments

Comments
 (0)