SWIG dependency on external project
I have a project "A" that depends on another project "B".
- ProjectB installs some headers, for example B1.h, B2.h.
- ProjectA tries to create a Python wrapper of B1.h and B2.h, using SWIG.
ProjectA uses :
-
ExternalProject_Add(ProjectB ...)
to compile and install ProjectB somwhere into the binary dir. -
Swig_Add_Library(ProjectB ...)
to create the Python wrapper ; this command creates a target _ProjectB.
I want to be sure that B1.h, B2.h are installed before SWIG runs, thus I added the following command : add_dependencies(_ProjectB ProjectA)
On Windows, this works fine.
However on Linux, the add_dependencies command is not taken into account, which gives :
.../ProjectA.i: 111: Error: Unable to find 'B1.h'
.../ProjectA.i: 112: Error: Unable to find 'B2.h'
I found a workaround : on Linux, I use : add_dependencies(ProjectB_swig_compilation ProjectA)
However, the target ProjectB_swig_compilation
does not exist on Windows. I don't understand why since I use the same version of CMake on both Linux and Windows.
It would be better if a unique solution could be found.