Browse Source

CMake: Generate and install 'pandac' for backwards-compatibility.

Sam Edwards 12 years ago
parent
commit
9fc2e6829b

+ 6 - 1
cmake/macros/Interrogate.cmake

@@ -36,6 +36,8 @@ endif()
 
 set(IMOD_FLAGS -python-native)
 
+# This stores the names of every module added to the Interrogate system:
+set(ALL_INTERROGATE_MODULES CACHE INTERNAL "Internal variable")
 
 #
 # Function: target_interrogate(target [ALL] [source1 [source2 ...]])
@@ -270,6 +272,9 @@ function(add_python_module module)
     if(WIN32 AND NOT CYGWIN)
       set_target_properties(${module} PROPERTIES SUFFIX ".pyd")
     endif()
+
+    list(APPEND ALL_INTERROGATE_MODULES "${module}")
+    set(ALL_INTERROGATE_MODULES "${ALL_INTERROGATE_MODULES}" CACHE INTERNAL "Internal variable")
   endif()
 endfunction(add_python_module)
 
@@ -281,5 +286,5 @@ if(HAVE_PYTHON)
 
   # The Interrogate path needs to be installed to the architecture-dependent
   # Python directory.
-  install(DIRECTORY "${PROJECT_BINARY_DIR}/panda3d" DESTINATION "${PYTHON_LIB_INSTALL_DIR}")
+  install(DIRECTORY "${PROJECT_BINARY_DIR}/panda3d" DESTINATION "${PYTHON_ARCH_INSTALL_DIR}")
 endif()

+ 3 - 0
direct/CMakeLists.txt

@@ -36,3 +36,6 @@ if(HAVE_PYTHON)
     FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py"
     DESTINATION "${PYTHON_LIB_INSTALL_DIR}/direct")
 endif()
+
+# pandac has its own installation steps necessary:
+add_subdirectory(src/pandac)

+ 15 - 0
direct/src/pandac/CMakeLists.txt

@@ -0,0 +1,15 @@
+if(HAVE_PYTHON)
+  # Generate PandaModules:
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
+    "# Generated by CMake; edits not preserved\n")
+  foreach(module ${ALL_INTERROGATE_MODULES})
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
+      "from panda3d.${module} import *\n")
+  endforeach()
+
+  # Now install ourselves:
+  file(GLOB python_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.py")
+  install(
+    FILES ${python_sources} "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
+    DESTINATION "${PYTHON_LIB_INSTALL_DIR}/pandac")
+endif()

+ 5 - 0
direct/src/pandac/__init__.py

@@ -0,0 +1,5 @@
+# N.B. PandaModules is generated at build time by CMake
+from PandaModules import *
+
+# Now import all extensions:
+