# CMAKE MODULE TO FATAL ERROR MUTUALLY EXCLUSIVE OPTIONS

**URL:** <https://discourse.cmake.org/t/cmake-module-to-fatal-error-mutually-exclusive-options/10911>\
**Category:** Code\
**Created:** [May 27, 2024, 6:43pm UTC](https://discourse.cmake.org/t/cmake-module-to-fatal-error-mutually-exclusive-options/10911 "2024-05-27T18:43:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mredenti](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mredenti/32/4464_2.png) [@mredenti](https://discourse.cmake.org/u/mredenti)\
**Post date:** [May 27, 2024, 6:43pm UTC](https://discourse.cmake.org/t/cmake-module-to-fatal-error-mutually-exclusive-options/10911/1 "2024-05-27T18:43:59Z")

</div>

I would like to set three mutually exclusive options in CMake where an error is raised if more than one of the three options is enables

```auto
option(TPL_ENABLE_MPI "enable MPI" OFF)
option(TPL_ENABLE_FFTW "enable Fast Fourier Transform library" OFF)
option(TPL_ENABLE_CUFFT "enable TPL FFTW" OFF)

```

the three options above have default values to OFF. How to raise a fatal error if more than one is enabled from the command line? I know I can do it with if/elseif but I was wondering if there is CMake module i can use. (I am using CMake 3.21)

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [March 13, 2025, 6:24pm UTC](https://discourse.cmake.org/t/cmake-module-to-fatal-error-mutually-exclusive-options/10911/2 "2025-03-13T18:24:16Z")

</div>

Why not make it a string variable and set the [`STRINGS`](https://cmake.org/cmake/help/latest/prop_cache/STRINGS.html) cache property to make it act like a radio button instead?
