[CMake] UseSWIG.cmake Parallel Build Issue

Brian Panneton brian.panneton at gmail.com
Tue Feb 1 09:24:27 EST 2011


Would someone be able to verify this for me?

Thanks,
Brian Panneton

On Thu, Jan 27, 2011 at 11:58 AM, Brian Panneton
<brian.panneton at gmail.com>wrote:

> I have found an issue with UseSWIG.cmake during parallel builds. If you are
> swigging Python and Java using the SWIG_ADD_MODULE and SWIG_LINK_LIBRARIES
> macros you could run into this issue.
>
> When you run through CMake, the macro SWIG_GET_EXTRA_OUTPUT_FILES sets the
> variable SWIG_EXTRA_GENERATED_FILES. This variable is used by a custom
> command as an output. When CMaking, it never gets reset. Thus if you start
> with swigging Python, the file module.py is appended to it. Then when
> swigging Java, the same file remains as an output.
>
> If you are running in parallel, the output file is claimed by both Java and
> Python. Somehow this makes it so the Python lib might not get fully built on
> the first try.
>
> To solve this issue on the user side we need to reset
> SWIG_EXTRA_GENERATED_FILES right before you call the macro SWIG_ADD_MODULE,
> like such:
>
> set(swig_extra_generated_files "")
> swig_add_module(${module_name} python module.i)
>
> To solve this issue on the UseSWIG.cmake side add SET(${outfiles} "") to
> the first line of the macro SWIG_GET_EXTRA_OUTPUT_FILES, like such:
>
> MACRO(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
>   SET(${outfiles} "")
>   GET_SOURCE_FILE_PROPERTY(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
>     ${infile} SWIG_MODULE_NAME)
>
> I am pretty sure this would solve the issue. Please let me know if this is
> the correct way to go about it.
>
> Thanks,
> Brian Panneton
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110201/4ac71580/attachment.htm>


More information about the CMake mailing list