0

I have a project where i use 2 different libraries depending on the user interest. While generating, i would like to give the user a choice to select which library to build. So far, i used something like this:

set(BUILD_WITH_IR  OFF CACHE BOOL "build ir")
set(BUILD_WITH_TOF OFF CACHE BOOL "build tof")

Problem:

I see 2 checkboxes in CMake GUI to select. I choose one and click configure. CMake resets both the checkboxes to OFF (deselected). Understandably, because both are set to OFF every time CMake configures.

I would like the user be able choose only one option at a time. Based on the user selection, i configure rest of my project.

How can i make these variables mutually exclusive?

MarKS
  • 494
  • 6
  • 22
  • 1
    ? What's the point? Do `set(BUILD_WITH nothing CACHE STRING "build with that thung")` with `set_property(CACHE BUILD_WITH PROPERTY STRINGS nothing IR TOF)`. It's strange to create multioption by using multiple boolean options... https://blog.kitware.com/constraining-values-with-comboboxes-in-cmake-cmake-gui/ Anyway, it should be doable with [cmake_dependent_option](https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html). – KamilCuk Oct 31 '20 at 15:09

1 Answers1

0

This looks like a single option that takes multiple values, rather then two separate unrelated options. Try:

 set(YOURLIB_BUILD_WITH "NOTHING" CACHE STRING "build with that thing")
 set_property(CACHE YOURLIB_BUILD_WITH PROPERTY STRINGS "NOTHING" "IR" "TOF")
KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • Maybe you can add how to do it with cmake_dependent_option as well. Would help others. Thanks! – MarKS Oct 31 '20 at 15:19