summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2022-11-17 12:30:10 -0600
committerChad Elliott <elliottc@objectcomputing.com>2022-11-17 12:30:10 -0600
commit841f148543c35674b10b3143abc563f0223b0d6f (patch)
tree20a13323719e0726a9b4fd400a8eea1d3da1d86c /modules
parentd4736ff20e0db3ec6a1d8d8c98af8027ebbb83c3 (diff)
downloadMPC-841f148543c35674b10b3143abc563f0223b0d6f.tar.gz
Support multiple projects in the out-of-tree workspaces.
Diffstat (limited to 'modules')
-rw-r--r--modules/CMakeWorkspaceCreator.pm35
1 files changed, 24 insertions, 11 deletions
diff --git a/modules/CMakeWorkspaceCreator.pm b/modules/CMakeWorkspaceCreator.pm
index a3cdafea..f5d9e63a 100644
--- a/modules/CMakeWorkspaceCreator.pm
+++ b/modules/CMakeWorkspaceCreator.pm
@@ -95,17 +95,20 @@ sub write_ws_top {
"project($ws CXX)", $crlf;
}
-sub write_single_include_ws {
- my($self, $prj) = @_;
+sub write_include_ws {
+ my($self, $prjs) = @_;
my $fh = new FileHandle();
- my $dir = $self->mpc_dirname($prj);
+ my $dir = $self->mpc_dirname($$prjs[0]);
my $file = $dir . '/' . $self->workspace_file_name();
if (open($fh, ">$file")) {
my $crlf = $self->crlf();
$self->pre_workspace($fh);
$self->write_ws_top($fh, basename($dir));
- print $fh "${crlf}include(", basename($prj), ")$crlf";
+ foreach my $prj (@$prjs) {
+ print $fh "${crlf}include(", basename($prj), ")";
+ }
+ print $fh $crlf;
close($fh);
}
}
@@ -121,19 +124,28 @@ sub write_comps {
## directory. The workspace in that directory will handle going to
## other subdirectories.
my %dirs;
+ my %out_of_tree;
foreach my $entry (@projects) {
my $dir = $self->get_top_directory($entry);
- if ($dir ne $entry && !exists $dirs{$dir}) {
- ## Keep track of the project existing in this directory
- $dirs{$dir} = 1;
+ if ($dir ne $entry) {
+ if (!exists $dirs{$dir}) {
+ ## Keep track of the project existing in this directory
+ $dirs{$dir} = 1;
+
+ push(@project_dirs, $dir);
+ }
## If this directory is out-of-tree, it will not contain a top-level
## workspace (due to the way that workspace-per-directory works). We
- ## need to generate one here.
+ ## need to keep track of it here.
if ($self->out_of_tree($dir)) {
- $self->write_single_include_ws($entry);
+ if (exists $out_of_tree{$dir}) {
+ push(@{$out_of_tree{$dir}}, $entry);
+ }
+ else {
+ $out_of_tree{$dir} = [$entry];
+ }
}
- push(@project_dirs, $dir);
}
}
@@ -151,7 +163,7 @@ sub write_comps {
print $fh $crlf;
}
my $bin_dir = '';
- if ($self->out_of_tree($dir)) {
+ if (exists $out_of_tree{$dir}) {
## Because this directory is out-of-tree, CMake requires a binary
## directory to be passed to add_subdirectory().
my $bin = basename($dir);
@@ -160,6 +172,7 @@ sub write_comps {
}
$bin_dir = " $bin";
$bin_used{$bin} = 1;
+ $self->write_include_ws($out_of_tree{$dir});
}
print $fh "add_subdirectory($dir$bin_dir)$crlf";
}