Conditionally define constants in the CLI environment.

Only define constants if they don't already exist. Users can modify
`app/Console/cake.php` and define constants before this code executes.

Fixes #4000