UseSWIG: Set output directory per swig source file (module)
I'm using Swig to wrap a C++ library with multiple namespaces to C#, and I would like to have corresponding namespaces in C#.
In CMake 3.18, it is possible to set OUTPUT_DIR
for the whole library, but not per Swig source file.
This will not work if a class with the same name is located in two different namespaces.
set_property(SOURCE src/swig/Foo.i PROPERTY COMPILE_OPTIONS -namespace Foo)
set_property(SOURCE src/swig/Bar.i PROPERTY COMPILE_OPTIONS -namespace Bar)
swig_add_library(MyLib OUTPUT_DIR generated-files SOURCES Foo.i Bar.i)
Would it be possible to specify OUTPUT_DIR
per source file in the future? Something like this:
set_property(SOURCE src/swig/Foo.i PROPERTY COMPILE_OPTIONS -namespace Foo)
set_property(SOURCE src/swig/Foo.i PROPERTY OUTPUT_DIR generated-files/Foo)
set_property(SOURCE src/swig/Bar.i PROPERTY COMPILE_OPTIONS -namespace Bar)
set_property(SOURCE src/swig/Bar.i PROPERTY OUTPUT_DIR generated-files/Bar)
swig_add_library(MyLib OUTPUT_DIR generated-files SOURCES Foo.i Bar.i)
Note: I cannot use the %nspace
feature in Swig, because the C# namespace is different from the C++ one, due to .NET naming conventions.