Skip to content

Commit da6d9ff

Browse files
authored
Cmake version check (#400)
* add cmake version checker for doctor * fix linux distro checker message
1 parent d3a001d commit da6d9ff

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/SPC/doctor/item/LinuxToolCheckList.php

+16
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ public function checkCliTools(): ?CheckResult
7474
return CheckResult::ok();
7575
}
7676

77+
#[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')]
78+
public function checkCMakeVersion(): ?CheckResult
79+
{
80+
$check_cmd = 'cmake --version';
81+
$pattern = '/cmake version (.*)/m';
82+
$out = shell()->execWithResult($check_cmd, false)[1][0];
83+
if (preg_match($pattern, $out, $match)) {
84+
$ver = $match[1];
85+
if (version_compare($ver, '3.18.0') <= 0) {
86+
return CheckResult::fail('cmake version is too low (' . $ver . '), please update it manually!');
87+
}
88+
return CheckResult::ok($match[1]);
89+
}
90+
return CheckResult::fail('Failed to get cmake version');
91+
}
92+
7793
/** @noinspection PhpUnused */
7894
#[AsCheckItem('if necessary linux headers are installed', limit_os: 'Linux')]
7995
public function checkSystemOSPackages(): ?CheckResult

src/SPC/doctor/item/OSCheckList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function checkOS(): ?CheckResult
2020
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
2121
}
2222
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
23-
$known_distro = PHP_OS_FAMILY === 'Linux' && in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros());
23+
$known_distro = PHP_OS_FAMILY !== 'Linux' || in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros());
2424
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)'));
2525
}
2626
}

0 commit comments

Comments
 (0)