[cmake-developers] [CMake 0011782]: Issue with UseSWIG.cmake and parallel builds

Mantis Bug Tracker mantis at public.kitware.com
Tue Feb 1 10:59:46 EST 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=11782 
====================================================================== 
Reported By:                Brian Panneton
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11782
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-02-01 10:59 EST
Last Modified:              2011-02-01 10:59 EST
====================================================================== 
Summary:                    Issue with UseSWIG.cmake and parallel builds
Description: 
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
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-02-01 10:59 Brian Panneton New Issue                                    
======================================================================




More information about the cmake-developers mailing list