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/CMakeProjectCreator.pm | |
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/CMakeProjectCreator.pm')
-rw-r--r-- | modules/CMakeProjectCreator.pm | 65 |
1 files changed, 33 insertions, 32 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; } |