Manually-specified variables were not used by the project:

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:


This works as expected, but I will see the warning:

CMake Warning:
  Manually-specified variables were not used by the project:


This behavior was already reported ( Is there an other, more obvious ways to pass binary options, that would not trigger the warning?

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.

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,