changeset 1041:95939fa925f6

LinuxStandardBaseUic.py
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Oct 2019 17:23:27 +0200
parents 14c0a29cd9ec
children b26fb3a99f01 b60d70e8b55c
files Resources/CMake/LinuxStandardBaseUic.py Resources/CMake/QtConfiguration.cmake
diffstat 2 files changed, 41 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/LinuxStandardBaseUic.py	Tue Oct 08 17:23:27 2019 +0200
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+import subprocess
+import sys
+
+if len(sys.argv) <= 1:
+    sys.stderr.write('Please provide arguments for uic\n')
+    sys.exit(-1)
+
+path = ''
+pos = 1
+while pos < len(sys.argv):
+    if sys.argv[pos].startswith('-'):
+        pos += 2
+    else:
+        path = sys.argv[pos]
+        break
+
+if len(path) == 0:
+    sys.stderr.write('Unable to find the input file in the arguments to uic\n')
+    sys.exit(-1)
+
+with open(path, 'r') as f:
+    lines = f.read().split('\n')
+    if (len(lines) > 1 and
+        lines[0].startswith('<?')):
+        content = '\n'.join(lines[1:])
+    else:
+        content = '\n'.join(lines)
+        
+# Remove the source file from the arguments
+args = sys.argv[1:pos] + sys.argv[pos+1:]
+
+p = subprocess.Popen([ '/opt/lsb/bin/uic' ] + args,
+                     stdin = subprocess.PIPE)
+p.communicate(input = content)
--- a/Resources/CMake/QtConfiguration.cmake	Tue Oct 08 11:19:58 2019 +0200
+++ b/Resources/CMake/QtConfiguration.cmake	Tue Oct 08 17:23:27 2019 +0200
@@ -24,7 +24,11 @@
   # Linux Standard Base version 5 ships Qt 4.2.3
   include(Qt4Macros)
 
-  set(QT_UIC_EXECUTABLE ${LSB_PATH}/bin/uic)
+  # The script "LinuxStandardBaseUic.py" is just a wrapper around the
+  # "uic" compiler from LSB that does not support the "<?xml ...?>"
+  # header that is automatically added by Qt Creator
+  set(QT_UIC_EXECUTABLE ${CMAKE_CURRENT_LIST_DIR}/LinuxStandardBaseUic.py)
+
   set(QT_MOC_EXECUTABLE ${LSB_PATH}/bin/moc)
 
   include_directories(