VTK uses hard-coded path to freetype.so resulting in failure of cross-compiling

Hi there.

Recently we started using PCL in our application. Everything worked well on the x86_64 side. Our next step is to cross-compile our application to aarch64 and this is where the problem raised.

A little background of how we do cross-compile. We use Docker to generate the SYSROOT of the target system, i.e., Ubuntu 18.04 aarch64. In the Dockerfile, we install libpcl-dev via apt-get, which has a dependency of vtk-6.3. Then we extract the /usr folder and tell CMake to use that folder as SYSROOT.

The first problem was that PCL has a hard-coded path to vtk6.3 which is in the host filesystem instead of in the SYSTOOT

    set(VTK_DIR "/usr/lib/cmake/vtk-6.3" CACHE PATH "The directory containing VTKConfig.cmake")

This was solved by adding -DVTK_DIR=${SYSROOT}/usr/lib/cmake/vtk-6.3. However, we then found that VTK also has some hard-coded path to some libraries:


Take libfreetype.so as an example, it was added by Modules/vtkfreetype.cmake

set(vtkfreetype_LIBRARIES "/usr/lib/aarch64-linux-gnu/libfreetype.so")
set(vtkfreetype_INCLUDE_DIRS "${VTK_INSTALL_PREFIX}/include/vtk-6.3;/usr/include/freetype2")

So clearly this is a path to the host, not to the SYSROOT. Therefore, our cross compile failed because the path /usr/lib/aarch64-linux-gnu/libfreetype.so doesn’t exist on the x86_64 machine and it’s not a target either.

I feel it’ll be rude to ask VTK developers to stop using hardcoded when they releasing vtk pkg to Ubuntu sources. Is there any better way to solve the problem?


6.3 is very old. 9.0 should no longer have any hard-coded paths (it was something I kept in mind when reworking the build system 2 years ago). 8.2 probably still has hard-coded paths though.