use conan for everything

This commit is contained in:
Richard Ward
2025-12-18 21:33:19 +00:00
parent 49843d6664
commit 635d93d0b6
5 changed files with 5 additions and 112 deletions

View File

@@ -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: |

View File

@@ -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)

View File

@@ -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

View File

@@ -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")

View File

@@ -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)