What can cause a CMake option not work?

前端 未结 2 596
我在风中等你
我在风中等你 2021-01-22 05:22

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) 


        
相关标签:
2条回答
  • 2021-01-22 05:36

    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

    • What's the CMake syntax to set and use variables?
    • Advantages of using CMake option command rather than set?
    • How to tell whether CMake used initial value for an option?
    0 讨论(0)
  • 2021-01-22 05:45
    if (NEED_GUI MATCHES ON)
    

    is the appropriate usage rather than

    if (NEED_GUI)
    
    0 讨论(0)
提交回复
热议问题