Browse Source

Install d3dcompiler_xx.dll to the runtime bin directory on MSVC build.
Close #738.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
58332565ea

+ 2 - 4
CMake/Modules/FindBCM_VC.cmake

@@ -55,10 +55,8 @@ endif ()
 if (BCM_VC_FOUND)
 if (BCM_VC_FOUND)
     include (FindPackageMessage)
     include (FindPackageMessage)
     FIND_PACKAGE_MESSAGE (BCM_VC "Found Broadcom VideoCore firmware: ${BCM_VC_LIBRARIES} ${BCM_VC_INCLUDE_DIRS}" "[${BCM_VC_LIBRARIES}][${BCM_VC_INCLUDE_DIRS}]")
     FIND_PACKAGE_MESSAGE (BCM_VC "Found Broadcom VideoCore firmware: ${BCM_VC_LIBRARIES} ${BCM_VC_INCLUDE_DIRS}" "[${BCM_VC_LIBRARIES}][${BCM_VC_INCLUDE_DIRS}]")
-else ()
-    if (BCM_VC_FIND_REQUIRED)
-        message (FATAL_ERROR "Could not find Broadcom VideoCore firmware")
-    endif ()
+elseif (BCM_VC_FIND_REQUIRED)
+    message (FATAL_ERROR "Could not find Broadcom VideoCore firmware")
 endif ()
 endif ()
 
 
 mark_as_advanced (BCM_VC_INCLUDE_DIRS BCM_VC_LIBRARIES BCM_VC_LIB_BCM_HOST BCM_VC_LIB_EGL BCM_VC_LIB_GLES2)
 mark_as_advanced (BCM_VC_INCLUDE_DIRS BCM_VC_LIBRARIES BCM_VC_LIB_BCM_HOST BCM_VC_LIB_EGL BCM_VC_LIB_GLES2)

+ 63 - 56
CMake/Modules/FindDirect3D.cmake

@@ -27,77 +27,84 @@
 #  DIRECT3D_FOUND
 #  DIRECT3D_FOUND
 #  DIRECT3D_INCLUDE_DIRS
 #  DIRECT3D_INCLUDE_DIRS
 #  DIRECT3D_LIBRARIES
 #  DIRECT3D_LIBRARIES
+#  DIRECT3D_DLL
 #
 #
 
 
 if (NOT WIN32 OR DIRECT3D_FOUND)
 if (NOT WIN32 OR DIRECT3D_FOUND)
     return ()
     return ()
 endif ()
 endif ()
 
 
-# When using Direct3D11, do not search for the SDK from Visual Studio 2012 onward
-# to avoid incompatibility between DirectX SDK and Windows SDK defines and the 
-# resulting warning spam
-if (MSVC AND (MSVC_VERSION LESS 1700 OR NOT URHO3D_D3D11))
-    set (DIRECTX_INC_SEARCH_PATH
-        "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include"
-        "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include"
-        "$ENV{DIRECTX_ROOT}/Include"
-        "$ENV{DXSDK_DIR}/Include")
-    find_path (DIRECT3D_INCLUDE_DIRS NAMES d3dcompiler.h PATHS ${DIRECTX_INC_SEARCH_PATH})
-
+if (MSVC)
+    # Prefer to use MS Windows SDK, so search for it first
     if (CMAKE_CL_64)
     if (CMAKE_CL_64)
-        set (DIRECTX_LIB_SEARCH_PATH
-            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64"
-            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x64"
-            "$ENV{DIRECTX_ROOT}/Lib/x64"
-            "$ENV{DXSDK_DIR}/Lib/x64")
+        set (PATH_SUFFIX x64)
     else ()
     else ()
-        set (DIRECTX_LIB_SEARCH_PATH
-            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib"
-            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x86"
-            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib"
-            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x86"
-            "$ENV{DIRECTX_ROOT}/Lib"
-            "$ENV{DIRECTX_ROOT}/Lib/x86"
-            "$ENV{DXSDK_DIR}/Lib"
-            "$ENV{DXSDK_DIR}/Lib/x86")
+        set (PATH_SUFFIX x86)
     endif ()
     endif ()
-    if (NOT URHO3D_D3D11)
-        find_library (DIRECT3D_LIB_D3D9 NAMES d3d9 PATHS ${DIRECTX_LIB_SEARCH_PATH})
-        find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH})
-        if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D9 AND DIRECT3D_LIB_D3DCOMPILER)
-            set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D9} ${DIRECT3D_LIB_D3DCOMPILER})
-            set (DIRECT3D_FOUND 1)
+    # Only need to search the DLL as a proxy for the presence of the MS Windows SDK
+    find_file (DIRECT3D_DLL d3dcompiler_47.dll d3dcompiler_46.dll PATHS
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}")
+    if (DIRECT3D_DLL)
+        if (NOT URHO3D_D3D11)
+            set (DIRECT3D_LIBRARIES d3d9 d3dcompiler)
+        else ()
+            set (DIRECT3D_LIBRARIES d3d11 d3dcompiler dxgi dxguid)
         endif ()
         endif ()
-    else ()
-        find_library (DIRECT3D_LIB_D3D11 NAMES d3d11 PATHS ${DIRECTX_LIB_SEARCH_PATH})
-        find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH})
-        find_library (DIRECT3D_LIB_DXGI NAMES dxgi PATHS ${DIRECTX_LIB_SEARCH_PATH})
-        find_library (DIRECT3D_LIB_DXGUID NAMES dxguid PATHS ${DIRECTX_LIB_SEARCH_PATH})
-        if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D11 AND DIRECT3D_LIB_D3DCOMPILER AND DIRECT3D_LIB_DXGI AND DIRECT3D_LIB_DXGUID)
-            set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D11} ${DIRECT3D_LIB_D3DCOMPILER} ${DIRECT3D_LIB_DXGI} ${DIRECT3D_LIB_DXGUID})
-            set (DIRECT3D_FOUND 1)
+        unset (DIRECT3D_INCLUDE_DIRS)
+        set (DIRECT3D_FOUND 1)
+    elseif (MSVC_VERSION LESS 1700 OR NOT URHO3D_D3D11)
+        # To avoid incompatibility between DirectX SDK and Windows SDK defines and the resulting warning spam,
+        # only search for the DirectX SDK when using Visual Studion lower than VS2012 or when using D3D9
+        set (DIRECTX_INC_SEARCH_PATH
+            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include"
+            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include"
+            "$ENV{DIRECTX_ROOT}/Include"
+            "$ENV{DXSDK_DIR}/Include")
+        find_path (DIRECT3D_INCLUDE_DIRS NAMES d3dcompiler.h PATHS ${DIRECTX_INC_SEARCH_PATH})
+
+        if (CMAKE_CL_64)
+            set (DIRECTX_LIB_SEARCH_PATH
+                "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64"
+                "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x64"
+                "$ENV{DIRECTX_ROOT}/Lib/x64"
+                "$ENV{DXSDK_DIR}/Lib/x64")
+        else ()
+            set (DIRECTX_LIB_SEARCH_PATH
+                "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib"
+                "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x86"
+                "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib"
+                "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x86"
+                "$ENV{DIRECTX_ROOT}/Lib"
+                "$ENV{DIRECTX_ROOT}/Lib/x86"
+                "$ENV{DXSDK_DIR}/Lib"
+                "$ENV{DXSDK_DIR}/Lib/x86")
+        endif ()
+        if (NOT URHO3D_D3D11)
+            find_library (DIRECT3D_LIB_D3D9 NAMES d3d9 PATHS ${DIRECTX_LIB_SEARCH_PATH})
+            find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH})
+            if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D9 AND DIRECT3D_LIB_D3DCOMPILER)
+                set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D9} ${DIRECT3D_LIB_D3DCOMPILER})
+                set (DIRECT3D_FOUND 1)
+            endif ()
+        else ()
+            find_library (DIRECT3D_LIB_D3D11 NAMES d3d11 PATHS ${DIRECTX_LIB_SEARCH_PATH})
+            find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH})
+            find_library (DIRECT3D_LIB_DXGI NAMES dxgi PATHS ${DIRECTX_LIB_SEARCH_PATH})
+            find_library (DIRECT3D_LIB_DXGUID NAMES dxguid PATHS ${DIRECTX_LIB_SEARCH_PATH})
+            if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D11 AND DIRECT3D_LIB_D3DCOMPILER AND DIRECT3D_LIB_DXGI AND DIRECT3D_LIB_DXGUID)
+                set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D11} ${DIRECT3D_LIB_D3DCOMPILER} ${DIRECT3D_LIB_DXGI} ${DIRECT3D_LIB_DXGUID})
+                set (DIRECT3D_FOUND 1)
+            endif ()
         endif ()
         endif ()
     endif ()
     endif ()
 endif ()
 endif ()
 
 
 if (DIRECT3D_FOUND)
 if (DIRECT3D_FOUND)
     include (FindPackageMessage)
     include (FindPackageMessage)
-    FIND_PACKAGE_MESSAGE (Direct3D "Found DirectX SDK: ${DIRECT3D_LIBRARIES} ${DIRECT3D_INCLUDE_DIRS}" "[${DIRECT3D_LIBRARIES}][${DIRECT3D_INCLUDE_DIRS}]")
-else ()
-    if (NOT URHO3D_D3D11)
-        set (DIRECT3D_LIBRARIES d3d9 d3dcompiler)
-    else ()
-        set (DIRECT3D_LIBRARIES d3d11 d3dcompiler dxgi dxguid)
-    endif ()
-    if (MSVC)
-        if (MSVC_VERSION LESS 1700 OR NOT URHO3D_D3D11)
-            message (STATUS "DirectX SDK not found. This is not fatal if a recent Windows SDK is installed")
-        else ()
-            message (STATUS "DirectX SDK search skipped for MSVC 2012 and greater when using Direct3D 11")
-        endif ()
-    else ()
-        message (STATUS "DirectX SDK search skipped for MinGW. It is assumed that MinGW itself comes with the necessary headers & libraries")
-    endif ()
+    FIND_PACKAGE_MESSAGE (Direct3D "Found Direct3D: ${DIRECT3D_LIBRARIES} ${DIRECT3D_INCLUDE_DIRS}" "[${DIRECT3D_LIBRARIES}][${DIRECT3D_INCLUDE_DIRS}]")
+elseif (Direct3D_FIND_REQUIRED)
+    message (FATAL_ERROR "Could not find Direct3D in Windows SDK and DirectX SDK")
 endif ()
 endif ()
 
 
-mark_as_advanced (DIRECT3D_INCLUDE_DIRS DIRECT3D_LIBRARIES)
+mark_as_advanced (DIRECT3D_INCLUDE_DIRS DIRECT3D_LIBRARIES DIRECT3D_DLL)

+ 12 - 5
CMake/Modules/Urho3D-CMake-common.cmake

@@ -350,15 +350,18 @@ if (NOT URHO3D_LIB_TYPE STREQUAL SHARED)
     add_definitions (-DURHO3D_STATIC_DEFINE)
     add_definitions (-DURHO3D_STATIC_DEFINE)
 endif ()
 endif ()
 
 
-# Find DirectX SDK include & library directories for Visual Studio. It is also possible to compile
-# without if a recent Windows SDK is installed. The SDK is not searched for with MinGW as it is
-# incompatible; rather, it is assumed that MinGW itself comes with the necessary headers & libraries.
+# Find Direct3D include & library directories for Visual Studio in MS Windows SDK or DirectX SDK.
+# The SDK is not searched for with MinGW as it is incompatible, rather, it is assumed that MinGW
+# itself comes with the necessary headers & libraries.
 # Note that when building for OpenGL, any libraries are not used, but the include directory may
 # Note that when building for OpenGL, any libraries are not used, but the include directory may
 # be necessary for DirectInput & DirectSound headers, if those are not present in the compiler's own
 # be necessary for DirectInput & DirectSound headers, if those are not present in the compiler's own
 # default includes.
 # default includes.
 if (WIN32)
 if (WIN32)
-    find_package (Direct3D)
-    if (DIRECT3D_FOUND)
+    if (MSVC)
+        set (D3D_REQUIRED REQUIRED)
+    endif ()
+    find_package (Direct3D ${D3D_REQUIRED})
+    if (DIRECT3D_FOUND AND DIRECT3D_INCLUDE_DIRS)
         include_directories (${DIRECT3D_INCLUDE_DIRS})
         include_directories (${DIRECT3D_INCLUDE_DIRS})
     endif ()
     endif ()
 endif ()
 endif ()
@@ -838,6 +841,10 @@ macro (setup_executable)
             install (FILES ${FILES} DESTINATION ${DEST_BUNDLE_DIR} OPTIONAL)    # We get html.map or html.mem depend on the build configuration
             install (FILES ${FILES} DESTINATION ${DEST_BUNDLE_DIR} OPTIONAL)    # We get html.map or html.mem depend on the build configuration
         else ()
         else ()
             install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} BUNDLE DESTINATION ${DEST_BUNDLE_DIR})
             install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} BUNDLE DESTINATION ${DEST_BUNDLE_DIR})
+            if (MSVC AND DIRECT3D_DLL AND NOT DIRECT3D_DLL_INSTALLED)
+                install (FILES ${DIRECT3D_DLL} DESTINATION ${DEST_RUNTIME_DIR})
+                set (DIRECT3D_DLL_INSTALLED TRUE)
+            endif ()
         endif ()
         endif ()
     endif ()
     endif ()
 endmacro ()
 endmacro ()