[Insight-developers] ITK modularization & linking against sub-sets

Brad King brad.king at kitware.com
Thu Apr 7 09:16:43 EDT 2011


On 04/07/2011 09:01 AM, Hauke Heibel wrote:
> first of all I would like to thank you guys for the modularization
> effort. It looks really great and with the new configuration setup I
> am even able to set a debug postfix for ITK while it is possible to
> link against both versions without modifying
> "ITKLibraryDepends.cmake".
[snip]
> target_link_libraries(<TARGET> debug ITKIOd release ITKIO)

FYI, if you build and install both release and a debug build with a
suffix into the same install tree then the IMPORTED targets you get
when loading ITKConfig.cmake will handle the configuration automatically.
You can just say

  target_link_libraries(mytarget Some-ITK-Target)

and CMake will generate the right thing in each configuration.  Look
at the globbing at the bottom of ITKTargets.cmake in the install tree
to see how it works.

> I tried to modify the find_package call to
> 
> find_package(ITK REQUIRED COMPONENTS ITK-IO-Base)
> 
> but ${ITK_LIBRARIES} still contained all defined modules.

We intend to make an interface like this work but have not yet done so.

> Is there any trick which I could use? If yes, is there a trick to
> search for all IO libraries? Like using wildcards when specifying
> components during find_package calls.

Look in the lib/cmake/ITK-4.0/Modules/ITK-*.cmake files that get loaded
by ITKConfig.cmake.  They provide per-module information including the
proper list of libraries in a <mod>_LIBRARIES variable.

-Brad


More information about the Insight-developers mailing list