Aleph0
Aleph0

Reputation: 6074

How to change option in CMakeLists.txt by calling cmake with special arguments

I have some complicated CMake project containing an option like:

option(BUILD_WITH_FEATURE  OFF)

This option is scattered in many CMakeLists.txt and I really don't want to change all the files manually, as I often need to switch between ON and OFF.

Can I call cmake with some parameters like

cmake --setOption  BUILD_WITH_FEATURE=<ON|OFF>

, so that the option is changed consistently among all CMakeLists.txt?

Upvotes: 0

Views: 1271

Answers (1)

Goran Broeckaert
Goran Broeckaert

Reputation: 66

You can fill in options by passing the following to your cmake command: -DOPTION=VALUE.

So in your case you will have to use: cmake -DBUILD_WITH_FEATURE=ON.

Clearing your CMake cache before may be needed (CMakeCache.txt).

Upvotes: 2

Related Questions