FindDirect3D.cmake 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #
  2. # Copyright (c) 2008-2014 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. # For MSVC compiler, find Microsoft DirectX installation (need June 2010 SDK or later)
  23. # For MinGW compiler, assume MinGW not only comes with the necessary headers & libraries but also has the headers & libraries directories in its default search path
  24. # (use 'echo |gcc -v -E -' and 'gcc -print-search-dirs', respectively, to double check)
  25. #
  26. # DIRECT3D_FOUND
  27. # DIRECT3D_INCLUDE_DIRS
  28. # DIRECT3D_LIBRARIES
  29. #
  30. if (NOT WIN32 OR DIRECT3D_FOUND)
  31. return ()
  32. endif ()
  33. if (MSVC)
  34. set (DIRECTX_INC_SEARCH_PATH
  35. "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include"
  36. "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include"
  37. "$ENV{DIRECTX_ROOT}/Include"
  38. "$ENV{DXSDK_DIR}/Include")
  39. find_path (DIRECT3D_INCLUDE_DIRS NAMES d3dcompiler.h PATHS ${DIRECTX_INC_SEARCH_PATH})
  40. if (CMAKE_CL_64)
  41. set (DIRECTX_LIB_SEARCH_PATH
  42. "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64"
  43. "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x64"
  44. "$ENV{DIRECTX_ROOT}/Lib/x64"
  45. "$ENV{DXSDK_DIR}/Lib/x64")
  46. else ()
  47. set (DIRECTX_LIB_SEARCH_PATH
  48. "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib"
  49. "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x86"
  50. "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib"
  51. "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x86"
  52. "$ENV{DIRECTX_ROOT}/Lib"
  53. "$ENV{DIRECTX_ROOT}/Lib/x86"
  54. "$ENV{DXSDK_DIR}/Lib"
  55. "$ENV{DXSDK_DIR}/Lib/x86")
  56. endif ()
  57. find_library (DIRECT3D_LIB_D3D9 NAMES d3d9 PATHS ${DIRECTX_LIB_SEARCH_PATH})
  58. find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH})
  59. if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D9 AND DIRECT3D_LIB_D3DCOMPILER)
  60. set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D9} ${DIRECT3D_LIB_D3DCOMPILER})
  61. set (DIRECT3D_FOUND 1)
  62. endif ()
  63. endif ()
  64. if (DIRECT3D_FOUND)
  65. include (FindPackageMessage)
  66. FIND_PACKAGE_MESSAGE (Direct3D "Found DirectX SDK: ${DIRECT3D_LIBRARIES} ${DIRECT3D_INCLUDE_DIRS}" "[${DIRECT3D_LIBRARIES}][${DIRECT3D_INCLUDE_DIRS}]")
  67. else ()
  68. set (DIRECT3D_LIBRARIES d3d9 d3dcompiler)
  69. if (MSVC)
  70. message (STATUS "DirectX SDK not found. This is not fatal if a recent Windows SDK is installed")
  71. else ()
  72. message (STATUS "DirectX SDK is not being searched for MinGW. It is assumed that MinGW itself comes with the necessary headers & libraries for Direct3D")
  73. endif ()
  74. endif ()
  75. mark_as_advanced (DIRECT3D_INCLUDE_DIRS DIRECT3D_LIBRARIES)