メインコンテンツへスキップ

CMake の FetchContent で SDL image を使用しようとして詰った箇所

    Windows 11 と CLion の組み合せで SDL image を使用しようとして、ビルドに失敗したけど、Claude Code に聞いたら一発で解決した問題を念のためメモしておく。

    FetchContent_Declare(
            sdl_image
            GIT_REPOSITORY https://github.com/libsdl-org/SDL_image
            GIT_TAG release-2.8.12
            GIT_PROGRESS TRUE
    )

    上記のように CMakeLists.txt で SDL image を FetchContent で取得して使用しようとしたら、以下のようなエラーが出てビルドに失敗してしまった。

      -- The ASM compiler identification is MSVC
      CMake Warning (dev) at C:/Program Files/JetBrains/CLion 2026.1/bin/cmake/win/x64/share/cmake-4.2/Modules/CMakeDetermineASMCompiler.cmake:234 (message):
        Policy CMP194 is not set: MSVC is not an assembler for language ASM.  Run
        "cmake --help-policy CMP194" for policy details.  Use the cmake_policy
        command to set the policy and suppress this warning.
      Call Stack (most recent call first):
        cmake-build-debug/_deps/sdl_image-src/external/dav1d/CMakeLists.txt:96 (enable_language)
      This warning is for project developers.  Use -Wno-dev to suppress it.
    
      -- Found assembler: C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.50.35717/bin/Hostx64/x64/cl.exe
      -- The ASM_NASM compiler identification is u
      -- Didn't find assembler
      CMake Error at cmake-build-debug/_deps/sdl_iLists.txt:97 (enable_language):
        No CMAKE_ASM_NASM_COMPILER could be found.
    
        Tell CMake where to find the compiler by setting either the environment
        variable "ASM_NASM" or the CMake cache ent the
        full path to the compiler, or to the compiler name if it is in the PATH.
    
    
      -- Configuring incomplete, errors occurred!

    Claude Code にエラーメッセージを貼ったところ、NASM が必要だが存在しないためエラーになってになっている。と教えてくれて必要な CMake の設定も以下のように追加してくれた。

    # AVIF は vendored dav1d のビルドに NASM を要求するので無効化する。
    # 本書で使う PNG / JPEG は stb_image バックエンドで読める。
    set(SDL2IMAGE_AVIF OFF CACHE BOOL "" FORCE)

    最近はこの手の設定時のエラーが出た場合は Claude Code などに投げて楽になって便利になった感じがする。その分 Claude Code が解決出きないエラーなどがあったら苦労はしそうだけど。

     
     
    フリーランスプログラマ。 スマートフォンゲーム運営・開発やWeb3ゲーム開発に携わってきました。 現在はAIを活用したブラウザツールやアプリを開発・公開中。 Unity / C# / Swift / C++ 案件・お仕事のご相談歓迎です。

    あなたへのおすすめ