I have python file, for example, named blah.py, that I would like to have compiled then placed into another folder using cmake. Right now, I am capable of doing this with the following code in my cmake file:
ADD_CUSTOM_TARGET(output ALL /usr/bin/python -m py_compile src/blah.py
COMMAND /bin/mv src/blah.pyc build VERBATIM)
This is on ubuntu 12.04. This code works as intended; the only problem is that the python file is being compiled in the source directory, then being put in the build directory.
However, I can't assume that this src directory will have read AND write privileges, meaning what I need to do is combine these two commands into one (compile the python file and place the compiled python file into my build directory, instead of compiling it in the src directory then moving it)
I'm sure there must be some way I could be using to specify where I would like this compiled code to be placed, but I can't find any. Help would be greatly appreciated! :)
EDIT: This link may have a solution..not sure:
Can compiled bytecode files (.pyc) get generated in different directory?