diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index 817a2b6cda..0eaf61f2aa 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -229,24 +229,34 @@ function(interrogate_sources target output database language_flags) endfunction(interrogate_sources) # -# Function: add_python_module(module [lib1 [lib2 ...]] [LINK lib1 ...]) +# Function: add_python_module(module [lib1 [lib2 ...]] [LINK lib1 ...] +# [IMPORT mod1 ...]) # Uses interrogate to create a Python module. If the LINK keyword is specified, # the Python module is linked against the specified libraries instead of those -# listed before. +# listed before. The IMPORT keyword makes the output module import another +# Python module when it's initialized. # function(add_python_module module) if(INTERROGATE_PYTHON_INTERFACE) set(targets) set(link_targets) + set(import_flags) set(infiles) set(sources) set(link_keyword OFF) + set(import_keyword OFF) foreach(arg ${ARGN}) if(arg STREQUAL "LINK") set(link_keyword ON) + set(import_keyword OFF) + elseif(arg STREQUAL "IMPORT") + set(link_keyword OFF) + set(import_keyword ON) elseif(link_keyword) list(APPEND link_targets "${arg}") + elseif(import_keyword) + list(APPEND import_flags "-import" "${arg}") else() list(APPEND targets "${arg}") endif() @@ -269,6 +279,7 @@ function(add_python_module module) COMMAND interrogate_module -oc "${CMAKE_CURRENT_BINARY_DIR}/${module}_module.cxx" -module ${module} -library ${module} + ${import_flags} ${INTERROGATE_MODULE_OPTIONS} ${IMOD_FLAGS} ${infiles} DEPENDS interrogate_module ${infiles} diff --git a/direct/CMakeLists.txt b/direct/CMakeLists.txt index fc9f74f019..9fe7a24c65 100644 --- a/direct/CMakeLists.txt +++ b/direct/CMakeLists.txt @@ -17,8 +17,7 @@ add_subdirectory(src/interval) add_subdirectory(src/showbase) if(HAVE_PYTHON) - add_python_module(direct p3dcparser p3deadrec p3distributed p3interval p3showbase) - target_link_libraries(direct core) + add_python_module(direct p3dcparser p3deadrec p3distributed p3interval p3showbase IMPORT panda3d.core) # Make an __init__.py pointing at the source directory so users can run # Panda3D code straight from their build path: diff --git a/panda/CMakeLists.txt b/panda/CMakeLists.txt index ab8ff038a6..31d219f22b 100644 --- a/panda/CMakeLists.txt +++ b/panda/CMakeLists.txt @@ -96,15 +96,12 @@ if(HAVE_PYTHON) add_python_module(core ${CORE_MODULE_COMPONENTS} LINK panda) if(HAVE_EGG) - add_python_module(egg p3egg p3egg2pg) - target_link_libraries(egg core) + add_python_module(egg p3egg p3egg2pg IMPORT panda3d.core) endif() - add_python_module(physics p3physics p3particlesystem) - target_link_libraries(physics core) + add_python_module(physics p3physics p3particlesystem IMPORT panda3d.core) if(HAVE_ODE) - add_python_module(ode p3ode) - target_link_libraries(ode core) + add_python_module(ode p3ode IMPORT panda3d.core) endif() endif()