Fix --add-compiler-defaults for newer standard versions containing space
@@ -69,7 +69,25 @@ def get_compiler_defines(compiler):
for line in out.splitlines(True):
LOG.debug("define: " + line)
define = line.strip().split(" ")[1:]
- d = "-D"+define[0] + '=' + '"' + ' '.join(define[1:]) + '"'
+
+ variable = define[0]
+ value = ' '.join(define[1:])
+
+ if value:
+ if '"' in value:
+ # Certain defines might contain string literals, such
+ # as
+ # #define __VERSION__ "5.4.0 20160609"
+ # which causes a problem when manually defining as
+ # Clang will not understand '-D__VERSION__=""...""'
+ # (note double quote) and instead attempt to use it as
+ # a folder...
+ value = value.replace('"', r'\"')
+
+ d = "-D{0}=\"{1}\"".format(variable, value)
+ else:
+ d = "-D{0}".format(variable)
+
defines.append(d)
except OSError as oerr:
LOG.error("Cannot find defines:" + oerr.strerror+"\n")
