FindPackage not working in new module system

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

FindPackage not working in new module system

Bill Lorensen
TYhis cmake file:
cmake_minimum_required(VERSION 2.8)

PROJECT(ReadOBJ)

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

add_executable(ReadOBJ MACOSX_BUNDLE ReadOBJ.cxx )

target_link_libraries(ReadOBJ ${VTK_LIBRARIES})

I specify the VTK_DIR to point at a new module VTK build. I'm using
cmake version 3.10.3

I get:

CMake Error at /usr/share/cmake-2.8/Modules/FindVTK.cmake:135 (message):
  VTK not found.  Set the VTK_DIR cmake cache entry to the directory
  containing VTKConfig.cmake.  This is either the root of the build tree, or
  PREFIX/lib/vtk for an installation.  For VTK 4.0, this is the location of
  UseVTK.cmake.  This is either the root of the build tree or
  PREFIX/include/vtk for an installation.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)

--
Unpaid intern in BillsParadise at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
On Wed, Jan 09, 2019 at 11:44:01 -0800, Bill Lorensen wrote:

> TYhis cmake file:
> cmake_minimum_required(VERSION 2.8)
>
> PROJECT(ReadOBJ)
>
> find_package(VTK REQUIRED)
> include(${VTK_USE_FILE})
>
> add_executable(ReadOBJ MACOSX_BUNDLE ReadOBJ.cxx )
>
> target_link_libraries(ReadOBJ ${VTK_LIBRARIES})
>
> I specify the VTK_DIR to point at a new module VTK build. I'm using
> cmake version 3.10.3

The vtk-config.cmake file is in the `lib/cmake/vtk-*` directory of the
build tree, not the top-level. This mirrors the install tree and also
keeps the code between the two very similar (instead of having to differ
on relative paths to other generated CMake files).

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
With a very similar cmake file, I'm seeing the error:

CMake Error at CMakeLists.txt:6 (include):
include called with wrong number of arguments. include() only takes one
file.


I pointed VTK_Dir at ".....vtk/build/lib/cmake/vtk-8.90" , like you suggested. My VTK build does have OpenVR enabled, on windows, so I have to set OpenVR_INCLUDE_DIR and OpenVR_LIBRARY.


If I change to:


include("${VTK_USE_FILE}")


It warns that no file was provided, then during compile it can't find VTK headers.


The find_package(VTK REQUIRED) is going wrong?'


What am I doing wrong?

Thanks,

Aron


On Wed, Jan 9, 2019 at 3:06 PM Ben Boeckel via vtk-developers <[hidden email]> wrote:
On Wed, Jan 09, 2019 at 11:44:01 -0800, Bill Lorensen wrote:
> TYhis cmake file:
> cmake_minimum_required(VERSION 2.8)
>
> PROJECT(ReadOBJ)
>
> find_package(VTK REQUIRED)
> include(${VTK_USE_FILE})
>
> add_executable(ReadOBJ MACOSX_BUNDLE ReadOBJ.cxx )
>
> target_link_libraries(ReadOBJ ${VTK_LIBRARIES})
>
> I specify the VTK_DIR to point at a new module VTK build. I'm using
> cmake version 3.10.3

The vtk-config.cmake file is in the `lib/cmake/vtk-*` directory of the
build tree, not the top-level. This mirrors the install tree and also
keeps the code between the two very similar (instead of having to differ
on relative paths to other generated CMake files).

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
Sorry, I should have started with the original problem. I started with this file:

cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
PROJECT (mineview)
find_package(VTK REQUIRED)
vtk_module_config(VTK
  vtkCommonCore
  vtkCommonDataModel
  vtkFiltersGeneral
  vtkIOFFMPEG
  vtkIOImage
  vtkIOXML
  vtkInteractionStyle
  vtkRenderingOpenGL2
  vtkRenderingOpenVR
)
include(${VTK_USE_FILE})

add_executable(mineview MACOSX_BUNDLE mineview.cxx Lobby.cxx View.cxx AudioHandler.cxx)
target_link_libraries(mineview ${VTK_LIBRARIES} Xaudio2.lib opengl32 winmm.lib)

but "vtk_module_config" doesn't exist anymore, right? So I tried to change to this:
find_package(VTK
  COMPONENTS
  vtkCommonCore
 ...

but then it complains:

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:
vtkCommonCore.


Thus I am confused. :)
Hope those breadcrumbs help?
Thanks,
Aron


On Thu, Jan 10, 2019 at 12:18 PM Aron Helser <[hidden email]> wrote:
With a very similar cmake file, I'm seeing the error:

CMake Error at CMakeLists.txt:6 (include):
include called with wrong number of arguments. include() only takes one
file.


I pointed VTK_Dir at ".....vtk/build/lib/cmake/vtk-8.90" , like you suggested. My VTK build does have OpenVR enabled, on windows, so I have to set OpenVR_INCLUDE_DIR and OpenVR_LIBRARY.


If I change to:


include("${VTK_USE_FILE}")


It warns that no file was provided, then during compile it can't find VTK headers.


The find_package(VTK REQUIRED) is going wrong?'


What am I doing wrong?

Thanks,

Aron


On Wed, Jan 9, 2019 at 3:06 PM Ben Boeckel via vtk-developers <[hidden email]> wrote:
On Wed, Jan 09, 2019 at 11:44:01 -0800, Bill Lorensen wrote:
> TYhis cmake file:
> cmake_minimum_required(VERSION 2.8)
>
> PROJECT(ReadOBJ)
>
> find_package(VTK REQUIRED)
> include(${VTK_USE_FILE})
>
> add_executable(ReadOBJ MACOSX_BUNDLE ReadOBJ.cxx )
>
> target_link_libraries(ReadOBJ ${VTK_LIBRARIES})
>
> I specify the VTK_DIR to point at a new module VTK build. I'm using
> cmake version 3.10.3

The vtk-config.cmake file is in the `lib/cmake/vtk-*` directory of the
build tree, not the top-level. This mirrors the install tree and also
keeps the code between the two very similar (instead of having to differ
on relative paths to other generated CMake files).

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
In reply to this post by VTK - Dev mailing list
On Thu, Jan 10, 2019 at 12:18:37 -0500, Aron Helser wrote:
> include("${VTK_USE_FILE}")

VTK_USE_FILE isn't provided anymore since it isn't necessary.
`find_package(VTK)` is all that is necessary.

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
In reply to this post by VTK - Dev mailing list
On Thu, Jan 10, 2019 at 12:24:07 -0500, Aron Helser wrote:

> Sorry, I should have started with the original problem. I started with this
> file:
>
> cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
> PROJECT (mineview)
> find_package(VTK REQUIRED)
> vtk_module_config(VTK
>   vtkCommonCore
>   vtkCommonDataModel
>   vtkFiltersGeneral
>   vtkIOFFMPEG
>   vtkIOImage
>   vtkIOXML
>   vtkInteractionStyle
>   vtkRenderingOpenGL2
>   vtkRenderingOpenVR
> )
> include(${VTK_USE_FILE})
>
> add_executable(mineview MACOSX_BUNDLE mineview.cxx Lobby.cxx View.cxx
> AudioHandler.cxx)
> target_link_libraries(mineview ${VTK_LIBRARIES} Xaudio2.lib opengl32
> winmm.lib)
>
> but "vtk_module_config" doesn't exist anymore, right? So I tried to change
> to this:
> find_package(VTK
>   COMPONENTS
>   vtkCommonCore
>  ...
>
> but then it complains:
>
> 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:
> vtkCommonCore.
>
>
> Thus I am confused. :)
> Hope those breadcrumbs help?

COMPONENTS are now `CommonCore` and `FiltersGeneral` since they end up
like `VTK::CommonCore`. I suppose the components list could be
preprocessed to detect a leading `vtk` and remove it (warning that that
name is deprecated).

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

Bill Lorensen
I'm curious why the component names were changed.

On Thu, Jan 10, 2019, 10:37 AM Ben Boeckel <[hidden email] wrote:
On Thu, Jan 10, 2019 at 12:24:07 -0500, Aron Helser wrote:
> Sorry, I should have started with the original problem. I started with this
> file:
>
> cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
> PROJECT (mineview)
> find_package(VTK REQUIRED)
> vtk_module_config(VTK
>   vtkCommonCore
>   vtkCommonDataModel
>   vtkFiltersGeneral
>   vtkIOFFMPEG
>   vtkIOImage
>   vtkIOXML
>   vtkInteractionStyle
>   vtkRenderingOpenGL2
>   vtkRenderingOpenVR
> )
> include(${VTK_USE_FILE})
>
> add_executable(mineview MACOSX_BUNDLE mineview.cxx Lobby.cxx View.cxx
> AudioHandler.cxx)
> target_link_libraries(mineview ${VTK_LIBRARIES} Xaudio2.lib opengl32
> winmm.lib)
>
> but "vtk_module_config" doesn't exist anymore, right? So I tried to change
> to this:
> find_package(VTK
>   COMPONENTS
>   vtkCommonCore
>  ...
>
> but then it complains:
>
> 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:
> vtkCommonCore.
>
>
> Thus I am confused. :)
> Hope those breadcrumbs help?

COMPONENTS are now `CommonCore` and `FiltersGeneral` since they end up
like `VTK::CommonCore`. I suppose the components list could be
preprocessed to detect a leading `vtk` and remove it (warning that that
name is deprecated).

--Ben

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
In reply to this post by VTK - Dev mailing list
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.

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?

On Thu, Jan 10, 2019 at 1:37 PM Ben Boeckel <[hidden email]> wrote:
On Thu, Jan 10, 2019 at 12:24:07 -0500, Aron Helser wrote:
> Sorry, I should have started with the original problem. I started with this
> file:
>
> cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
> PROJECT (mineview)
> find_package(VTK REQUIRED)
> vtk_module_config(VTK
>   vtkCommonCore
>   vtkCommonDataModel
>   vtkFiltersGeneral
>   vtkIOFFMPEG
>   vtkIOImage
>   vtkIOXML
>   vtkInteractionStyle
>   vtkRenderingOpenGL2
>   vtkRenderingOpenVR
> )
> include(${VTK_USE_FILE})
>
> add_executable(mineview MACOSX_BUNDLE mineview.cxx Lobby.cxx View.cxx
> AudioHandler.cxx)
> target_link_libraries(mineview ${VTK_LIBRARIES} Xaudio2.lib opengl32
> winmm.lib)
>
> but "vtk_module_config" doesn't exist anymore, right? So I tried to change
> to this:
> find_package(VTK
>   COMPONENTS
>   vtkCommonCore
>  ...
>
> but then it complains:
>
> 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:
> vtkCommonCore.
>
>
> Thus I am confused. :)
> Hope those breadcrumbs help?

COMPONENTS are now `CommonCore` and `FiltersGeneral` since they end up
like `VTK::CommonCore`. I suppose the components list could be
preprocessed to detect a leading `vtk` and remove it (warning that that
name is deprecated).

--Ben

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
In reply to this post by Bill Lorensen
On Thu, Jan 10, 2019 at 11:00:33 -0800, Bill Lorensen wrote:
> I'm curious why the component names were changed.

Short answer:

CMake intricacies and simpler code on the module system's side.

That said, the translation code is possible to do (though I don't think
I'll get to it right away; feel free to make an MR and I can review).

Long answer:

The idea was to have the name used to link in the build and install tree
be exactly the same. When exporting with a namespace, CMake does
`<namespace>::<target>` without support for renaming `<target>`. The
module system helps to write out the `find_package(dependency)` calls
based on the requested components for which it needs to know their
names. The old component names could have been preserved, but that would
have resulted in targets like `VTK::vtkCommonCore` which I originally
kept, but discussions with others said that `VTK::CommonCore` was
preferred.

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
In reply to this post by VTK - Dev mailing list
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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
On Thu, Jan 10, 2019 at 14:50:27 -0500, Ben Boeckel wrote:
> On Thu, Jan 10, 2019 at 14:01:59 -0500, Aron Helser wrote:
> > 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.

This and the component name compatibility have been added here:

    https://gitlab.kitware.com/vtk/vtk/merge_requests/5056

--Ben
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: FindPackage not working in new module system

VTK - Dev mailing list
Awesome, thanks!

On Thu, Jan 10, 2019 at 5:08 PM Ben Boeckel <[hidden email]> wrote:
On Thu, Jan 10, 2019 at 14:50:27 -0500, Ben Boeckel wrote:
> On Thu, Jan 10, 2019 at 14:01:59 -0500, Aron Helser wrote:
> > 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.

This and the component name compatibility have been added here:

    https://gitlab.kitware.com/vtk/vtk/merge_requests/5056

--Ben

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers