[CMake] I need help with compiling python scripts more than once

Simon Schäfer Simon.Schaefer at sevenload.com
Thu Jan 29 11:58:11 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tyler Roscoe schrieb:
> On Thu, Jan 29, 2009 at 03:27:44PM +0100, Simon Schäfer wrote:
>> I want to automate the build of my python scripts which work together
>> with my C project, and on a later stage pack all together with CPack.
>>
>> My problem for now is to automatically build my python code with cmake.
>> I am able to build it on the initial cmake build but on a following make
>> it will not recompile. Best would be if I can declare some files (the
>> .py files) on which the recompile will be redone.
>>
>> My current CMakeLists.txt:
>>
>> PROJECT ("python scripts")
>> CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
>> FIND_PACKAGE(PythonInterp 2.4)
>> EXECUTE_PROCESS(
>>         COMMAND ${PYTHON_EXECUTABLE} -O -c "import compileall;
>> compileall.compile_dir('.', maxlevels=0, force=1);"
>>         OUTPUT_VARIABLE pythonBuild
>> )
> 
> I don't know if I really understand your problem but I would consider
> using add_custom_command and add_custom_target to make this part of your
> build behave like the other parts of your build. That way, you get a
> target that runs when your .pyc are out of date and you can have your C
> code depend on your python code.
> 
> tyler
> 

well i have two projet which should both be build with cmake for example:

./CMakeLists.txt
./pyProject/CMakeLists.txt
./cProject/CMakeLists.txt

now I want to compile all together when I am at the lowest level. I
don't want to deliver the source code to any of the programs therefore I
do not send the python code out to the customer. The python code itself
is not depending on the c code because its just a tool that communicates
with the cProject.
I tried the add_custom_command approach but ended up with the problem
that I have no real build target and that the python command is not in
the makefile so it would never rebuild the pyc anyway.

Well, if I would bind it to the cProject how do i let them depend on the
pyc files?

Simon
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmB4CMACgkQCT+234kh3ajkOQCeKDzIr+jNboszY0JNz0OlQDzY
gOMAoI0arZF57gwsX5Hp4uMqaROTG3iY
=5YQy
-----END PGP SIGNATURE-----


More information about the CMake mailing list