Skip to content

Commit

Permalink
Merge pull request wgois#53 from rpaciorek/master
Browse files Browse the repository at this point in the history
fixes for mingw cross-compile
  • Loading branch information
Ybalrid authored Aug 4, 2019
2 parents dbc9c7d + 34c46fc commit dfe2cfd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
53 changes: 36 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,50 @@ if (UNIX AND NOT APPLE)
endif()

if (WIN32)
option(OIS_WIN32_XINPUT_SUPPORT "Add support XInput." ON)

find_package(WindowsSDK)
# I'm assuming that this will be set under all normal circumstances
# if not, the user can set it themselves
if(WINDOWSSDK_FOUND)
set(OIS_WIN32_DXSDK_DIR ${WINDOWSSDK_PREFERRED_DIR} CACHE PATH "Location of the DirectX SDK on your system.")
option(OIS_WIN32_XINPUT_SUPPORT "Add support XInput." ON)

if(CMAKE_CROSSCOMPILING)
MESSAGE(STATUS "Cross-compiling ... search libraries instead of WindowsSDK")
find_library(DINPUT8_LIBRARY NAMES libdinput8.a dinput8.lib)
find_library(XINPUT8_LIBRARY NAMES libxinput.a)
find_library(DXGUID_LIBRARY NAMES libdxguid.a)
if (NOT DINPUT8_LIBRARY)
MESSAGE(FATAL_ERROR " could not locate dinput8 DirectX library")
endif()
if (NOT XINPUT8_LIBRARY)
MESSAGE(FATAL_ERROR " could not locate xinput DirectX library")
endif()
if (NOT DXGUID_LIBRARY)
MESSAGE(FATAL_ERROR " could not locate dxguid DirectX library")
endif()
MESSAGE(STATUS " using " ${DINPUT8_LIBRARY} ", " ${XINPUT8_LIBRARY} " and " ${DXGUID_LIBRARY})
else()
set(OIS_WIN32_DXSDK_DIR "$ENV{DXSDK_DIR}" CACHE PATH "Location of the DirectX SDK on your system.")
endif()

if("${OIS_WIN32_DXSDK_DIR}" STREQUAL "")
MESSAGE(FATAL_ERROR "Could not locate DirectX SDK on this system")
else()
MESSAGE(STATUS "Found DirectX SDK at ${OIS_WIN32_DXSDK_DIR}")
find_package(WindowsSDK)
# I'm assuming that this will be set under all normal circumstances
# if not, the user can set it themselves
if(WINDOWSSDK_FOUND)
set(OIS_WIN32_DXSDK_DIR ${WINDOWSSDK_PREFERRED_DIR} CACHE PATH "Location of the DirectX SDK on your system.")
else()
set(OIS_WIN32_DXSDK_DIR "$ENV{DXSDK_DIR}" CACHE PATH "Location of the DirectX SDK on your system.")
endif()

if("${OIS_WIN32_DXSDK_DIR}" STREQUAL "")
MESSAGE(FATAL_ERROR "Could not locate DirectX SDK on this system")
else()
MESSAGE(STATUS "Found DirectX SDK at ${OIS_WIN32_DXSDK_DIR}")
endif()

include_directories("${OIS_WIN32_DXSDK_DIR}/Include")
endif()

if(BUILD_SHARED_LIBS)
add_definitions(-DOIS_DYNAMIC_LIB)
endif()

if(OIS_WIN32_XINPUT_SUPPORT)
add_definitions(-DOIS_WIN32_XINPUT_SUPPORT)
endif()

include_directories("${OIS_WIN32_DXSDK_DIR}/Include")

set(ois_source
${ois_source}
"${CMAKE_CURRENT_SOURCE_DIR}/src/win32/Win32ForceFeedback.cpp"
Expand Down Expand Up @@ -161,6 +178,8 @@ if (WIN32)

if (WINDOWSSDK_FOUND)
target_link_libraries(OIS "dinput8.lib" "dxguid.lib")
elseif(CMAKE_CROSSCOMPILING)
target_link_libraries(OIS "${DINPUT8_LIBRARY}" "${XINPUT8_LIBRARY}" "${DXGUID_LIBRARY}")
else()
target_link_libraries(OIS "${DXSDK_DIR}/Lib/${DIRECTX_ARCH}/dinput8.lib" "${DXSDK_DIR}/Lib/${DIRECTX_ARCH}/dxguid.lib")
endif()
Expand Down
2 changes: 1 addition & 1 deletion includes/win32/Win32Prereqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ following restrictions:
#include <dinput.h>

#ifdef OIS_WIN32_XINPUT_SUPPORT
#include <XInput.h>
#include <xinput.h>
#endif

//Max number of elements to collect from buffered DirectInput
Expand Down

0 comments on commit dfe2cfd

Please sign in to comment.