summaryrefslogtreecommitdiff
path: root/grc/core
diff options
context:
space:
mode:
authorHåkon Vågsether <haakonsv@gmail.com>2019-07-25 22:29:48 +0200
committerMarcus Müller <marcus@hostalia.de>2019-07-29 22:24:15 +0200
commitaabceda61861cc8949df7c3a3d974609d23143a7 (patch)
tree8ac0357cde2d56158a19a51ff5387d19f02f245d /grc/core
parent5dec5e8ec3bf6cf6b6e060b437dae67bcbf2b168 (diff)
grc/cppgen: Use cli-style CMake options
In other words, use "-DKEY1=VAL1 -DKEY2=VAL2" instead of "KEY1=VAL1; KEY2=VAL2"
Diffstat (limited to 'grc/core')
-rw-r--r--grc/core/generator/cpp_templates/CMakeLists.txt.mako7
-rw-r--r--grc/core/generator/cpp_top_block.py10
2 files changed, 13 insertions, 4 deletions
diff --git a/grc/core/generator/cpp_templates/CMakeLists.txt.mako b/grc/core/generator/cpp_templates/CMakeLists.txt.mako
index caae2dd9fb..1b212e7bcc 100644
--- a/grc/core/generator/cpp_templates/CMakeLists.txt.mako
+++ b/grc/core/generator/cpp_templates/CMakeLists.txt.mako
@@ -13,7 +13,6 @@
<%
class_name = flow_graph.get_option('id')
-cmake_opt_list = flow_graph.get_option('cmake_opt').split(";")
%>\
cmake_minimum_required(VERSION 3.8)
@@ -37,9 +36,9 @@ add_definitions(${'$'}{Qt5Widgets_DEFINITIONS})
set(CMAKE_AUTOMOC TRUE)
% endif
-% if cmake_opt_list != ['']:
-% for opt in cmake_opt_list:
-set(${opt.split("=")[0].strip()} ${opt.split("=")[1].strip()})
+% if cmake_tuples:
+% for key, val in cmake_tuples:
+set(${key} ${val})
% endfor
% endif
diff --git a/grc/core/generator/cpp_top_block.py b/grc/core/generator/cpp_top_block.py
index d639536db9..c24e855d48 100644
--- a/grc/core/generator/cpp_top_block.py
+++ b/grc/core/generator/cpp_top_block.py
@@ -155,6 +155,15 @@ class CppTopBlockGenerator(TopBlockGenerator):
filename = 'CMakeLists.txt'
file_path = os.path.join(self.file_path, filename)
+ cmake_tuples = []
+ cmake_opt = self._flow_graph.get_option("cmake_opt")
+ cmake_opt = " " + cmake_opt # To make sure we get rid of the "-D"s when splitting
+
+ for opt_string in cmake_opt.split(" -D"):
+ opt_string = opt_string.strip()
+ if opt_string:
+ cmake_tuples.append(tuple(opt_string.split("=")))
+
output = []
flow_graph_code = cmake_template.render(
@@ -164,6 +173,7 @@ class CppTopBlockGenerator(TopBlockGenerator):
callbacks=self._callbacks(),
connections=self._connections(),
links=self._links(),
+ cmake_tuples=cmake_tuples,
**self.namespace
)
# strip trailing white-space