That is different from your original question but that is quite easy.
Assume you compile with -CfAVX2 then your code will obey:
{$if defined(AVX2)}.....{$endif}
It is a bit cumbersome to test for any and all possible combinations, though.
What are you trying to achieve? To my mind this is in most cases an erronious way to improve your code.
It is only of interest when you write inline assembler code that supports that particular define and you really
know what you are doing otherwise the compiler does probably a better job.
(That's the trap beginners and intermediate level programmers make, there are few programmers that can make it stick, but there are some on this forum, like Marcov)
But possible.
(But the question is really if you are naive or an expert? That is something you have to answer to yourself.)