Add -D option via boards.txt I'm trying to find a way to set a -D compiler option from within the boards.txt file. Basically set a #define for use in code. There are already some special ones like board.vid but is there a generic way to do it?

Somehow the Teensy add-on adds a little magic that allows the IDE to recognize options like:
.board.define0=-DHELLOWORLD
.board.option0=-DHELLOWORLD

In other words, add the -DHELLOWORD (#define HELLOWORLD) to the command line for GCC.

BUT, I can't get this to work without the Teensy add-on installed.

Is there a way to do this with the stock IDE?
Yes, it is possible in the 1.5.+ IDE. while not possible in the 1.0.+ and earlier.

Hardware-specification refers to both the boards.txt and platform.txt files.

in short the boards.txt file specifies...

uno.build.f_cpu=16000000L


and the platform.txt uses in the compile commands such as ...

 -DF_CPU={build.f_cpu}


You can your own. There is already a "build.extra_flags=" that some of the USB devices use to add their own FLAGs conditionally on the board type.