I am preparing an application which should work with and without GUI, so I use in my CMakeLists.txt the command
option (NEED_GUI "Include Qt support" OFF)
and
if (NEED_GUI)
message("****GUI should be OFF****")
add_subdirectory(QtGUI) # The Qt-based graphics routines
endif (NEED_GUI)
Despite that I set the option OFF, I receive the message and the library is built. Where to look for an error?
Turning my comment into an answer
Your code looks good. So I'm assuming the problem here is that option()
does transfer the value given into your CMakeCache.txt
with the initial configuration step. After that you can only change it by modifying the cached entry for NEED_GUI
. Changing the option in your CMakeLists.txt
after you have generated your build environment will not update the cache anymore.
References
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With