On Wed, Jan 15, 2014 at 2:20 PM, Jan Blechta <[email protected]> wrote:
> On Tue, 14 Jan 2014 17:42:42 +0100
> Johannes Ring <[email protected]> wrote:
>
>> On Tue, Jan 14, 2014 at 5:06 PM, Jan Blechta
>> <[email protected]> wrote:
>> > Is there a way choosing a SWIG installation if there are multiple of
>> > them on the system? It seems that CMake-built-in FindSWIG, say
>> >
>> >   $CMAKE_ROOT/share/cmake-2.8/Modules/FindSWIG.cmake
>> >
>> > picks one regardless of preset values SWIG_DIR and SWIG_EXECUTABLE.
>>
>> You should be able to force this by running cmake with
>> -DSWIG_EXECUTABLE:FILEPATH=/path/to/swig. Doesn't that work for you?
>
> Ok, this works. But generated code uses wrong swig version and
> ffc/jitcompiler.py:check_swig_version(compiled_module) raises.
>
> I guess that possible reason is that one my SWIGs has both swig2.0 and
> swig executables while another has only swig. FindSWIG.cmake prefers
> swig2.0 executable. So can -DSWIG_EXECUTABLE be passed to cmake when
> configuring an extension module?

See attached patch for Instant. I haven't tested it but maybe
something like that will fix this problem? Not sure it is a good fix
though.

Setting CMAKE_PREFIX_PATH might also help CMake pick the correct swig binary.

Johannes
diff --git a/instant/codegeneration.py b/instant/codegeneration.py
index d73eebb..9db0a21 100644
--- a/instant/codegeneration.py
+++ b/instant/codegeneration.py
@@ -415,6 +415,8 @@ endif()""" %
     else:
         cmake_form["lddargs"] = ""
 
+    cmake_form["swig_binary"] = get_swig_binary()
+
     cmake_template = """
 cmake_minimum_required(VERSION 2.6.0)
 
@@ -427,6 +429,7 @@ PROJECT(${NAME})
 %(cppargs)s
 %(lddargs)s
 
+set(SWIG_EXECUTABLE %(swig_binary)s)
 find_package(SWIG REQUIRED)
 include(${SWIG_USE_FILE})
 
_______________________________________________
fenics-support mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics-support

Reply via email to