[CMake] installing python scripts

Kyle Husmann kyle.husmann at gmail.com
Sun Jul 29 20:15:32 EDT 2012


Hi all,

In my project I have a python program (call it program.py) that references
a python module also in my project (call it pymodule). program.py gets
installed to ${CMAKE_INSTALL_PREFIX}/bin/program and pymodule gets
installed to ${PYTHON_INSTALL_DIR}.

To make sure the program.py program always finds pymodule, I treat it like
a config script in cmake and then add the following to the top of
program.py.in:

import sys
sys.path.append("@PYTHON_INSTALL_DIR@")
import pymodule

This works great, but it means that I can only run program.py after running
a make install, and running it from the installed location.

My question is, is there are clever way of doing this so that I can run
program.py from the build directory, without having to install it? (But
have it still run properly when installed)

Thanks,
Kyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120729/76f7dffb/attachment.htm>


More information about the CMake mailing list