# check with cmake if found ITK was compiled with GPU support

**URL:** <https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522>\
**Category:** Engineering\
**Created:** [January 14, 2019, 5:23pm UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522 "2019-01-14T17:23:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [January 14, 2019, 5:23pm UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522/1 "2019-01-14T17:23:43Z")

</div>

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:

> <https://github.com/romangrothausmann/ITK-CLIs/blob/735ae64200c6faa874fb3dd87b5e177895b1cb0d/CMakeLists.txt#L79-L85>

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

> <https://github.com/romangrothausmann/ITK-CLIs/blob/735ae64200c6faa874fb3dd87b5e177895b1cb0d/CMakeLists.txt#L635-L637>

  
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.

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [January 15, 2019, 10:21am UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522/2 "2019-01-15T10:21:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [January 15, 2019, 2:14pm UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522/3 "2019-01-15T14:14:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)\
**Post date:** [January 15, 2019, 3:12pm UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522/4 "2019-01-15T15:12:00Z")

</div>

@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](https://github.com/InsightSoftwareConsortium/ITK/issues/415).

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [January 24, 2019, 12:38pm UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522/5 "2019-01-24T12:38:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [November 17, 2019, 1:13pm UTC](https://discourse.itk.org/t/check-with-cmake-if-found-itk-was-compiled-with-gpu-support/1522/6 "2019-11-17T13:13:00Z")

</div>

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

> <https://github.com/romangrothausmann/ITK-CLIs/commit/abf897724d217f23defb0fb09957ec2541b91f55>
