How can I get CMake options used for building from within a program?
E.g. I would like to use this:
int main()
{
std::cout << "Build options: " << BUILD_OPTIONS << std::endl;
}
BUILD_OPTIONS
would contain a string with all options passed to cmake
, like:
cmake -DOPT1 -DOPT3
with CMakeLists.txt
defined as follows:
option(OPT1 "option 1" OFF)
option(OPT2 "option 2" OFF)
option(OPT3 "option 3" OFF)
The desired output of such program:
Build options: OPT1=ON OPT3=ON
(OPT2
skipped, as it is not defined explicitly and equal to default value)