Why would cmake reject an available SDL2Config.cmake?

I’m trying to build my game with SDL2 on Windows, and a build that used to work has quit working. It is now rejecting the available SDL2Config.cmake with this message:

[{
“resource”: “/c:/Users/ken/Desktop/prog24/HallOfMirrors/CMakeLists.txt”,
“owner”: “cmake-configure-diags”,
“severity”: 8,
“message”: “CMake Error at CMakeLists.txt:19 (find_package):Could not find a configuration file for package "SDL2" that is compatible\nwith requested version "".\n\nThe following configuration files were considered but not accepted:\n\n C:/msys64/usr/lib/cmake/SDL2/SDL2Config.cmake, version: 2.30.9 (32bit)”,
“source”: “CMake (find_package)”,
“startLineNumber”: 19,
“startColumn”: 1,
“endLineNumber”: 19,
“endColumn”: 10000,
“origin”: “extHost1”
}]

Here is my CMakeLists.txt, and below it is the SDL2Config.cmake that I find on my system. I don’t see any versioning requirements in SDL2Config.cmake, so I’m wondering what could be there that would be considered unsuitable.

cmake_minimum_required(VERSION 3.28)
project(my-project)

set (HALL_OF_MIRRORS 
    HallOfMirrors.cpp
    MirrorCore.cpp
    MirrorThings.cpp
    Thief.cpp
    Laser.cpp 
    Ray.cpp
    LogMe.cpp
    SetupScreen.cpp
    Keyboards.cpp
    InputCode.cpp)

set(WORKBENCH Test.cpp InputCode.cpp)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(SDL2 REQUIRED COMPONENTS SDL2)  # recommended in Readme
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(SDL2_image REQUIRED)

set (SDL2_gfx_LIBRARIES C:/msys64/ucrt64/lib/libSDL2_gfx.dll.a)
link_directories(${SDL2_LIBRARY_DIRS} /opt/homebrew/lib/)

include_directories(/opt/homebrew/include . ../Drawbox/Library ../Drawbox/Tools 
                        ../Drawbox/APClass Library/jpeg)
message( STATUS SDL2_INCLUDE_DIRS=${SDL2_INCLUDE_DIRS} )
message( STATUS SDL2_LIBRARIES=${SDL2_LIBRARIES} )

include(../Drawbox/Library/CMakeLists.txt)
include(../Drawbox/Tools/CMakeLists.txt)
include(../Drawbox/APClass/CMakeLists.txt)

add_executable(HallOfMirrors ../Drawbox/DrawboxMain.cpp ${HALL_OF_MIRRORS} 
                    ${DRAWBOX} ${APCLASS} ${TOOLS}) 

target_compile_features(HallOfMirrors PUBLIC cxx_std_11)
target_compile_options(HallOfMirrors PRIVATE 
        -Wno-switch -Wno-deprecated-declarations -Wno-write-strings)

if (WIN32)  
    target_link_libraries(HallOfMirrors 
            ${SDL2_LIBRARIES} 
            SDL2_ttf::SDL2_ttf
            SDL2_image::SDL2_image
            ${SDL2_gfx_LIBRARIES}
            fmt) 
else()
    target_link_libraries(HallOfMirrors ${SDL2_LIBRARIES} SDL2_gfx SDL2_ttf
                    /opt/homebrew/lib/libSDL2_image.dylib
                    /opt/homebrew/lib/libSDL2_ttf.dylib
                    /opt/homebrew/lib/libSDL2_mixer.dylib
                    ) 
endif()

Here’s C:/msys64/usr/lib/cmake/SDL2/SDL2Config.cmake:

# sdl2 cmake project-config input for CMakeLists.txt script

include(FeatureSummary)
set_package_properties(SDL2 PROPERTIES
  URL "https://www.libsdl.org/"
  DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
)


####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was SDL2Config.cmake.in                            ########

get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

macro(set_and_check _var _file)
  set(${_var} "${_file}")
  if(NOT EXISTS "${_file}")
    message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
  endif()
endmacro()

macro(check_required_components _NAME)
  foreach(comp ${${_NAME}_FIND_COMPONENTS})
    if(NOT ${_NAME}_${comp}_FOUND)
      if(${_NAME}_FIND_REQUIRED_${comp})
        set(${_NAME}_FOUND FALSE)
      endif()
    endif()
  endforeach()
endmacro()

####################################################################################

set(SDL2_FOUND TRUE)

if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2Targets.cmake")
  include("${CMAKE_CURRENT_LIST_DIR}/SDL2Targets.cmake")
  set(SDL2_SDL2_FOUND TRUE)
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2staticTargets.cmake")
  if(ANDROID)
    enable_language(CXX)
  endif()
  include("${CMAKE_CURRENT_LIST_DIR}/SDL2staticTargets.cmake")
  set(SDL2_SDL2-static_FOUND TRUE)
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2mainTargets.cmake")
  include("${CMAKE_CURRENT_LIST_DIR}/SDL2mainTargets.cmake")
  set(SDL2_SDL2main_FOUND TRUE)
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2testTargets.cmake")
  include("${CMAKE_CURRENT_LIST_DIR}/SDL2testTargets.cmake")
  set(SDL2_SDL2test_FOUND TRUE)
endif()


include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake")

set(SDL_ALSA OFF)
set(SDL_ALSA_SHARED OFF)
if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static)
  sdlFindALSA()
endif()
unset(SDL_ALSA)
unset(SDL_ALSA_SHARED)


check_required_components(SDL2)

# Create SDL2::SDL2 alias for static-only builds
if(TARGET SDL2::SDL2-static AND NOT TARGET SDL2::SDL2)
  if(CMAKE_VERSION VERSION_LESS "3.18")
    # FIXME: Aliasing local targets is not supported on CMake < 3.18, so make it global.
    add_library(SDL2::SDL2 INTERFACE IMPORTED)
    set_target_properties(SDL2::SDL2 PROPERTIES INTERFACE_LINK_LIBRARIES "SDL2::SDL2-static")
  else()
    add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static)
  endif()
endif()

# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.

set(SDL2_PREFIX "${PACKAGE_PREFIX_DIR}")
set(SDL2_EXEC_PREFIX "${PACKAGE_PREFIX_DIR}")
set(SDL2_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include/SDL2")
set(SDL2_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include;${PACKAGE_PREFIX_DIR}/include/SDL2")
set(SDL2_BINDIR "${PACKAGE_PREFIX_DIR}/bin")
set(SDL2_LIBDIR "${PACKAGE_PREFIX_DIR}/lib")
set(SDL2_LIBRARIES SDL2::SDL2)
set(SDL2_STATIC_LIBRARIES SDL2::SDL2-static)
set(SDL2_STATIC_PRIVATE_LIBS)

set(SDL2MAIN_LIBRARY)
if(TARGET SDL2::SDL2main)
  set(SDL2MAIN_LIBRARY SDL2::SDL2main)
  list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
  list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
endif()

set(SDL2TEST_LIBRARY SDL2::SDL2test)

The version requirements should be stored in SDL2ConfigVersion.cmake, that should be located next to SDL2Config.cmake.

Could it be that your library is somehow x64 by default and SDL is only x86?

I find libSDL2dll.a, for example, in

C:\Users\ken\Desktop\SDL2\SDL2-2.30.9\x86_64-w64-mingw32\lib\libSDL2.dll.a
C:\msys64\ucrt64\lib\libSDL2.dll.a
C:\msys64\usr\lib\libSDL2.dll.a

It appears that they are all 64-bit items. Same deal with the various occurrences of SDL2.dll. However, from the last lines of SDL2ConfigVersion.cmake:

if(NOT CMAKE_SIZEOF_VOID_P STREQUAL “4”)
math(EXPR installedBits “4 * 8”)
set(PACKAGE_VERSION “${PACKAGE_VERSION} (${installedBits}bit)”)
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

CMAKE_SIZEOF_VOID_P is showing as 8, and by this logic (second line) installedBits is computed to be 32. Huh??