From 9fc2e6829b31e4f5153b8cd70c8cd2c8debe80c0 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 7 Feb 2014 14:30:46 -0700 Subject: [PATCH] CMake: Generate and install 'pandac' for backwards-compatibility. --- cmake/macros/Interrogate.cmake | 7 ++++++- direct/CMakeLists.txt | 3 +++ direct/src/pandac/CMakeLists.txt | 15 +++++++++++++++ direct/src/pandac/__init__.py | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 direct/src/pandac/CMakeLists.txt create mode 100644 direct/src/pandac/__init__.py diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index 8fdb80e2dd..72b595ec1c 100644 --- a/cmake/macros/Interrogate.cmake +++ b/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() diff --git a/direct/CMakeLists.txt b/direct/CMakeLists.txt index e14c11ad14..9bf1cbdb19 100644 --- a/direct/CMakeLists.txt +++ b/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) diff --git a/direct/src/pandac/CMakeLists.txt b/direct/src/pandac/CMakeLists.txt new file mode 100644 index 0000000000..62969e7acf --- /dev/null +++ b/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() diff --git a/direct/src/pandac/__init__.py b/direct/src/pandac/__init__.py new file mode 100644 index 0000000000..d313bda3dd --- /dev/null +++ b/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: +