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?
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")