Adding command line options to CMake

Yeah, you should use the option command. You can set options from the command line this way:

//CMakeLists.txt
option(MyOption "MyOption" OFF)

//Command line
cmake -DMyOption=ON MyProjectFolder

Note that -DMyOption must come before the path.

Leave a Comment