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