diff --git a/python-helpers.cmake b/python-helpers.cmake
index 16c7351aa..e1e284609 100644
--- a/python-helpers.cmake
+++ b/python-helpers.cmake
@@ -13,23 +13,70 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see .
-# .rst: .. command:: PYTHON_INSTALL(MODULE FILE DEST)
+# .rst:
+#
+# ~~~
+# .. command:: PYTHON_INSTALL( COMPONENT )
+# ~~~
#
# Compile and install a Python file.
#
+# :param module: Python module name.
+#
+# :param file: Python file name.
+#
+# :param file: Installation directory.
+#
+# :param component: Component to forward to install command.
macro(PYTHON_INSTALL MODULE FILE DEST)
+ set(options)
+ set(oneValueArgs COMPONENT)
+ set(multiValueArgs)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}"
+ ${ARGN})
+
+ if(ARGS_COMPONENT)
+ set(_COMPONENT_NAME ${ARGS_COMPONENT})
+ else()
+ set(_COMPONENT_NAME ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
+ endif()
+
python_build("${MODULE}" "${FILE}")
- install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}/${FILE}"
- DESTINATION "${DEST}/${MODULE}")
+ install(
+ FILES "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}/${FILE}"
+ DESTINATION "${DEST}/${MODULE}"
+ COMPONENT ${_COMPONENT_NAME})
endmacro()
-# .rst: .. command:: PYTHON_INSTALL_ON_SITE (MODULE FILE)
+# .rst:
+#
+# ~~~
+# .. command:: PYTHON_INSTALL_ON_SITE ( COMPONENT )
+# ~~~
#
# Compile and install a Python file in :cmake:variable:`PYTHON_SITELIB`.
#
+# :param module: Python module name.
+#
+# :param file: Python file name.
+#
+# :param component: Component to forward to install command.
macro(PYTHON_INSTALL_ON_SITE MODULE FILE)
- python_install("${MODULE}" "${FILE}" ${PYTHON_SITELIB})
+ set(options)
+ set(oneValueArgs COMPONENT)
+ set(multiValueArgs)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}"
+ ${ARGN})
+
+ if(ARGS_COMPONENT)
+ set(_COMPONENT_NAME ${ARGS_COMPONENT})
+ else()
+ set(_COMPONENT_NAME ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
+ endif()
+
+ python_install("${MODULE}" "${FILE}" ${PYTHON_SITELIB} COMPONENT
+ ${_COMPONENT_NAME})
endmacro()
# PYTHON_BUILD_GET_TARGET(TARGET)