line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Build::CMake; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2084
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
97
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
86
|
|
5
|
3
|
|
|
3
|
|
60
|
use 5.008004; |
|
3
|
|
|
|
|
11
|
|
6
|
3
|
|
|
3
|
|
17
|
use Config; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
134
|
|
7
|
3
|
|
|
3
|
|
474
|
use Alien::Build::Plugin; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
21
|
|
8
|
3
|
|
|
3
|
|
21
|
use Capture::Tiny qw( capture ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2482
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: CMake plugin for Alien::Build |
11
|
|
|
|
|
|
|
our $VERSION = '2.46'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub cmake_generator |
15
|
|
|
|
|
|
|
{ |
16
|
1
|
50
|
|
1
|
1
|
10
|
if($^O eq 'MSWin32') |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
0
|
|
|
|
0
|
return 'MinGW Makefiles' if is_dmake(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
|
0
|
my($out, $err) = capture { system $Config{make}, '/?' }; |
|
0
|
|
|
|
|
0
|
|
22
|
0
|
0
|
|
|
|
0
|
return 'NMake Makefiles' if $out =~ /NMAKE/; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
|
0
|
my($out, $err) = capture { system $Config{make}, '--version' }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
27
|
0
|
0
|
|
|
|
0
|
return 'MinGW Makefiles' if $out =~ /GNU Make/; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
die 'make not detected'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else |
33
|
|
|
|
|
|
|
{ |
34
|
1
|
|
|
|
|
6
|
return 'Unix Makefiles'; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub init |
39
|
|
|
|
|
|
|
{ |
40
|
0
|
|
|
0
|
1
|
|
my($self, $meta) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$meta->prop->{destdir} = $^O eq 'MSWin32' ? 0 : 1; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$meta->add_requires('configure' => 'Alien::Build::Plugin::Build::CMake' => '0.99'); |
45
|
0
|
|
|
|
|
|
$meta->add_requires('share' => 'Alien::cmake3' => '0.02'); |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if(is_dmake()) |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
# even on at least some older versions of strawberry that do not |
50
|
|
|
|
|
|
|
# use it, come with gmake in the PATH. So to save us the effort |
51
|
|
|
|
|
|
|
# of having to install Alien::gmake lets just use that version |
52
|
|
|
|
|
|
|
# if we can find it! |
53
|
0
|
|
|
|
|
|
my $found_gnu_make = 0; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
foreach my $exe (qw( gmake make mingw32-make )) |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
|
|
my($out, $err) = capture { system $exe, '--version' }; |
|
0
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if($out =~ /GNU Make/) |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
|
|
$meta->interpolator->replace_helper('make' => sub { $exe }); |
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$found_gnu_make = 1; |
62
|
0
|
|
|
|
|
|
last; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if(!$found_gnu_make) |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
|
|
|
$meta->add_requires('share' => 'Alien::gmake' => '0.20'); |
69
|
0
|
|
|
0
|
|
|
$meta->interpolator->replace_helper('make' => sub { require Alien::gmake; Alien::gmake->exe }); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
|
|
$meta->interpolator->replace_helper('cmake' => sub { require Alien::cmake3; Alien::cmake3->exe }); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$meta->interpolator->add_helper('cmake_generator' => \&cmake_generator); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my @args = ( |
77
|
|
|
|
|
|
|
-G => '%{cmake_generator}', |
78
|
|
|
|
|
|
|
'-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true', |
79
|
|
|
|
|
|
|
'-DCMAKE_INSTALL_PREFIX:PATH=%{.install.prefix}', |
80
|
|
|
|
|
|
|
'-DCMAKE_INSTALL_LIBDIR:PATH=lib', |
81
|
|
|
|
|
|
|
'-DCMAKE_MAKE_PROGRAM:PATH=%{make}', |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$meta->prop->{plugin_build_cmake}->{args} = \@args; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$meta->default_hook( |
87
|
|
|
|
|
|
|
build => [ |
88
|
|
|
|
|
|
|
['%{cmake}', @args, '%{.install.extract}' ], |
89
|
|
|
|
|
|
|
['%{make}' ], |
90
|
|
|
|
|
|
|
['%{make}', 'install' ], |
91
|
|
|
|
|
|
|
], |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# TODO: handle destdir on windows ?? |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $is_dmake; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub is_dmake |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
0
|
|
0
|
1
|
|
unless(defined $is_dmake) |
102
|
|
|
|
|
|
|
{ |
103
|
0
|
0
|
|
|
|
|
if($^O eq 'MSWin32') |
104
|
|
|
|
|
|
|
{ |
105
|
0
|
|
|
0
|
|
|
my($out, $err) = capture { system $Config{make}, '-V' }; |
|
0
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
$is_dmake = $out =~ /dmake/ ? 1 : 0; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else |
109
|
|
|
|
|
|
|
{ |
110
|
0
|
|
|
|
|
|
$is_dmake = 0; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$is_dmake; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |