Skip to content

Commit 0bf8d1b

Browse files
Peter Oliverpks-t
authored andcommitted
meson: fix Perl version check for Meson versions before 1.7.0
Command `perl --version` says, e.g., “This is perl 5, version 26, subversion 0 (v5.26.0)”, which older versions of Meson interpret as version 26. This will be fixed in Meson 1.7.0, but at the time of writing that isn’t yet released. If we run `perl -V:version` we get the unambiguous response “version='5.26.0';”, but we need at least Meson 1.5.0 to be able to do that. Note that Perl are seriously considering dropping the leading 5 entirely in the near future (https://perl.github.io/PPCs/ppc0025-perl-version/), but that shouldn’t affect us. Signed-off-by: Peter Oliver <[email protected]> Co-authored-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d874d37 commit 0bf8d1b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

meson.build

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,22 @@ endif
777777

778778
# Note that we only set NO_PERL if the Perl features were disabled by the user.
779779
# It may not be set when we have found Perl, but only use it to run tests.
780-
perl = find_program('perl', version: '>=5.26.0', dirs: program_path, required: perl_required)
780+
#
781+
# At the time of writing, executing `perl --version` results in a string
782+
# similar to the following output:
783+
#
784+
# This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux-thread-multi
785+
#
786+
# Meson picks up the "40" as version number instead of using "v5.40.0"
787+
# due to the regular expression it uses. This got fixed in Meson 1.7.0,
788+
# but meanwhile we have to either use `-V:version` instead of `--version`,
789+
# which we can do starting with Meson 1.5.0 and newer, or we have to
790+
# match against the minor version.
791+
if meson.version().version_compare('>=1.5.0')
792+
perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')
793+
else
794+
perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')
795+
endif
781796
perl_features_enabled = perl.found() and get_option('perl').allowed()
782797
if perl_features_enabled
783798
build_options_config.set('NO_PERL', '')

0 commit comments

Comments
 (0)