From 635d93d0b68db9fac72580a1289a93641b8c5c18 Mon Sep 17 00:00:00 2001 From: Richard Ward Date: Thu, 18 Dec 2025 21:33:19 +0000 Subject: [PATCH] use conan for everything --- .github/workflows/release.yml | 3 - CMakeLists.txt | 6 -- README.md | 19 ++---- conanfile.py | 1 + scripts/setup_vendor_dependencies.py | 88 ---------------------------- 5 files changed, 5 insertions(+), 112 deletions(-) delete mode 100644 scripts/setup_vendor_dependencies.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf26074..55834d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,9 +63,6 @@ jobs: - name: Detect Conan profile run: conan profile detect - - name: Vendor SDL3/Vulkan - run: python scripts/setup_vendor_dependencies.py - - name: Install Conan dependencies shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 459d410..f7efb33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,6 @@ cmake_minimum_required(VERSION 3.24) project(SDL3App LANGUAGES CXX) option(BUILD_SDL3_APP "Build the SDL3 Vulkan demo" ON) -set(VENDOR_INSTALL_DIR "${CMAKE_SOURCE_DIR}/vendor/install") -if(EXISTS "${VENDOR_INSTALL_DIR}") - list(APPEND CMAKE_PREFIX_PATH "${VENDOR_INSTALL_DIR}") - message(STATUS "Using vendored dependencies from ${VENDOR_INSTALL_DIR}") -endif() - set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/README.md b/README.md index 13b074d..9dbfaea 100644 --- a/README.md +++ b/README.md @@ -3,31 +3,20 @@ A minimal SDL3 + Vulkan spinning cube demo. ## Build -1. Install SDL3 development headers for your platform (e.g., `libsdl3-dev` on Debian/Ubuntu or the SDK from [libsdl.org](https://www.libsdl.org/download-3.html)). -2. Install or update [Conan 2.x](https://docs.conan.io/en/latest/installation.html) and run +1. Install or update [Conan 2.x](https://docs.conan.io/en/latest/installation.html) and run ``` conan install . --install-folder build --build=missing ``` - so that Conan brings in `lua` and the Vulkan loader + headers. -3. Configure the project with CMake using the generated Conan toolchain: + so that Conan brings in `lua`, SDL3, and the Vulkan loader + headers. +2. Configure the project with CMake using the generated Conan toolchain: ``` cmake -B build -S . ``` -4. Build the demo: +3. Build the demo: ``` cmake --build build ``` -### Vendor SDL3/Vulkan from source - -If you cannot install the SDL3/Vulkan headers via the distro packages, run the helper to download and build them into `vendor/install`: - -``` -python3 scripts/setup_vendor_dependencies.py -cmake -S . -B build -DBUILD_SDL3_APP=ON -DCMAKE_BUILD_TYPE=Release -cmake --build build -``` - Shaders are copied into `build/shaders` during configuration, so the demo can load the precompiled `cube.{vert,frag}.spv`. ## Run diff --git a/conanfile.py b/conanfile.py index 0c47d7a..c4505f4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -16,5 +16,6 @@ class SDL3CppConan(ConanFile): def requirements(self): self.requires("lua/5.4.6") + self.requires("sdl3/3.2.0") if self.options.build_app: self.requires("vulkan-loader/1.4.313.0") diff --git a/scripts/setup_vendor_dependencies.py b/scripts/setup_vendor_dependencies.py deleted file mode 100644 index cc8a0ed..0000000 --- a/scripts/setup_vendor_dependencies.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python3 -import subprocess -import sys -from pathlib import Path - -ROOT = Path(__file__).resolve().parent.parent -VENDOR_DIR = ROOT / "vendor" -INSTALL_DIR = VENDOR_DIR / "install" - - -def run(command, cwd=None): - print(f"[vendor-deps] running: {' '.join(command)} (cwd={cwd or ROOT})") - subprocess.run(command, cwd=cwd or ROOT, check=True) - - -def fetch_repo(name, url, ref): - target = VENDOR_DIR / name - if (target / ".git").exists(): - print(f"[vendor-deps] updating {name}") - run(["git", "-C", str(target), "fetch", "--tags", "origin"]) - run(["git", "-C", str(target), "checkout", ref]) - run(["git", "-C", str(target), "reset", "--hard", f"origin/{ref}"]) - else: - print(f"[vendor-deps] cloning {name}") - run(["git", "clone", "--depth", "1", "--branch", ref, url, str(target)]) - - -def build_and_install(source_dir, build_dir, cmake_options=None): - cmake_options = cmake_options or [] - build_dir.mkdir(parents=True, exist_ok=True) - run( - [ - "cmake", - "-S", - str(source_dir), - "-B", - str(build_dir), - "-DCMAKE_BUILD_TYPE=Release", - f"-DCMAKE_INSTALL_PREFIX={INSTALL_DIR}", - *cmake_options, - ] - ) - run( - [ - "cmake", - "--build", - str(build_dir), - "--config", - "Release", - "--", - f"-j{max(1, (subprocess.os.cpu_count() or 1))}", - ] - ) - run(["cmake", "--install", str(build_dir), "--config", "Release"]) - - -def main(): - VENDOR_DIR.mkdir(exist_ok=True) - INSTALL_DIR.mkdir(exist_ok=True) - - fetch_repo("SDL", "https://github.com/libsdl-org/SDL.git", "release-3.2.x") - build_and_install( - VENDOR_DIR / "SDL", - VENDOR_DIR / "build-sdl", - ["-DSDL_SHARED=OFF", "-DSDL_STATIC=ON", "-DSDL_TEST=OFF", "-DBUILD_SHARED_LIBS=OFF"], - ) - - fetch_repo("Vulkan-Loader", "https://github.com/KhronosGroup/Vulkan-Loader.git", "sdk-1.3.261.1") - fetch_repo("Vulkan-Headers", "https://github.com/KhronosGroup/Vulkan-Headers.git", "sdk-1.3.261.1") - build_and_install( - VENDOR_DIR / "Vulkan-Headers", - VENDOR_DIR / "build-vulkan-headers", - ) - - build_and_install( - VENDOR_DIR / "Vulkan-Loader", - VENDOR_DIR / "build-vulkan-loader", - ["-DBUILD_WSI=OFF", "-DBUILD_SAMPLES=OFF"], - ) - - print(f"[vendor-deps] vendor dependencies built into {INSTALL_DIR}") - - -if __name__ == "__main__": - try: - main() - except subprocess.CalledProcessError as exc: - sys.exit(exc.returncode)