[CMake] Swig Generation

Michael Wild themiwi at gmail.com
Thu Jul 15 13:01:09 EDT 2010


On 15. Jul, 2010, at 18:09 , Michael.Schmidt at L-3com.com wrote:

>> Never done it myself, but reading the FAQ and the docs, I'd suggest
>> something like this:
>> 
>> find_package(SWIG REQUIRED)
>> include(${SWIG_USE_FILE})
>> find_package(PythonLibs REQUIRED)
>> include_directories(
>> ${CMAKE_CURRENT_SOURCE_DIR}
>> ${PYTHON_INCLUDE_DIRS}
>> )
>> 
>> set_source_files_properties(swig_main.i PROPERTIES
>> CPLUSPLUS ON
>> # SWIG_FLAGS "-includeall" # enable if needed by you
>> )
>> 
>> set(SWIG_MODULE_mylib__EXTRA_DEPS swig_a.i swig_b.i regular.h)
>> swig_add_module(mylib python swig_main.i regular.cxx)
>> swig_link_libraries(mylib ${PYTHON_LIBRARIES})
>> 
>> 
>> I hope this helps getting you started
>> 
>> Michael
> 
> I tried doing exactly what you suggested.  When I compile, it can't find
> common headers, e.g. "Error: Unable to find 'stdio.h'". If I add
> "/usr/include" to the INCLUDE_DIRECTORIES, then it complains about
> "Unable to find 'gnu/stubs-32.h'" and "Unable to find 'stddef.h".
> 
> Thanks,
> Mike

Did you enable the -includeall option? If so, that might be the problem here. Try removing it, I just copied it from the FAQ.

Michael


More information about the CMake mailing list