Does target_compile_definition assign a value to the item?

For example is there any difference between the two commands?

target_compile_definitions(target_foo PRIVATE FOO)

And explicitly stating

target_compile_definitions(target_foo PRIVATE FOO=1)

I’m asking because it matters depending on if users use

// This will fail if FOO is only defined
#if FOO


#ifdef FOO

Does cmake make a guarantee on this behavior? If so it’s not in the documentation I can find.

Yes. The first translates to -DFOO and the latter is -DFOO=1 (in GCC terms). So #if with the former is not well-defined. I suppose the docs could use some enhancement to this effect. Please file an issue.

Link to the gitlab issue: