line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Build::CMake; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
518435
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
119
|
|
4
|
3
|
|
|
3
|
|
23
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
117
|
|
5
|
3
|
|
|
3
|
|
187
|
use 5.008001; |
|
3
|
|
|
|
|
18
|
|
6
|
3
|
|
|
3
|
|
23
|
use Config; |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
181
|
|
7
|
3
|
|
|
3
|
|
1000
|
use Alien::Build::Plugin; |
|
3
|
|
|
|
|
6356
|
|
|
3
|
|
|
|
|
31
|
|
8
|
3
|
|
|
3
|
|
1031
|
use Capture::Tiny qw( capture ); |
|
3
|
|
|
|
|
80927
|
|
|
3
|
|
|
|
|
3450
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: CMake plugin for Alien::Build |
11
|
|
|
|
|
|
|
our $VERSION = '0.04_01'; # TRIAL VERSION |
12
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub cmake_generator |
16
|
|
|
|
|
|
|
{ |
17
|
2
|
50
|
|
2
|
1
|
113
|
if($^O eq 'MSWin32') |
18
|
|
|
|
|
|
|
{ |
19
|
0
|
0
|
|
|
|
0
|
return 'Unix Makefiles' if is_dmake(); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
|
0
|
my($out, $err) = capture { system $Config{make}, '/?' }; |
|
0
|
|
|
|
|
0
|
|
23
|
0
|
0
|
|
|
|
0
|
return 'NMake Makefiles' if $out =~ /NMAKE/; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
|
0
|
my($out, $err) = capture { system $Config{make}, '--version' }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
28
|
0
|
0
|
|
|
|
0
|
return 'Unix Makefiles' if $out =~ /GNU Make/; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
die 'make not detected'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else |
34
|
|
|
|
|
|
|
{ |
35
|
2
|
|
|
|
|
16
|
return 'Unix Makefiles'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub init |
40
|
|
|
|
|
|
|
{ |
41
|
1
|
|
|
1
|
1
|
60206
|
my($self, $meta) = @_; |
42
|
|
|
|
|
|
|
|
43
|
1
|
50
|
|
|
|
12
|
$meta->prop->{destdir} = $^O eq 'MSWin32' ? 0 : 1; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
14
|
$meta->add_requires('share' => 'Alien::cmake3' => '0.02'); |
46
|
|
|
|
|
|
|
|
47
|
1
|
50
|
|
|
|
28
|
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
|
|
|
|
|
0
|
my $found_gnu_make = 0; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
foreach my $exe (qw( gmake make )) |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
|
0
|
my($out, $err) = capture { system $exe, '--version' }; |
|
0
|
|
|
|
|
0
|
|
58
|
0
|
0
|
|
|
|
0
|
if($out =~ /GNU Make/) |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
|
0
|
$meta->interpolator->replace_helper('make' => sub { $exe }); |
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
$found_gnu_make = 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
if(!$found_gnu_make) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
0
|
$meta->add_requires('share' => 'Alien::gmake' => '0.20'); |
68
|
0
|
|
|
0
|
|
0
|
$meta->interpolator->replace_helper('make' => sub { require Alien::gmake; Alien::gmake->exe }); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
1
|
|
7
|
$meta->interpolator->replace_helper('cmake' => sub { require Alien::cmake3; Alien::cmake3->exe }); |
|
1
|
|
|
|
|
38511
|
|
|
1
|
|
|
|
|
10
|
|
73
|
1
|
|
|
|
|
4128
|
$meta->interpolator->add_helper('cmake_generator' => \&cmake_generator); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
38
|
$meta->default_hook( |
76
|
|
|
|
|
|
|
build => [ |
77
|
|
|
|
|
|
|
['%{cmake}', -G => '%{cmake_generator}', '-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true', '-DCMAKE_INSTALL_PREFIX:PATH=%{.install.prefix}', '.' ], |
78
|
|
|
|
|
|
|
['%{make}' ], |
79
|
|
|
|
|
|
|
['%{make}', 'install' ], |
80
|
|
|
|
|
|
|
], |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# TODO: set the makefile type ?? |
84
|
|
|
|
|
|
|
# TODO: handle destdir on windows ?? |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $is_dmake; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub is_dmake |
90
|
|
|
|
|
|
|
{ |
91
|
2
|
50
|
|
2
|
1
|
40
|
unless(defined $is_dmake) |
92
|
|
|
|
|
|
|
{ |
93
|
2
|
50
|
|
|
|
12
|
if($^O eq 'MSWin32') |
94
|
|
|
|
|
|
|
{ |
95
|
0
|
|
|
0
|
|
0
|
my($out, $err) = capture { system $Config{make}, '-V' }; |
|
0
|
|
|
|
|
0
|
|
96
|
0
|
0
|
|
|
|
0
|
$is_dmake = $out =~ /dmake/ ? 1 : 0; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
else |
99
|
|
|
|
|
|
|
{ |
100
|
2
|
|
|
|
|
6
|
$is_dmake = 0; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
16
|
$is_dmake; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |