CMake: Update add_python_module to support COMPONENT

This commit is contained in:
Sam Edwards 2018-12-06 17:48:03 -07:00
parent 9fffb5605a
commit 8b6a2cfd09

View File

@ -250,6 +250,7 @@ function(add_python_module module)
endif() endif()
set(targets) set(targets)
set(component "Python")
set(link_targets) set(link_targets)
set(import_flags) set(import_flags)
set(infiles_rel) set(infiles_rel)
@ -259,7 +260,7 @@ function(add_python_module module)
set(keyword) set(keyword)
foreach(arg ${ARGN}) foreach(arg ${ARGN})
if(arg STREQUAL "LINK" OR arg STREQUAL "IMPORT") if(arg STREQUAL "LINK" OR arg STREQUAL "IMPORT" OR arg STREQUAL "COMPONENT")
set(keyword "${arg}") set(keyword "${arg}")
elseif(keyword STREQUAL "LINK") elseif(keyword STREQUAL "LINK")
list(APPEND link_targets "${arg}") list(APPEND link_targets "${arg}")
@ -267,6 +268,9 @@ function(add_python_module module)
elseif(keyword STREQUAL "IMPORT") elseif(keyword STREQUAL "IMPORT")
list(APPEND import_flags "-import" "${arg}") list(APPEND import_flags "-import" "${arg}")
set(keyword) set(keyword)
elseif(keyword STREQUAL "COMPONENT")
set(component "${arg}")
set(keyword)
else() else()
list(APPEND targets "${arg}") list(APPEND targets "${arg}")
endif() endif()
@ -308,7 +312,8 @@ function(add_python_module module)
COMMENT "Generating module ${module}" COMMENT "Generating module ${module}"
) )
add_python_target(panda3d.${module} "${module}_module.cxx" ${sources_abs} ${extensions}) add_python_target(panda3d.${module} COMPONENT "${component}" EXPORT "${component}"
"${module}_module.cxx" ${sources_abs} ${extensions})
target_link_libraries(panda3d.${module} ${link_targets}) target_link_libraries(panda3d.${module} ${link_targets})
if(CMAKE_VERSION VERSION_LESS "3.11") if(CMAKE_VERSION VERSION_LESS "3.11")