--- configure.py
+++ configure.py
@@ -1871,6 +1871,15 @@
     if macros is None:
         return None
 
+    # QMake macros may contain comments on the same line so we need to remove them
+    if sys.version[0] == '3':
+        mitems = list(macros.items())
+    else:
+        mitems = macros.iteritems()
+    for macro, value in mitems:
+        if "#" in value:
+            macros[macro] = value.split("#", 1)[0]
+
     # Qt5 doesn't seem to support the specific macros so add them if they are
     # missing.
     if macros.get("INCDIR_QT", "") == "":
