summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2022-11-15 07:28:29 -0600
committerChad Elliott <elliottc@objectcomputing.com>2022-11-15 07:28:29 -0600
commit1d04f7001338262563dd1e527015366a6bf2fa23 (patch)
tree0df1927f8bd2e721027ff879397efd2955862854 /modules
parentfe2179434123896ad860c6ae3f092c7ab86f4c84 (diff)
downloadMPC-1d04f7001338262563dd1e527015366a6bf2fa23.tar.gz
Added a template function to help determine if a variable value is a CMake macro usage. This allows us to handle those values in a special way in the template to allow conditionally linking in libraries.
Diffstat (limited to 'modules')
-rw-r--r--modules/TemplateParser.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm
index f8fddaef..d2dd92e6 100644
--- a/modules/TemplateParser.pm
+++ b/modules/TemplateParser.pm
@@ -69,6 +69,7 @@ my %keywords = ('if' => 0,
'reverse' => $get_type|$perform_type,
'sort' => $get_type|$perform_type,
'uniq' => $get_type|$perform_type,
+ 'cmake_macro' => $get_type|$perform_type|$doif_type,
'multiple' => $get_type|$doif_type|$get_combined_type,
'starts_with' => $get_type|$doif_type|$get_combined_type,
'ends_with' => $get_type|$doif_type|$get_combined_type,
@@ -1721,6 +1722,43 @@ sub handle_basename {
}
+sub actual_cmake_macro {
+ my($self, $value) = @_;
+ return $1 if ($value =~ /^\$\{(\w+)\}$/);
+ return '';
+}
+
+
+sub perform_cmake_macro {
+ my($self, $value) = @_;
+ my @val;
+ foreach my $val (@$value) {
+ push(@val, $self->actual_cmake_macro($val));
+ }
+ return @val;
+}
+
+
+sub get_cmake_macro {
+ my($self, $name) = @_;
+ return $self->actual_cmake_macro($self->get_value_with_default($name));
+}
+
+
+sub doif_cmake_macro {
+ my($self, $value) = @_;
+ return (defined $value && $value ne '');
+}
+
+
+sub handle_cmake_macro {
+ my($self, $name) = @_;
+
+ $self->append_current(
+ $self->actual_cmake_macro($self->get_value_with_default($name)));
+}
+
+
sub handle_basenoextension {
my($self, $name) = @_;
my $val = $self->tp_basename($self->get_value_with_default($name));