From f0f74231354e24fb77ea6f40c02561af719678aa Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 25 Oct 2024 16:07:20 -0700 Subject: [PATCH] Update CMake to use gameinput package (#498) --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee544b55..65c58513 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,10 +292,15 @@ include(CheckIncludeFileCXX) if(BUILD_GAMEINPUT) message(STATUS "Using GameInput for GamePad/Keyboard/Mouse.") - set(CMAKE_REQUIRED_QUIET ON) - CHECK_INCLUDE_FILE_CXX(GameInput.h GAMEINPUT_HEADER) - if(NOT GAMEINPUT_HEADER) - message(FATAL_ERROR "Microsoft GDK required to build GameInput. See https://aka.ms/gdk") + find_package(gameinput CONFIG QUIET) + if(gameinput_FOUND) + target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::GameInput) + else() + set(CMAKE_REQUIRED_QUIET ON) + CHECK_INCLUDE_FILE_CXX(GameInput.h GAMEINPUT_HEADER) + if(NOT GAMEINPUT_HEADER) + message(FATAL_ERROR "Microsoft GDK required to build GameInput. See https://aka.ms/gdk") + endif() endif() target_compile_definitions(${PROJECT_NAME} PUBLIC USING_GAMEINPUT) elseif(BUILD_WGI)