#cmakedefine01 syntax is not clearly defined in the documentation
EDIT: It looks like the problem here might be that I used
#cmakedefine01 DEV_BUILD @DEV_BUILD@like one might do
#cmakedefine DEV_BUILD @DEV_BUILD@, but the difference in syntax is really unclear from the documentation.
If you try to use
#cmakedefine01 in a C++ header file with a variable defined using
option(), C++ will fail to recognize the output, with an error along the lines of the following:
application.cpp:496:53: error: expected ';' after expression shouldSetAutoStart = shouldSetAutoStart && !DEV_BUILD; ^ config.h:32:23: note: expanded from macro 'DEV_BUILD' #define DEV_BUILD OFF 0 ^ application.cpp:496:53: error: use of undeclared identifier 'OFF' config.h:32:19: note: expanded from macro 'DEV_BUILD' #define DEV_BUILD OFF 0 ^
What appears to be happening is that, rather than setting the variable
0 as the equivalent of the option
configure_file is setting a new variable,
0, or something like that.
The CMake documentation on
configure_filereads as follows:
depending on whether
VARis set in CMake to any value not considered a false constant by the
if()command. The "..." content on the line after the variable name, if any, is processed as above. Input file lines of the form
#cmakedefine01 VARwill be replaced with either
#define VAR 1or
#define VAR 0similarly.
Clicking through to the page on
if(), we see the following:
True if the constant is
Y, or a non-zero number. False if the constant is
NOTFOUND, the empty string, or ends in the suffix
OFF is defined as a false constant for
#cmakedefine01 should recognize it and convert it as such.
It's possible that I'm not using
#cmakedefine01 correctly, but the option variable
DEV_BUILD works properly elsewhere in the CMake scripts; there are a number of
#cmakedefine string variables that are working correctly in the same header file; and this seems like a fairly trivial case for me to be messing up...