瀏覽代碼

CMake: Fix generated pandac.PandaModules on Py2

Python 2 doesn't use the fully qualified module name in
its ImportError output; only the local name. Test for that.
Sam Edwards 6 年之前
父節點
當前提交
9645aaee07
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      direct/CMakeLists.txt

+ 2 - 1
direct/CMakeLists.txt

@@ -56,11 +56,12 @@ if(HAVE_PYTHON)
 print(\"Warning: pandac.PandaModules is deprecated, import from panda3d.core instead\")\n")
 
   foreach(module ${ALL_INTERROGATE_MODULES})
+    string(REGEX REPLACE "^.*\\." "" module_name "${module}")
     file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py" "
 try:
     from ${module} import *
 except ImportError as err:
-    if not (\"No module named\" in str(err) and \"${module}\" in str(err)):
+    if not (\"No module named\" in str(err) and \"${module_name}\" in str(err)):
         raise
 ")
   endforeach()