line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::CMake; |
2
|
3
|
|
|
3
|
|
190653
|
use strict; |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
83
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
78
|
|
4
|
3
|
|
|
3
|
|
1139
|
use Alien::CMake::ConfigData; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
102
|
|
5
|
3
|
|
|
3
|
|
1579
|
use File::ShareDir qw(dist_dir); |
|
3
|
|
|
|
|
79052
|
|
|
3
|
|
|
|
|
163
|
|
6
|
3
|
|
|
3
|
|
24
|
use File::Spec; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
56
|
|
7
|
3
|
|
|
3
|
|
14
|
use File::Find; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
196
|
|
8
|
3
|
|
|
3
|
|
1544
|
use File::Spec::Functions qw(catdir catfile rel2abs); |
|
3
|
|
|
|
|
2259
|
|
|
3
|
|
|
|
|
1576
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Alien::CMake - Build and make available CMake library - L |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.11 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Alien::CMake during its installation does one of the following: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item * Builds I binaries from source codes and installs dev |
29
|
|
|
|
|
|
|
files (headers: *.h, static library: *.a) into I |
30
|
|
|
|
|
|
|
directory of Alien::CMake distribution. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=back |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Later you can use Alien::CMake in your module that needs to link with I |
35
|
|
|
|
|
|
|
like this: |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Sample Build.pl |
38
|
|
|
|
|
|
|
use Module::Build; |
39
|
|
|
|
|
|
|
use Alien::CMake; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $build = Module::Build->new( |
42
|
|
|
|
|
|
|
module_name => 'Any::CMake::Module', |
43
|
|
|
|
|
|
|
# + other params |
44
|
|
|
|
|
|
|
build_requires => { |
45
|
|
|
|
|
|
|
'Alien::CMake' => 0, |
46
|
|
|
|
|
|
|
# + others modules |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
configure_requires => { |
49
|
|
|
|
|
|
|
'Alien::CMake' => 0, |
50
|
|
|
|
|
|
|
# + others modules |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
extra_compiler_flags => Alien::CMake->config('cflags'), |
53
|
|
|
|
|
|
|
extra_linker_flags => Alien::CMake->config('libs'), |
54
|
|
|
|
|
|
|
)->create_build_script; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
NOTE: Alien::CMake is required only for building not for using 'Any::CMake::Module'. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Please consider using L instead. It uses newer Alien |
61
|
|
|
|
|
|
|
technology and is more reliable. In particular, this module will download |
62
|
|
|
|
|
|
|
very old binaries for some platforms (some from the 2.x series). In |
63
|
|
|
|
|
|
|
addition L will build from source if binaries are not |
64
|
|
|
|
|
|
|
available for your platform. Also L integrates more |
65
|
|
|
|
|
|
|
naturally with L and L. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
In short C can be used to detect and get configuration |
68
|
|
|
|
|
|
|
settings from an already installed CMake. It offers also an option to |
69
|
|
|
|
|
|
|
download CMake source codes and build binaries from scratch. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 METHODS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 config() |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This function is the main public interface to this module: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Alien::CMake->config('prefix'); |
78
|
|
|
|
|
|
|
Alien::CMake->config('version'); |
79
|
|
|
|
|
|
|
Alien::CMake->config('libs'); |
80
|
|
|
|
|
|
|
Alien::CMake->config('cflags'); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 bin_dir() |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
For compatability with L, this will return the path containing C |
85
|
|
|
|
|
|
|
or empty list if it is already in the C. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 BUGS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Please post issues and bugs at L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
KMX, Ekmx at cpan.orgE, |
94
|
|
|
|
|
|
|
FROGGS, Efroggs at cpan.orgE, |
95
|
|
|
|
|
|
|
plicease Eplicease at cpan.orgE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This program is free software; you can redistribute |
100
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The full text of the license can be found in the |
103
|
|
|
|
|
|
|
LICENSE file included with this module. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
### get config params |
108
|
|
|
|
|
|
|
sub config |
109
|
|
|
|
|
|
|
{ |
110
|
7
|
|
|
7
|
1
|
98
|
my ($package, $param) = @_; |
111
|
7
|
50
|
|
|
|
21
|
return _cmake_config_via_config_data($param) if(Alien::CMake::ConfigData->config('config')); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub set_path |
115
|
|
|
|
|
|
|
{ |
116
|
1
|
|
|
1
|
0
|
814
|
my $path_sep = ':'; |
117
|
1
|
50
|
|
|
|
11
|
if($^O eq 'MSWin32') |
|
|
50
|
|
|
|
|
|
118
|
|
|
|
|
|
|
{ |
119
|
0
|
|
|
|
|
0
|
$path_sep = ';'; |
120
|
0
|
|
|
|
|
0
|
my @paths = split($path_sep, $ENV{'PATH'}); |
121
|
0
|
|
|
|
|
0
|
my @_paths = (); |
122
|
0
|
|
|
|
|
0
|
my $i = 0; |
123
|
0
|
|
|
|
|
0
|
foreach (@paths) |
124
|
|
|
|
|
|
|
{ |
125
|
0
|
0
|
|
|
|
0
|
push(@_paths, $_) unless -e "$_/sh.exe"; # cmake throws a warning when sh.exe is in path when using mingw32 |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
0
|
unless(Alien::CMake::ConfigData->config('script')) |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
|
|
0
|
unshift(@_paths, Alien::CMake->config('bin')); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
$ENV{'PATH'} = join($path_sep, @_paths); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
elsif(!Alien::CMake::ConfigData->config('script')) |
136
|
|
|
|
|
|
|
{ |
137
|
1
|
|
|
|
|
17
|
$ENV{'PATH'} = join($path_sep, Alien::CMake->config('bin'), $ENV{'PATH'}); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
3
|
return $ENV{'PATH'}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
### internal functions |
144
|
|
|
|
|
|
|
sub _cmake_config_via_config_data |
145
|
|
|
|
|
|
|
{ |
146
|
7
|
|
|
7
|
|
27
|
my ($param) = @_; |
147
|
7
|
|
|
|
|
12
|
my $real_prefix = ''; |
148
|
7
|
|
|
|
|
14
|
my $subdir = Alien::CMake::ConfigData->config('share_subdir'); |
149
|
7
|
50
|
|
|
|
15
|
if(Alien::CMake::ConfigData->config('script')) |
150
|
|
|
|
|
|
|
{ |
151
|
0
|
|
|
|
|
0
|
$real_prefix = $subdir; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
else |
154
|
|
|
|
|
|
|
{ |
155
|
7
|
|
|
|
|
22
|
my $share_dir = dist_dir('Alien-CMake'); |
156
|
7
|
50
|
|
|
|
688
|
return unless $subdir; |
157
|
7
|
|
|
|
|
32
|
$real_prefix = catdir($share_dir, $subdir); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
7
|
50
|
|
|
|
30
|
return unless ($param =~ /[a-z0-9_]*/i); |
161
|
7
|
|
|
|
|
22
|
my $val = Alien::CMake::ConfigData->config('config')->{$param}; |
162
|
7
|
50
|
|
|
|
13
|
return unless $val; |
163
|
|
|
|
|
|
|
# handle @PrEfIx@ replacement |
164
|
7
|
|
|
|
|
20
|
$val =~ s/\@PrEfIx\@/$real_prefix/g; |
165
|
7
|
|
|
|
|
61
|
return $val; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub bin_dir |
169
|
|
|
|
|
|
|
{ |
170
|
0
|
0
|
|
0
|
1
|
|
!Alien::CMake::ConfigData->config('script') |
171
|
|
|
|
|
|
|
? (Alien::CMake->config('bin')) |
172
|
|
|
|
|
|
|
: (); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |