From 8c4dfe735aad31fd280f4a4f9c2d19246267bb7e Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 25 Oct 2024 16:07:10 -0700 Subject: [PATCH] Update CMake to use gameinput package if needed (#275) --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2103a940..771619c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,10 +339,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)