diff options
author | Chad Elliott <elliottc@objectcomputing.com> | 2022-10-12 06:21:58 -0500 |
---|---|---|
committer | Chad Elliott <elliottc@objectcomputing.com> | 2022-10-12 06:21:58 -0500 |
commit | 56c19e2f626ecaee103d146b32f5ab4ad6d1086a (patch) | |
tree | 25de2779772783e3d4621301b72c1008858dcaf8 /modules | |
parent | 5099bdb4327d16bf0946a78c5c332e46c8a48677 (diff) | |
download | MPC-56c19e2f626ecaee103d146b32f5ab4ad6d1086a.tar.gz |
Turn off automatic output for all custom commands. That must be handled by CMake modules.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/CMakeProjectCreator.pm | 65 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 13 |
2 files changed, 45 insertions, 33 deletions
diff --git a/modules/CMakeProjectCreator.pm b/modules/CMakeProjectCreator.pm index cf9883d0..a9bdeec2 100644 --- a/modules/CMakeProjectCreator.pm +++ b/modules/CMakeProjectCreator.pm @@ -28,6 +28,39 @@ my %info = (Creator::cplusplus() => {'template' => 'cmake'}); # Subroutine Section # ************************************************************ +sub pre_generation { + my $self = shift; + + ## For CMake, we are expecting a hybrid of custom types and modules. + ## We are turning off all automatic output so that the modules defined + ## for CMake can handle these artifacts. + foreach my $gentype (keys %{$self->{'generated_exts'}}) { + $self->{'generated_exts'}->{$gentype}->{'automatic_out'} = 0; + } +} + +sub default_to_library { + ## In case there are only generated source files... + return 1; +} + +sub need_to_write_project { + my $self = shift; + + ## Because we do not automatically add custom output, it is possible that + ## the project only has generated source files and expects them to cause + ## an automatic library name to be chosen. If the base + ## need_to_write_project() tells us that it's only generated source files + ## but the user didn't mark this project as "custom only", then we have to + ## override it back to 1 to retain the user provided target name. + my $status = $self->SUPER::need_to_write_project(); + if ($status == 2 && !$self->get_assignment('custom_only')) { + $status = 1; + } + + return $status; +} + sub dollar_special { return 1; } @@ -73,38 +106,6 @@ sub fill_value { return "@$paths"; } } - elsif ($name eq 'non_generated_sources') { - ## Get our list of source files, which will contain files added by the user - ## as well as files generated by custom commands. - my $tag = 'source_files'; - my @list = $self->get_component_list($tag); - - my $ctypes = $self->get_assignment('custom_types'); - if (defined $ctypes) { - $ctypes = $self->create_array($ctypes); - - ## Get a list of files that exist within @list that are generated by - ## custom commands. - my @added; - foreach my $ctype (@$ctypes) { - foreach my $file (@list) { - $self->list_generated_file($ctype, $tag, \@added, $file); - } - } - - ## Any file in @added needs to be removed from @list - foreach my $added (@added) { - for(my $i = 0; $i <= $#list; $i++) { - if ($list[$i] eq $added) { - splice(@list, $i, 1); - $i--; - } - } - } - } - - return "@list"; - } return undef; } diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index 48582ea1..6dd1d2fe 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -834,6 +834,9 @@ sub parse_line { ## Project Ending if (!defined $self->{'reading_parent'}->[0] && !$self->{'reading_global'}) { + ## Call into the project type's pre-generation hook. + $self->pre_generation(); + ## Fill in all the default values $self->generate_defaults(); @@ -2861,7 +2864,7 @@ sub generate_default_target_names { if (!defined $sources[0]) { @sources = $self->get_component_list($self->get_resource_tag(), 1); } - if (defined $sources[0]) { + if (defined $sources[0] || $self->default_to_library()) { if (!$shared_empty) { $self->process_assignment('sharedname', $self->{'unmodified_project_name'}); @@ -6081,4 +6084,12 @@ sub pre_write_output_file { return 1; } +sub pre_generation { + #my $self = shift; +} + +sub default_to_library { + return 0; +} + 1; |