title: Conditionally compile units for FMX or VCL
body: <p>I want to have a different list of units in the <code>uses</code> clause depending on compiling for FMX or VCL. In the code below I try to test <code>FireMonkeyVersion</code> which works in an FMX project (<code>label1.Text</code> is 'FMX'). When I move the $IF statement into the <code>uses</code> clause I get an error message (<code>[dcc32 Error] fmx_text.pas(7): E2026 Constant expression expected</code>). Is there any way to get the desired conditional compilation?</p>
  
  <pre><code>unit fmx_text;
  
  interface
  
  uses
    System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
    System.Variants, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Types;
  {$IF FireMonkeyVersion &gt;= 16}
     {$DEFINE HAS_FMX}
  {$ELSE}
     {$DEFINE HAS_VCL}
  {$IFEND}
  
  type
  
    TForm2 = class(TForm)
      Label1: TLabel;
      procedure FormCreate(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form2: TForm2;
  
  implementation
  
  {$R *.fmx}
  
  procedure TForm2.FormCreate(Sender: TObject);
  begin
     label1.Text := 'Undefined';
  {$IFDEF HAS_FMX}
     label1.Text := 'FMX';
  {$ENDIF}
  {$IFDEF HAS_VCL}
     label1.Text := 'VCL';
  {$ENDIF}
  end;
  
  end.
  </code></pre>