BRabbit27
BRabbit27

Reputation: 6623

Why CMake "option" does not refresh value on CMakeCache?

In the CMakeLists file of a project I just joined, they use OPTION as way to enable/disable some flags for the project configuration. The problem I see, is that if I generate the VS2017 project with the option as OFF and then turn it into ON. The project does not reflects that change.

OPTION(RENDER_OFFSCREEN "Set the application to render offscreen" OFF)

This generates the project and it does render offscreen, now if I turn it ON in the CMakeLists.txt file, the project still renders offscreen. Usually I have to regenerate the project for it to work.

I think I am missing something about the OPTION statement in CMake but I don't know what it is. Any advise?

Upvotes: 4

Views: 3601

Answers (1)

BRabbit27
BRabbit27

Reputation: 6623

I found the following post What can cause a CMake option not work? in SO that explains that changing the CMakeLists won't update the Cache file.

Therefore, the only alternative is to pass -DRENDER_OFFSCREEN=ON when building using the command line.

Upvotes: 2

Related Questions