This could be the acid test of how the spell works.
If the spell always detects the recipient as being an enemy, then even someone behind a door, completely unaware of the casters presence, will detect as an enemy.
Alternatively, if the spell relies on picking up some kind of instantaneous "intent" from the recipient (such as acting on a personal grudge, a cult antipathy (Orlanth v. a chaot), or perhaps a racial hatred (Troll v. Elf for example)), then it will not work - since there cannot be a "plan" on the part of the recipient to harm the caster if they don't know that they are there.
Just to add some fuel to this discussion, how about this use-case: the recipient of the Detect Enemy spell had been fighting the party the caster is in, but someone else has successfully cast Befuddle on the recipient. Now, in a Befuddled state, but previously having been intending to harm the Caster, will the recipient still detect as an enemy?
And taking this one step further, could you deliberately Befuddle an ally, and then push them through a Warding - so as to defeat the Warding activating (in a Befuddled state, can the recipient of the spell feel antipathy to anyone (except perhaps the person who just shoved them through the Warding)?
Just having a thoughtful Sunday Morning, savouring a mug of Jamaica Blue Mountain coffee and listening to the new Manics album.