Skip to content

Installing python packages built by a CMake project

Mayeul d'Avezac edited this page May 16, 2014 · 3 revisions

CMake can be used to create python packages. However, it is not always straightforward to figure out where to install the built packages and attendant files.

include(PythonInstall)
install_python(
    ... # Same arguments as CMake's install
    DESTINATION package/subpackage
)

If the DESTINATION argument is not absolute, then its root is given by PYTHON_PKG_DIR, rather than CMAKE_INSTALL_PREFIX. By default, PYTHON_PKG_DIR points to the directory given by running in python:

from distutils.sysconfig import get_python_lib
print(get_python_lib())