FindDirect3D.cmake 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #
  2. # Copyright (c) 2008-2013 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. # Find Microsoft DirectX installation
  23. # The search paths are based on realXtend Tundra CMake build system (https://github.com/realXtend/naali)
  24. #
  25. # DIRECT3D_FOUND
  26. # DIRECT3D_INCLUDE_DIRS
  27. # DIRECT3D_LIBRARIES
  28. # DIRECT3D_COMPILER_LIBRARIES
  29. #
  30. if (NOT WIN32)
  31. return ()
  32. endif ()
  33. if (DIRECT3D_FOUND)
  34. return ()
  35. endif ()
  36. set (DIRECTX_INC_SEARCH_PATH
  37. "$ENV{DIRECTX_ROOT}/Include"
  38. "$ENV{DXSDK_DIR}/Include"
  39. "C:/Program Files (x86)/Microsoft DirectX SDK*/Include"
  40. "C:/Program Files/Microsoft DirectX SDK*/Include")
  41. find_path (DIRECT3D_INCLUDE_DIRS d3dx9.h ${DIRECTX_INC_SEARCH_PATH})
  42. if (CMAKE_CL_64)
  43. set (DIRECTX_LIB_SEARCH_PATH
  44. "$ENV{DIRECTX_ROOT}/Lib/x64"
  45. "$ENV{DXSDK_DIR}/Lib/x64"
  46. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/x64"
  47. "C:/Program Files/Microsoft DirectX SDK*/Lib/x64")
  48. else ()
  49. set (DIRECTX_LIB_SEARCH_PATH
  50. "$ENV{DIRECTX_ROOT}/Lib"
  51. "$ENV{DIRECTX_ROOT}/Lib/x86"
  52. "$ENV{DXSDK_DIR}/Lib"
  53. "$ENV{DXSDK_DIR}/Lib/x86"
  54. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib"
  55. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/x86"
  56. "C:/Program Files/Microsoft DirectX SDK*/Lib"
  57. "C:/Program Files/Microsoft DirectX SDK*/Lib/x86")
  58. endif ()
  59. find_library (DIRECT3D_LIBRARIES d3d9 ${DIRECTX_LIB_SEARCH_PATH})
  60. find_library (DIRECT3D_COMPILER_LIBRARIES d3dcompiler ${DIRECTX_LIB_SEARCH_PATH})
  61. if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIBRARIES AND DIRECT3D_COMPILER_LIBRARIES)
  62. set (DIRECT3D_FOUND 1)
  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. message (STATUS "DirectX SDK not found. This is not fatal if a recent Windows SDK is installed")
  69. # Set non-absolute fallback library names and assume they are found in default library directories
  70. set (DIRECT3D_LIBRARIES d3d9)
  71. set (DIRECT3D_COMPILER_LIBRARIES d3dcompiler)
  72. endif ()
  73. mark_as_advanced (DIRECT3D_INCLUDE_DIRS DIRECT3D_LIBRARIES DIRECT3D_COMPILER_LIBRARIES)