Skip to content

Commit ab4e0bc

Browse files
authored
Merge pull request #741 from crazywhalecc/fix/freetype-cmake
force minimum version 3.5 for cmake policies in freetype
2 parents 42f356d + 1b7404f commit ab4e0bc

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

src/SPC/builder/unix/library/freetype.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ trait freetype
1818
*/
1919
protected function build(): void
2020
{
21-
$extra_libs = $this->builder->getLib('libpng') ? '-DFT_DISABLE_PNG=OFF ' : '-DFT_DISABLE_PNG=ON ';
22-
$extra_libs .= $this->builder->getLib('bzip2') ? '-DFT_DISABLE_BZIP2=OFF ' : '-DFT_DISABLE_BZIP2=ON ';
23-
$extra_libs .= $this->builder->getLib('brotli') ? '-DFT_DISABLE_BROTLI=OFF ' : '-DFT_DISABLE_BROTLI=ON ';
21+
$extra = '';
22+
if (version_compare(get_cmake_version(), '4.0.0', '>=')) {
23+
$extra .= '-DCMAKE_POLICY_VERSION_MINIMUM=3.12 ';
24+
}
25+
$extra .= $this->builder->getLib('libpng') ? '-DFT_DISABLE_PNG=OFF ' : '-DFT_DISABLE_PNG=ON ';
26+
$extra .= $this->builder->getLib('bzip2') ? '-DFT_DISABLE_BZIP2=OFF ' : '-DFT_DISABLE_BZIP2=ON ';
27+
$extra .= $this->builder->getLib('brotli') ? '-DFT_DISABLE_BROTLI=OFF ' : '-DFT_DISABLE_BROTLI=ON ';
2428
FileSystem::resetDir($this->source_dir . '/build');
2529
shell()->cd($this->source_dir . '/build')
2630
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
2731
->execWithEnv(
2832
"cmake {$this->builder->makeCmakeArgs()} -DFT_DISABLE_HARFBUZZ=ON " .
2933
'-DBUILD_SHARED_LIBS=OFF ' .
30-
"{$extra_libs}.."
34+
"{$extra}.."
3135
)
3236
->execWithEnv('make clean')
3337
->execWithEnv("make -j{$this->builder->concurrency}")

src/SPC/doctor/item/LinuxToolCheckList.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,14 @@ public function checkCliTools(): ?CheckResult
8787
#[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')]
8888
public function checkCMakeVersion(): ?CheckResult
8989
{
90-
$check_cmd = 'cmake --version';
91-
$pattern = '/cmake version (.*)/m';
92-
$out = shell()->execWithResult($check_cmd, false)[1][0];
93-
if (preg_match($pattern, $out, $match)) {
94-
$ver = $match[1];
95-
if (version_compare($ver, '3.18.0') <= 0) {
96-
return CheckResult::fail('cmake version is too low (' . $ver . '), please update it manually!');
97-
}
98-
return CheckResult::ok($match[1]);
90+
$ver = get_cmake_version();
91+
if ($ver === null) {
92+
return CheckResult::fail('Failed to get cmake version');
93+
}
94+
if (version_compare($ver, '3.18.0') < 0) {
95+
return CheckResult::fail('cmake version is too low (' . $ver . '), please update it manually!');
9996
}
100-
return CheckResult::fail('Failed to get cmake version');
97+
return CheckResult::ok($ver);
10198
}
10299

103100
/** @noinspection PhpUnused */

src/globals/functions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,21 @@ function f_putenv(string $env): bool
192192
logger()->debug('Setting env: ' . $env);
193193
return putenv($env);
194194
}
195+
196+
/**
197+
* Get the installed CMake version
198+
*
199+
* @return null|string The CMake version or null if it couldn't be determined
200+
*/
201+
function get_cmake_version(): ?string
202+
{
203+
try {
204+
[,$output] = shell()->execWithResult('cmake --version', false);
205+
if (preg_match('/cmake version ([\d.]+)/i', $output[0], $matches)) {
206+
return $matches[1];
207+
}
208+
} catch (Exception $e) {
209+
logger()->warning('Failed to get CMake version: ' . $e->getMessage());
210+
}
211+
return null;
212+
}

src/globals/test-extensions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
// test php version (8.1 ~ 8.4 available, multiple for matrix)
1515
$test_php_version = [
16-
// '8.1',
17-
// '8.2',
18-
// '8.3',
16+
'8.1',
17+
'8.2',
18+
'8.3',
1919
'8.4',
2020
];
2121

2222
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
2323
$test_os = [
2424
// 'macos-13',
2525
// 'macos-14',
26-
'macos-15',
26+
// 'macos-15',
2727
'ubuntu-latest',
2828
// 'ubuntu-22.04',
2929
// 'ubuntu-24.04',

0 commit comments

Comments
 (0)