In my CMakeList.txt i can do the following thing:
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -new -flags -here")
Is it possible to to the same thing via command line? Like:
cmake.exe -DCMAKE_CXXFLAGS+= -new -flags
Options and variables are defined on the CMake command line like this: $ cmake -DVARIABLE=value path/to/source You can set a variable after the initial `CMake` invocation to change its value. You can also undefine a variable: $ cmake -UVARIABLE path/to/source Variables are stored in the `CMake` cache.
You access a variable by using ${} , such as ${MY_VARIABLE} . 1. CMake has the concept of scope; you can access the value of the variable after you set it as long as you are in the same scope. If you leave a function or a file in a sub directory, the variable will no longer be defined.
Set a normal, cache, or environment variable to a given value. See the cmake-language(7) variables documentation for the scopes and interaction of normal variables and cache entries. Signatures of this command that specify a <value>... placeholder expect zero or more arguments.
I'm not sure whether you can directly add options from the command line, but you can use an additional variable to store them and merge it at the end. Like the following:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_FLAGS}")
And then call cmake as following:
cmake -DMY_FLAGS="-new -flags"
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