FindDirect3D.cmake 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_DIR
  27. # DIRECT3D_LIBRARY
  28. # DIRECT3D_COMPILER_LIBRARY
  29. #
  30. if (WIN32)
  31. set (DIRECT3D_FOUND 0)
  32. set (DIRECTX_INC_SEARCH_PATH
  33. "$ENV{DIRECTX_ROOT}/Include"
  34. "$ENV{DXSDK_DIR}/Include"
  35. "C:/Program Files (x86)/Microsoft DirectX SDK*/Include"
  36. "C:/Program Files/Microsoft DirectX SDK*/Include")
  37. find_path (DIRECT3D_INCLUDE_DIR d3dx9.h ${DIRECTX_INC_SEARCH_PATH})
  38. if (CMAKE_CL_64)
  39. set (DIRECTX_LIB_SEARCH_PATH
  40. "$ENV{DIRECTX_ROOT}/Lib/x64"
  41. "$ENV{DXSDK_DIR}/Lib/x64"
  42. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/x64"
  43. "C:/Program Files/Microsoft DirectX SDK*/Lib/x64")
  44. else ()
  45. set (DIRECTX_LIB_SEARCH_PATH
  46. "$ENV{DIRECTX_ROOT}/Lib"
  47. "$ENV{DIRECTX_ROOT}/Lib/x86"
  48. "$ENV{DXSDK_DIR}/Lib"
  49. "$ENV{DXSDK_DIR}/Lib/x86"
  50. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib"
  51. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/x86"
  52. "C:/Program Files/Microsoft DirectX SDK*/Lib"
  53. "C:/Program Files/Microsoft DirectX SDK*/Lib/x86")
  54. endif ()
  55. find_library (DIRECT3D_LIBRARY d3d9 ${DIRECTX_LIB_SEARCH_PATH})
  56. find_library (DIRECT3D_COMPILER_LIBRARY d3dcompiler ${DIRECTX_LIB_SEARCH_PATH})
  57. if (DIRECT3D_INCLUDE_DIR AND DIRECT3D_LIBRARY AND DIRECT3D_COMPILER_LIBRARY)
  58. set (DIRECT3D_FOUND 1)
  59. endif ()
  60. if (DIRECT3D_FOUND)
  61. include (FindPackageMessage)
  62. FIND_PACKAGE_MESSAGE (Direct3D "Found DirectX SDK: ${DIRECT3D_LIBRARY} ${DIRECT3D_INCLUDE_DIR}" "[${DIRECT3D_LIBRARY}][${DIRECT3D_INCLUDE_DIR}]")
  63. else ()
  64. message (STATUS "DirectX SDK not found. This is not fatal if a recent Windows SDK is installed")
  65. # Set non-absolute fallback library names and assume they are found in default library directories
  66. set (DIRECT3D_LIBRARY d3d9)
  67. set (DIRECT3D_COMPILER_LIBRARY d3dcompiler)
  68. endif ()
  69. mark_as_advanced (DIRECT3D_INCLUDE_DIR DIRECT3D_LIBRARY DIRECT3D_COMPILER_LIBRARY)
  70. endif ()