summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-08-30 09:49:58 +0200
committerSebastian Koslowski <koslowski@kit.edu>2016-08-30 17:52:43 +0200
commit8e36f2d4aca96b4815c50647e935f06b34040282 (patch)
treef5b68d9d5ed185aa4370260c421ed9d36b08f87c
parenta7a57791d452fb2543de178ae72cfd63581bf80e (diff)
grc: replace templated xml files with search and replace for qt4
-rw-r--r--grc/blocks/CMakeLists.txt23
-rw-r--r--grc/blocks/options.xml (renamed from grc/blocks/options.xml.cmakein)2
2 files changed, 20 insertions, 5 deletions
diff --git a/grc/blocks/CMakeLists.txt b/grc/blocks/CMakeLists.txt
index 8d93852c29..d46b1febbe 100644
--- a/grc/blocks/CMakeLists.txt
+++ b/grc/blocks/CMakeLists.txt
@@ -22,7 +22,18 @@ include(GrPython)
file(GLOB xml_files "*.xml")
-configure_file(options.xml.cmakein "${CMAKE_CURRENT_BINARY_DIR}/options.xml" @ONLY)
+macro(REPLACE_IN_FILE _xml_block match replace)
+ set(xml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_xml_block}")
+ set(xml_block "${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}")
+
+ list(REMOVE_ITEM xml_files "${xml_block_src}")
+ file(READ "${xml_block_src}" xml_block_src_text)
+ string(REPLACE "${match}" "${replace}"
+ xml_block_text "${xml_block_src_text}")
+ file(WRITE "${xml_block}" "${xml_block_text}")
+
+ list(APPEND generated_xml_files "${xml_block}")
+endmacro()
macro(GEN_BLOCK_XML _generator _xml_block)
set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator})
@@ -32,13 +43,17 @@ macro(GEN_BLOCK_XML _generator _xml_block)
DEPENDS ${generator} OUTPUT ${xml_block}
COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block}
)
-endmacro(GEN_BLOCK_XML)
+endmacro()
+
+GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml)
-GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml)
+if(DESIRED_QT_VERSION EQUAL 4)
+ REPLACE_IN_FILE(options.xml PyQt5 PyQt4)
+endif()
add_custom_target(grc_generated_xml ALL DEPENDS ${generated_xml_files})
install(
- FILES ${xml_files} "${CMAKE_CURRENT_BINARY_DIR}/options.xml" ${generated_xml_files}
+ FILES ${xml_files} ${generated_xml_files}
DESTINATION ${GRC_BLOCKS_DIR}
)
diff --git a/grc/blocks/options.xml.cmakein b/grc/blocks/options.xml
index 985662f82e..e03269292c 100644
--- a/grc/blocks/options.xml.cmakein
+++ b/grc/blocks/options.xml
@@ -16,7 +16,7 @@ from grc_gnuradio import wxgui as grc_wxgui
import wx
#end if
#if $generate_options() == 'qt_gui'
-from PyQt@DESIRED_QT_VERSION@ import Qt
+from PyQt5 import Qt
import sys
#end if
#if not $generate_options().startswith('hb')