Migrated from Make to CMake.

This commit is contained in:
Johannes Findeisen 2026-11-06 19:05:14 +01:00
commit b6ba093000
52 changed files with 1276 additions and 1210 deletions

View file

@ -6,7 +6,7 @@ import subprocess
import sys
if not shutil.which("clang"):
sys.exit("clang is required for make analyze")
sys.exit("clang is required for the CMake analyze target")
jack = subprocess.run(["pkg-config", "--cflags", "jack"], capture_output=True, text=True) if shutil.which("pkg-config") else None
for source in sys.argv[1:]:
flags = []

View file

@ -9,7 +9,6 @@ import os
from pathlib import Path
import platform
import re
import shlex
import subprocess
import tarfile
import tempfile
@ -29,9 +28,23 @@ def main():
a.output.parent.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(prefix='xtc-binary-stage-') as temporary:
stage = Path(temporary)
env = dict(os.environ, MAKEFLAGS='', MFLAGS='')
subprocess.run(shlex.split(env.get('MAKE', 'make')) + ['install-gui' if a.gui else 'install',
f'BUILD_DIR={a.build_dir.resolve()}', f'DESTDIR={stage}', 'PREFIX=/usr'], env=env, check=True)
env = dict(os.environ)
driver = stage / 'cmake-driver'
cache = (a.build_dir / 'CMakeCache.txt').read_text()
generator = next(line.partition('=')[2] for line in cache.splitlines()
if line.startswith('CMAKE_GENERATOR:INTERNAL='))
jack = 'OFF' if 'XTC_WITH_JACK:BOOL=OFF' in cache else 'ON'
subprocess.run(['cmake', '-G', generator, '-S', str(Path.cwd()), '-B', str(driver),
'-DBUILD_TESTING=OFF', '-DCMAKE_INSTALL_PREFIX=/usr', '-DCMAKE_INSTALL_LIBDIR=lib',
f'-DXTC_BUILD_GUI={"ON" if a.gui else "OFF"}',
'-DXTC_INSTALL_PKGCONFIGDIR=lib/pkgconfig',
f'-DXTC_INSTALL_BUILD_DIR={a.build_dir.resolve()}',
f'-DXTC_WITH_JACK={jack}', f'-DXTC_INSTALL_GUI={"ON" if a.gui else "OFF"}'],
env=env, check=True)
subprocess.run(['cmake', '--install', str(driver)], env=dict(env, DESTDIR=str(stage)), check=True)
# Only the installed /usr tree belongs to the archive.
import shutil
shutil.rmtree(driver)
pc = stage / 'usr/lib/pkgconfig/xtc.pc'
pc.write_text(pc.read_text().replace('prefix=/usr\n', 'prefix=${pcfiledir}/../..\n'))
entries = []