Reputation: 5
I'm successfully building a SWIG interface between python and my C++ library on Linux using cmake. (well, except on linux an extra _ is added at the beginning of the module name).
However, on windows, the build fails with "Only one target language can be supported at a time (both -python and -python were specified)." My SWIG_ADD_LIBRARY call is straight forward:
SWIG_ADD_LIBRARY(pyIntegration TYPE SHARED LANGUAGE PYTHON SOURCES example.i example.h, etc )
My .i file is not very exciting, just a module specification as : %module pyIntegration
and some typedefs (e.g. unsigned int uint32_t, etc).
Any thoughts? Seems like a cmake bug most likely, but how best to work around? Thanks so much for any assistance!
Upvotes: 0
Views: 26
Reputation: 5
ok, egg on my face - I found the problem. When I converted the CMakeLists.txt file, I modified a set property that had previously set the tcl version to tcl8 to instead specify -python - which then was duplicated by cmake. Sorry for the distraction!
Upvotes: 1
Reputation: 9309
Please provide:
UseSWIG
builtin module has got some rework in 3.19 IIRC4.3.0
is the last release)Did you set some property on the example.i
file ?
It should be:
set_property(SOURCE example.i PROPERTY CPLUSPLUS ON)
swig_add_library(pyIntegration LANGUAGE python SOURCES example.i)
ref: https://cmake.org/cmake/help/latest/module/UseSWIG.html
ps: you can find a working sample here: https://github.com/Mizux/python-native
pps: Swigwin manual install: https://github.com/Mizux/python-native/blob/0f3f49a0db49553ad6ffbb0fb59451e28a9f811c/.github/workflows/amd64_windows.yml#L29-L33
or from CMakeList.txt https://github.com/google/or-tools/blob/98129bd1fa6ab0d40be6bb08a74bbbc21af5ba25/cmake/dependencies/CMakeLists.txt#L17-L47
Upvotes: 0