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
Merge branch 'master' into 2.4