CAP is generally produced in low glucose environments, because it needs cAMP to bind to the DNA. However, when glucose is high, there is less cAMP, so that's why the lac operon (which needs CAP to catalyze more transcription) only kicks in when there is low glucose and lactose available