IIRC it can only be done with options which have an equivalent short directive. For example with -Sh (equivalent to {$H+}), you can use {$IFOPT H+}.
Also, most cmd. line options set or reset features which you can interrogate in code with {$ifdef FPC_HAS_XXX} and similar.
Note that, specifically for -GW, you can detect whether your program is a GUI or console one by interrogating Application.ConsoleApplication, which in turns interrogates System.IsConsole.