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