File Coverage

alienfile
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1 1     1   171076 use alienfile;
  1         2  
  1         5  
2              
3 1     1   140 use Config;
  1         2  
  1         21  
4 1     1   4 use File::Spec;
  1         1  
  1         826  
5              
6             # NOTE: you can set ALIEN_CMAKE_FROM_SOURCE to force a build from source
7             # even on platforms which have binary versions of cmake available. Normally
8             # you should only need this for testing the build from source capability of
9             # this alienfile.
10              
11             plugin 'Probe::CommandLine' => (
12             command => 'cmake',
13             args => ['--version'],
14             match => qr/^cmake\s+version\s+4\.[0-9\.]+/m,
15             version => qr/^cmake\s+version\s+(4\.[0-9\.]+)/,
16             );
17              
18             share {
19             my $binary_release_name;
20             my $binary_format;
21             if ($^O eq 'linux' && $Config{'archname'} =~ /^x86_64/) {
22             $binary_release_name = 'linux-x86_64';
23             $binary_format = 'tar.gz';
24             } elsif ($^O eq 'linux' && $Config{'archname'} =~ /^aarch64/) {
25             $binary_release_name = 'linux-aarch64';
26             $binary_format = 'tar.gz';
27             } elsif ($^O eq 'MSWin32' && $Config{'ptrsize'} == 4) {
28             $binary_release_name = 'windows-i386';
29             $binary_format = 'zip';
30             } elsif ($^O eq 'MSWin32' && $Config{'ptrsize'} == 8) {
31             $binary_release_name = 'windows-x86_64';
32             $binary_format = 'zip';
33             } elsif ($^O eq 'darwin' && $Config{'ptrsize'} == 8) {
34             my ($major, $minor, $patch) = map {
35             my $v = $_;
36             $v =~ s/^\s+//;
37             $v =~ s/\s+$//;
38             $v;
39             } split /\./, [split /:/, `sw_vers|grep ProductVersion`]->[1];
40             if ($major >= 11 || ($major == 10 && $minor >= 13)) {
41             $binary_release_name = 'macos-universal';
42             } else {
43             $binary_release_name = 'macos10.10-universal';
44             }
45             $binary_format = 'tar.gz';
46             }
47              
48             # For platforms where there is a binary release, use that:
49             if ($binary_release_name && ! $ENV{ALIEN_CMAKE_FROM_SOURCE}) {
50             start_url 'https://cmake.org/files/v4.3';
51             plugin Download => (
52             filter => qr/^cmake-4\.[0-9\.]+-\Q$binary_release_name\E\.\Q$binary_format\E$/,
53             version => qr/([0-9\.]+)/,
54             ($^O eq 'MSWin32' ? (bootstrap_ssl => 1) : ()),
55             );
56             plugin Extract => $binary_format;
57             if ($^O eq 'MSWin32') {
58             build sub {
59             my $build = shift;
60             # This is a rare case where we actually want the borked windows
61             # type paths with backslashes.
62             my $stage = File::Spec->catdir($build->install_prop->{stage});
63             path($stage)->mkpath unless -d $stage;
64             $build->system("xcopy . $stage /E");
65             };
66             } elsif ($^O eq 'darwin') {
67             build [
68             'cp -a CMake.app/Contents/* %{.install.stage}',
69             sub { shift->runtime_prop->{style} = 'binary' },
70             ];
71             } else {
72             build [
73             'cp -ar * %{.install.stage}',
74             sub { shift->runtime_prop->{style} = 'binary' },
75             ];
76             }
77              
78             # For platforms without a (recent) binary release, build it from source.
79             } else {
80             start_url 'https://cmake.org/download/';
81             plugin Download => (
82             filter => qr/^cmake-4\.[0-9\.]+\.tar.gz$/,
83             version => qr/([0-9\.]+)/,
84             );
85             plugin Extract => 'tar.gz';
86             plugin 'Build::Autoconf' => ('with_pic' => 0);
87             build [
88             '%{configure}',
89             '%{make}',
90             '%{make} install',
91             sub { shift->runtime_prop->{style} = 'source' },
92             ];
93             }
94              
95             after 'gather' => sub {
96             my $build = shift;
97              
98             $build->runtime_prop->{'command'} = 'cmake';
99             };
100             };