# Find DIRECTINPUT # # This module defines # DIRECTINPUT_FOUND # DIRECTINPUT_INCLUDE_DIRS # DIRECTINPUT_LIBRARIES # # Copyright (c) 2012 I-maginer # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA, or go to # http://www.gnu.org/copyleft/lesser.txt # if(WIN32) # The only platform it makes sense to check for DIRECTINPUT SDK include(FindPkgMacros) findpkg_begin(DIRECTINPUT) if( MSVC AND NOT MSVC90 ) # Windows 10.x SDK get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH) file(GLOB W10SDK_VERSIONS RELATIVE ${kit10_dir}/Include ${kit10_dir}/Include/10.*) # enumerate pre-release and not yet known release versions list(APPEND W10SDK_VERSIONS "10.0.10240.0" "10.0.14393.0" "10.0.15063.0" "10.0.16299.0") # enumerate well known release versions list(REMOVE_DUPLICATES W10SDK_VERSIONS) list(SORT W10SDK_VERSIONS) list(REVERSE W10SDK_VERSIONS) # sort from high to low if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) list(INSERT W10SDK_VERSIONS 0 ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) # prefer version passed by CMake, if any endif() foreach(W10SDK_VER ${W10SDK_VERSIONS}) find_path(DIRECTINPUT_INCLUDE_DIR NAMES dinput.h HINTS "${kit10_dir}/Include/${W10SDK_VER}/um" "C:/Program Files (x86)/Windows Kits/10/Include/${W10SDK_VER}/um" "C:/Program Files/Windows Kits/10/Include/${W10SDK_VER}/um") endforeach() # Windows 8.1 SDK if(NOT DIRECTINPUT_INCLUDE_DIR) find_path(DIRECTINPUT_INCLUDE_DIR NAMES dinput.h HINTS "C:/Program Files (x86)/Windows Kits/8.1/include/um" "C:/Program Files/Windows Kits/8.1/include/um") endif() # Windows 8.0 SDK if(NOT DIRECTINPUT_INCLUDE_DIR) find_path(DIRECTINPUT_INCLUDE_DIR NAMES dinput.h HINTS "C:/Program Files (x86)/Windows Kits/8.0/include/um" "C:/Program Files/Windows Kits/8.0/include/um") endif() endif() if(DIRECTINPUT_INCLUDE_DIR) # No need to specify full path to libraries, proper version would be found as part of SDK, in one of the following places # "C:/Program Files (x86)/Windows Kits/10/lib/${W10SDK_VER}/um/${MSVC_CXX_ARCHITECTURE_ID}/" # "C:/Program Files (x86)/Windows Kits/8.1/lib/winv6.3/um/${MSVC_CXX_ARCHITECTURE_ID}/" # "C:/Program Files (x86)/Windows Kits/8.0/lib/win8/um/${MSVC_CXX_ARCHITECTURE_ID}/" # "C:/Program Files (x86)/Windows Phone Kits/8.1/lib/${MSVC_CXX_ARCHITECTURE_ID}/" # "C:/Program Files (x86)/Windows Phone Kits/8.0/lib/${MSVC_CXX_ARCHITECTURE_ID}/" set(DIRECTINPUT_LIBRARY dinput8.lib dxgi.lib dxguid.lib) # but it is usefull to output selected version to the log message(STATUS "Found DIRECTINPUT headers: ${DIRECTINPUT_INCLUDE_DIR}") endif() if( NOT DIRECTINPUT_INCLUDE_DIR OR NOT DIRECTINPUT_LIBRARY ) set(DIRECTINPUT_LEGACY TRUE) # Get path, convert backslashes as ${ENV_DXSDK_DIR} getenv_path(DXSDK_DIR) getenv_path(DIRECTX_HOME) getenv_path(DIRECTX_ROOT) getenv_path(DIRECTX_BASE) # construct search paths set(DIRECTINPUT_PREFIX_PATH "${DXSDK_DIR}" "${ENV_DXSDK_DIR}" "${DIRECTX_HOME}" "${ENV_DIRECTX_HOME}" "${DIRECTX_ROOT}" "${ENV_DIRECTX_ROOT}" "${DIRECTX_BASE}" "${ENV_DIRECTX_BASE}" "C:/apps_x86/Microsoft DirectX SDK*" "C:/Program Files (x86)/Microsoft DirectX SDK*" "C:/apps/Microsoft DirectX SDK*" "C:/Program Files/Microsoft DirectX SDK*" "$ENV{ProgramFiles}/Microsoft DirectX SDK*" ) # dlls are in DIRECTINPUT_ROOT_DIR/Developer Runtime/x64|x86 # lib files are in DIRECTINPUT_ROOT_DIR/Lib/x64|x86 if(CMAKE_CL_64) set(DIRECTINPUT_LIBPATH_SUFFIX "x64") else(CMAKE_CL_64) set(DIRECTINPUT_LIBPATH_SUFFIX "x86") endif(CMAKE_CL_64) create_search_paths(DIRECTINPUT) # redo search if prefix path changed clear_if_changed(DIRECTINPUT_INC_SEARCH_PATH DIRECTINPUT_LIBRARY DIRECTINPUT_INCLUDE_DIR ) # look for Dinput components find_path(DIRECTINPUT_INCLUDE_DIR NAMES dinput.h HINTS ${DIRECTINPUT_INC_SEARCH_PATH} PATH_SUFFIXES ${DIRECTINPUT_INCPATH_SUFFIX}) find_library(DIRECTINPUT_DXGUID_LIBRARY NAMES dxguid HINTS ${DIRECTINPUT_LIB_SEARCH_PATH} PATH_SUFFIXES ${DIRECTINPUT_LIBPATH_SUFFIX}) find_library(DIRECTINPUT_DXGI_LIBRARY NAMES dxgi HINTS ${DIRECTINPUT_LIB_SEARCH_PATH} PATH_SUFFIXES ${DIRECTINPUT_LIBPATH_SUFFIX}) find_library(DIRECTINPUT_LIBRARY NAMES dinput8 HINTS ${DIRECTINPUT_LIB_SEARCH_PATH} PATH_SUFFIXES ${DIRECTINPUT_LIBPATH_SUFFIX}) find_library(DIRECTINPUT_DXERR_LIBRARY NAMES DxErr HINTS ${DIRECTINPUT_LIB_SEARCH_PATH} PATH_SUFFIXES ${DIRECTINPUT_LIBPATH_SUFFIX}) if (DIRECTINPUT_INCLUDE_DIR AND DIRECTINPUT_LIBRARY) set(DIRECTINPUT_LIBRARIES ${DIRECTINPUT_LIBRARIES} ${DIRECTINPUT_LIBRARY} ${DIRECTINPUT_DXGI_LIBRARY} ${DIRECTINPUT_DXGUID_LIBRARY}) endif () if (DIRECTINPUT_DXERR_LIBRARY) set(DIRECTINPUT_LIBRARIES ${DIRECTINPUT_LIBRARIES} ${DIRECTINPUT_DXERR_LIBRARY}) endif () set(DIRECTINPUT_LIBRARY ${DIRECTINPUT_LIBRARIES} ) mark_as_advanced(DIRECTINPUT_LIBRARY DIRECTINPUT_DXERR_LIBRARY DIRECTINPUT_DXGUID_LIBRARY) endif () # Legacy Direct X SDK findpkg_finish(DIRECTINPUT) endif(WIN32)