[vtk-developers] FindPackage not working in new module system

Ben Boeckel ben.boeckel at kitware.com
Thu Jan 10 14:50:27 EST 2019


On Thu, Jan 10, 2019 at 14:01:59 -0500, Aron Helser wrote:
> Yep, just figured that out, thanks!
> 
>  Unfortunately, I'm still having a problem just with IOFFMPEG - I need it
> for 'vtkFFMPEGVideoSource.h', but mineview cmake reports:
> 
> > -- Could NOT find FFMPEG (missing: FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES
> > avformat avcodec avutil swscale) (Required is at least version "4.0")
> > -- Could not find the VTK package due to a missing dependency: FFMPEG
> > CMake Warning at CMakeLists.txt:5 (find_package):
> >   Found package configuration file:
> >     C:/akit/vtk/build/lib/cmake/vtk-8.90/vtk-config.cmake
> >   but it set VTK_FOUND to FALSE so package "VTK" is considered to be NOT
> >   FOUND.  Reason given by package:
> >   Could not find the VTK package with the following required components:
> >   IOFFMPEG.

If you look in `CMake/vtkInstallCMakePackage.cmake`, there is a TODO
item to build up a list of prefix paths to hard-code into the build
tree. This is what would help. The issue is that the list of prefixes to
add is not immediately trivial to figure out since the list of packages
and how to make a prefix from them are quite expansive.

THe first thing that is needed is the list of packages that were found
during the build (`vtk_module_find_package` serves as the entry to the
package forwarding logic, so modifying it to register what packages are
wanted globally could help). From there, for each found package,
determining a prefix based on its cache variables is necessary.

Alternatively, `vtk_module_find_package` could take additional arguments
to figure out a prefix and make that list of prefixes what is available.
That might be more useful in the long run.

> I'm setting FFMPEG_ROOT to compile vtk, so then if I set it for my app, I
> get a warning:
> 
> CMake Warning (dev) at
> > C:/akit/vtk/build/lib/cmake/vtk-8.90/VTK-vtk-module-find-packages.cmake:279
> > (find_package):
> > Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
> > Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
> > command to set the policy and suppress this warning. CMake variable
> > FFMPEG_ROOT is set to: c:/akit/mineview/src/ffmpeg For compatibility,
> > CMake is ignoring the variable.
> > Call Stack (most recent call first):
> > C:/akit/vtk/build/lib/cmake/vtk-8.90/vtk-config.cmake:62 (include)
> > CMakeLists.txt:5 (find_package)
> 
> 
> But my app compiles! So I'm not sure about the warning?

It's a policy warning. We could set it in `vtk-config.cmake` since the
modules VTK is using should be policy-clean here. A policy scope should
be used though.

--Ben


More information about the vtk-developers mailing list