check with cmake if found ITK was compiled with GPU support

Hi!

What is the state-of-the-art way to check with cmake which features are compiled into the ITK-library found on the system, spicifically if ITK was compiled with GPU support?
Concerning enabled modules I am using this approach:


However, that seems not to work for checking if GPU code was enabled in ITK and my old way

does not work any more (always returns true).

Thanks for any help or hints.
All posts I could find with google concern building ITK with GPU support, but I want to check the capabilities of the ITK library found on the system by a project that (optionally) builds on ITK-GPU features.

My problems seems to be that ITK_MODULES_ENABLED contains ITKGPUSmoothing (and all other GPU-modules) even if ITK was not compiled with GPU support (ITK_USE_GPU=OFF). Is that expected? If so, how to check if ITK found by cmake was compiled with GPU support and then optionally add executables to compile?

I think that @matt.mccormick and @fbudin are best suited to answering this question.

@grothausmann.roman : I do not know why the GPU modules are listed in the available modules when ITK_USE_GPU is turned OFF. You could check globally if ITK_USE_GPU is ON (this CMake variable is exposed in ITKConfig.cmake (all the variables included in this files are set when using find_package), and then test the GPU modules individually as you are doing for the other modules.

That being said, I expect this to be a bug in ITK and created an issue on the ITK issue tracker.

2 Likes

Many thanks @dzenanz and @fbudin for looking into this and the proposed workaround.

2 Likes

Works with @fbudin’s workaround, see e.g.

1 Like