I have a project "A" that depends on another project "B".
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 am sure that the include dir given to SWIG is correct: indeed, when I run make
for the second time, this works because ProjectB was successfully installed by the first call to make
.
I use CMake 3.13.5.
Any help would be great !
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).
Eventually, here is what I did in my CMakeLists.txt :
if (WIN32 AND NOT MINGW)
add_dependencies(_ProjectB ProjectA)
else ()
add_dependencies(ProjectB_swig_compilation ProjectA)
endif ()