1 package CMakeProjectCreator
;
3 # ************************************************************
4 # Description : A CMake Project Creator
5 # Author : Chad Elliott
6 # Create Date : 10/10/2022
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
18 @ISA = qw(ProjectCreator);
20 # ************************************************************
22 # ************************************************************
27 ## For CMake, we are expecting a hybrid of custom types and modules.
28 ## We are turning off all automatic output so that the modules defined
29 ## for CMake can handle these artifacts.
30 foreach my $gentype (keys %{$self->{'generated_exts'}}) {
31 $self->{'generated_exts'}->{$gentype}->{'automatic_out'} = 0;
35 sub default_to_library
{
36 ## In case there are only generated source files...
40 sub need_to_write_project
{
43 ## Because we do not automatically add custom output, it is possible that
44 ## the project only has generated source files and expects them to cause
45 ## an automatic library name to be chosen. If the base
46 ## need_to_write_project() tells us that it's only generated source files
47 ## but the user didn't mark this project as "custom only", then we have to
48 ## override it back to 1 to retain the user provided target name.
49 my $status = $self->SUPER::need_to_write_project
();
50 if ($status == 2 && !$self->get_assignment('custom_only')) {
58 ## Override the option getter so that, for CMake, MPC always functions as
59 ## if the -use_env option was supplied on the command line.
63 sub pre_write_output_file
{
65 return $self->combine_custom_types();
72 sub project_file_prefix
{
81 sub get_dll_exe_template_input_file
{
85 sub get_dll_template_input_file
{
90 my($self, $name) = @_;
92 if ($name eq 'language') {
93 ## Currently, we only support C++
94 return 'CXX' if ($self->get_language() eq Creator
::cplusplus
());
96 elsif ($name =~ /^env_(\w+)/) {
97 my $dotdir = '${CMAKE_CURRENT_SOURCE_DIR}' .
98 ($1 eq 'libpaths' ?
' ${CMAKE_CURRENT_BINARY_DIR}' : '');
99 my $paths = $self->get_assignment($1);
100 if (defined $paths) {
101 $paths = $self->create_array($paths);
102 foreach my $path (@
$paths) {
107 $path =~ s/\$\(([^\)]+)\)/\${$1}/g;