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)