On 10/24/2010 01:26 AM, Bill Spotz wrote:
> Hi,
>
> Is there a standard way to make tests for python extension modules?
>
> Currently, I copy test scripts from the source directory to the binary
> directory. I would like to augment this by making the first line of my script
>
> #! ${PYTHON_EXECUTABLE}
>
> but the only copy facility I see that supports this substitution is
>
> CONFIGURE_FILE(...)
>
> The problem with this is that the file gets copied over during configuration,
> and it would be much preferable to have it copied during the build phase. Is
> there a copy facility that performs substitutions that executes during the
> build phase?
You might use a CMake script which is executed at build time:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(PYTHONTEST C)
SET(PYTHON_EXECUTABLE "path/to/python")
FILE(WRITE ${CMAKE_BINARY_DIR}/pythontest.py.in "#! @interpre...@\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/pythontest.cmake "
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/pythontest.py.in
${CMAKE_BINARY_DIR}/pythontest.py)\n")
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/pythontest.py
COMMAND ${CMAKE_COMMAND} -D INTERPRETER=${PYTHON_EXECUTABLE}
-P pythontest.cmake
DEPENDS ${CMAKE_BINARY_DIR}/pythontest.py.in)
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
ADD_EXECUTABLE(main main.c pythontest.py)
So, CONFIGURE_FILE() is delayed until the custom command's invocation.
Anyway, the variables' values that are subject to substitution, i.e.
INTERPRETER in the example, must be provided at configuration time.
Regards,
Michael
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake