[CMake] I need help with compiling python scripts more than once
Tyler Roscoe
tyler at cryptio.net
Thu Jan 29 16:05:25 EST 2009
On Thu, Jan 29, 2009 at 07:04:48PM +0100, Simon Schäfer wrote:
> in the highest level CMakeLists.txt:
> add_subdirectroy(pyProject)
> add_subdirectroy(cProject)
Yup.
> first try:
>
> ADD_CUSTOM_TARGET(pyCustom COMMAND ${PYTHON_EXECUTABLE} -O -c "import
> compileall; compileall.compile_dir('./pyProject/', maxlevels=0, force=1);"
> DEPENDS cProject/cbin
> )
>
> results into a clean build but no pyc files and no /usr/bin/python in
> the Makefiles
>
> second try:
> ADD_CUSTOM_TARGET(pyCustom ALL COMMAND ${PYTHON_EXECUTABLE} -O -c
> "import compileall; compileall.compile_dir('./pyProject/', maxlevels=0,
> force=1);"
> DEPENDS cProject/cbin
> )
>
> gives me the following errors (make VERBOSE=1)
>
> /usr/bin/python -O -c import\ compileall;\
> compileall.compile_dir('./pyProject/',\ maxlevels=0,\ force=1);
> /bin/sh: -c: line 0: syntax error near unexpected token
> `'./pyProject/',\ maxlevels=0,\ force=1'
> /bin/sh: -c: line 0: `/usr/bin/python -O -c import\ compileall;\
> compileall.compile_dir('./pyProject/',\ maxlevels=0,\ force=1);'
You're on the right track but I think you need an add_custom_command for
your custom target to refer to. The FAQ talks about the
add_custom_command/add_custom_target pattern:
http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_generate_an_executable.2C_then_use_the_executable_to_generate_a_file.3F
That should help get you thinking in the "CMake" way about how things
should fit together.
I think CMake is trying to pass that entire python command to your shell
as a single entity, which is not what you want.
tyler
More information about the CMake
mailing list