[CMake] [ITK-dev] find_package issues with ITK and VTK (and SlicerExecution Model)

Brad King brad.king at kitware.com
Tue Sep 30 10:48:47 EDT 2014


On 09/30/2014 10:14 AM, Williams, Norman K wrote:
> find_package(VTK REQUIRED)
> find_package(ITK REQUIRED)
> 
> You can’t real compile anything that needs VTK, because down in
> the ITK deployment stuff, it calls find_package(VTK) like this:
[snip]
> Which blows away the larger list of include directories and libraries

One may use the itk_module_config and vtk_module_config macros
from the *ModuleAPI.cmake modules that come with the respective
packages to compute the list of libraries and include dirs for
a given list of components.  All ITKConfig and VTKConfig do with
the list of components is:

 itk_module_config(ITK ${ITK_MODULES_REQUESTED})
 # sets ITK_LIBRARIES, ITK_INCLUDE_DIRS, etc.

and

 vtk_module_config(VTK ${VTK_MODULES_REQUESTED})
 # sets VTK_LIBRARIES, VTK_INCLUDE_DIRS, etc.

One can invoke these directly:

 itk_module_config(ITK ${MY_LIST_OF_ITK_COMPONENTS})
 vtk_module_config(VTK ${MY_LIST_OF_VTK_COMPONENTS})

at any time after the find_package calls.  One could even use
a different prefix:

 itk_module_config(MyITK ${MY_LIST_OF_ITK_COMPONENTS})
 # sets MyITK_LIBRARIES, MyITK_INCLUDE_DIRS, etc.

In the long run the plan is to stop recommending use of component
lists at find_package time and instead use imported targets and
usage requirements:

 http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#build-specification-and-usage-requirements

but that will have to wait until we can require CMake 3.0.

-Brad



More information about the CMake mailing list