Consider the situation: I am wearing an Amulet of Proof against Detection and Location, giving me the following effect:
While wearing this amulet, you are hidden from divination magic. You can't be targeted by such magic or perceived through magical scrying sensors.
I want to cast the detect magic spell, which has a range of self. Am I correct in assuming that the spell targets me, and thus I will be unable to cast it until I remove it? None of the existing answers cover the eventuality where you are casting the spell, only whether or not you show up to somebody else with it.