Hello,
I have the need to pass a binary option to my build process. I pass the option as cache variable:
cmake ... -DMY_OPTION=1
Within one of the CMakeLists.txt
, I ask for the existence of this parameter:
if (DEFINED MY_OPTION)
This works as expected, but I will see the warning:
CMake Warning:
Manually-specified variables were not used by the project:
MY_OPTION
This behavior was already reported (https://gitlab.kitware.com/cmake/cmake/-/issues/18152). Is there an other, more obvious ways to pass binary options, that would not trigger the warning?
McMartin
(Alain Martin)
2
If you only check for the existence of MY_OPTION
, then it seems that passing -DMY_OPTION=1
and passing -DMY_OPTION=0
mean the same. Is that intended?
Yes, I need just 2 different values: true or false. As the cmake command line parser requires me to set a value, any value would do the job.
McMartin
(Alain Martin)
4
If you need 2 values, then you should use if(MY_OPTION)
instead of if(DEFINED MY_OPTION)
.
1 Like
Hi Alain,
Iām sorry for the late response! And thank you for the suggested solution to my problem. Seems to work very well!
best regards,
Torsten