FindDirect3D.cmake 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_DIR
  28. # DIRECT3D_LIBRARIES
  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:/apps_x86/Microsoft DirectX SDK*/Include"
  36. "C:/Program Files (x86)/Microsoft DirectX SDK*/Include"
  37. "C:/apps/Microsoft DirectX SDK*/Include"
  38. "C:/Program Files/Microsoft DirectX SDK*/Include")
  39. find_path (DIRECT3D_INCLUDE_DIR d3dx9.h ${DIRECTX_INC_SEARCH_PATH})
  40. if (CMAKE_CL_64)
  41. set (DIRECTX_LIB_SEARCH_PATH
  42. "$ENV{DIRECTX_ROOT}/Lib/x64"
  43. "$ENV{DXSDK_DIR}/Lib/x64"
  44. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/x64"
  45. "C:/Program Files/Microsoft DirectX SDK*/Lib/x64")
  46. else ()
  47. set (DIRECTX_LIB_SEARCH_PATH
  48. "$ENV{DIRECTX_ROOT}/Lib"
  49. "$ENV{DIRECTX_ROOT}/Lib/x86"
  50. "$ENV{DXSDK_DIR}/Lib"
  51. "$ENV{DXSDK_DIR}/Lib/x86"
  52. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib"
  53. "C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/x86"
  54. "C:/Program Files/Microsoft DirectX SDK*/Lib"
  55. "C:/Program Files/Microsoft DirectX SDK*/Lib/x86")
  56. endif ()
  57. find_library (DIRECT3D_LIBRARIES d3d9 ${DIRECTX_LIB_SEARCH_PATH})
  58. if (DIRECT3D_INCLUDE_DIR AND DIRECT3D_LIBRARIES)
  59. set (DIRECT3D_FOUND 1)
  60. get_filename_component (DIRECT3D_LIBRARY_DIR ${DIRECT3D_LIBRARIES} PATH)
  61. endif ()
  62. if (DIRECT3D_FOUND)
  63. include (FindPackageMessage)
  64. FIND_PACKAGE_MESSAGE (Direct3D "Found DirectX SDK: ${DIRECT3D_LIBRARIES} ${DIRECT3D_INCLUDE_DIR}" "[${DIRECT3D_LIBRARIES}][${DIRECT3D_INCLUDE_DIR}]")
  65. else ()
  66. message ("-- DirectX SDK not found. This is not fatal if a recent Windows SDK is installed")
  67. endif ()
  68. mark_as_advanced (DIRECT3D_INCLUDE_DIR DIRECT3D_LIBRARIES)
  69. endif ()