1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Mac + RustでSDL2クレートのビルド時にエラーが発生する問題

Last updated at Posted at 2025-08-20

使用したSDL2クレート

rustcのバージョン

% rustc --version
rustc 1.89.0 (29483883e 2025-08-04)

Cargo.toml

dependenciesの書き方は、ここを参考にしました。
https://www.reddit.com/r/rust/comments/1d87vo3/cant_use_sdl2_with_rust_macos/?tl=ja

[package]
name = "train-sdl2"
version = "0.1.0"
edition = "2024"

[features]
default = []

[target.'cfg(target_os="macos")'.dependencies.sdl2]
features = ["bundled"]
version = "0.38.0"

[dependencies]

問題時のエラーログ

% cargo build
   Compiling sdl2-sys v0.38.0
error: failed to run custom build command for `sdl2-sys v0.38.0`

Caused by:
  process didn't exit successfully: `/Users/user/train-sdl2/target/debug/build/sdl2-sys-6009dbd30eb3d728/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_aarch64-apple-darwin = None
  CMAKE_TOOLCHAIN_FILE_aarch64_apple_darwin = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_aarch64-apple-darwin = None
  CMAKE_GENERATOR_aarch64_apple_darwin = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_aarch64-apple-darwin = None
  CMAKE_PREFIX_PATH_aarch64_apple_darwin = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_aarch64-apple-darwin = None
  CMAKE_aarch64_apple_darwin = None
  HOST_CMAKE = None
  CMAKE = None
  running: cd "/Users/user/train-sdl2/target/debug/build/sdl2-sys-c97cc07ec1adce12/out/build" && CMAKE_PREFIX_PATH="" LC_ALL="C" "cmake" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sdl2-sys-0.38.0/SDL" "-DCMAKE_OSX_ARCHITECTURES=arm64" "-DCMAKE_CONFIGURATION_TYPES=Release" "-DSDL_SHARED=ON" "-DSDL_STATIC=OFF" "-DCMAKE_INSTALL_PREFIX=/Users/user/train-sdl2/target/debug/build/sdl2-sys-c97cc07ec1adce12/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=15.5" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=15.5" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx -mmacosx-version-min=15.5" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- Configuring incomplete, errors occurred!

  --- stderr
  CMake Error at CMakeLists.txt:5 (cmake_minimum_required):
    Compatibility with CMake < 3.5 has been removed from CMake.

    Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
    to tell CMake that the project requires at least <min> but has been updated
    to work with policies introduced by <max> or earlier.

    Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.



  thread 'main' panicked at /Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cmake-0.1.54/src/lib.rs:1119:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

解決方法

.cargo/config.tomlファイルを作成し、

[env]
CMAKE_POLICY_VERSION_MINIMUM = "3.5"

を追記する。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?