Commit 7ca3b27064de7f9fe88dc53e7a3db6123804fdba

Ryan C. Gordon 2015-12-29T00:02:43

CMake: Fixed to work on Windows 8 SDK (thanks, Martin!). Fixes Bugzilla #3207.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c75ad6..b101119 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -900,7 +900,10 @@ elseif(WINDOWS)
 
   # Check for DirectX
   if(DIRECTX)
-    if(NOT CMAKE_COMPILER_IS_MINGW)
+    if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
+        set(USE_WINSDK_DIRECTX TRUE)
+    endif()
+    if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
       if("$ENV{DXSDK_DIR}" STREQUAL "")
         message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
       endif()
@@ -926,7 +929,7 @@ elseif(WINDOWS)
     check_include_file(dxgi.h HAVE_DXGI_H)
     if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
       set(HAVE_DIRECTX TRUE)
-      if(NOT CMAKE_COMPILER_IS_MINGW)
+      if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
       # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
         link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
         include_directories($ENV{DXSDK_DIR}\\Include)
@@ -1044,7 +1047,7 @@ elseif(WINDOWS)
       list(APPEND EXTRA_LIBS dinput8 dxguid)
       if(CMAKE_COMPILER_IS_MINGW)
         list(APPEND EXTRA_LIBS dxerr8)
-      else()
+      elseif (NOT USE_WINSDK_DIRECTX)
         list(APPEND EXTRA_LIBS dxerr)
       endif()
     endif()