Dear all,
I found where and how to implement this feature. For anyone requiring the same here is the patch:
--- src/plugins/compilergcc/compilergcc.cpp	(revision 2420)
+++ src/plugins/compilergcc/compilergcc.cpp	(working copy)
@@ -633,8 +633,34 @@
 					"This can't be good. There may be problems running "
 					"system commands and the application might not behave "
 					"the way it was designed to...");
+
 //    wxGetEnv("PATH", &path);
 //    Manager::Get()->GetMessageManager()->Log(m_PageIndex, "PATH set to: %s", path.c_str());
+
+  // apply the env vars for this target
+  StringHash vars = CompilerFactory::GetCompiler(m_CompilerId)->GetAllVars();
+  if (!vars.empty())
+  {
+    StringHash::iterator it;
+    for(it = vars.begin(); it!=vars.end(); ++it)
+    {
+      wxString var       = it->first;
+      wxString var_value = it->second;
+      wxString old_value;
+
+      // apply only if not already set (do not overwrite existing variables)
+      if (!wxGetEnv(var, &old_value))
+      {
+        wxSetEnv(var, var_value);
+//        Manager::Get()->GetMessageManager()->DebugLog(_T("Applied environment variable %s with value %s..."), var.c_str(), var_value.c_str());
+      }
+//      else
+//      {
+//        Manager::Get()->GetMessageManager()->DebugLog(_T("Environment variable %s not applied."), var.c_str());
+//        Manager::Get()->GetMessageManager()->DebugLog(_T("(Environment variable %s is currently set to %s.)"), var.c_str(), old_value.c_str());
+//      }
+    }
+  }
 }
 
 void CompilerGCC::SetEnvironmentForCompiler(const wxString& id, wxString& envPath)
 Please note that this patch:
1.) only expands compiler custom variables to environment variables and
2.) does not expand a variable that already exist in the environment.
This is on purpose but might be changed if someone requires a different solution.
With regards, Morten.
Ps.: To the devs: Do you think this makes sense? I could improve the patch to save old environment variabes and re-apply the old settings ones the compiler command is issued (similar as it is done with the PATH environment variable). But before I would like to know whether you agree, or not.
Edit: Updated the patch to be more convenient.