FindOpenAL.cmake 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindOpenAL
  5. ----------
  6. Finds Open Audio Library (OpenAL).
  7. This module defines ``OPENAL_LIBRARY OPENAL_FOUND``, if
  8. false, do not try to link to OpenAL ``OPENAL_INCLUDE_DIR``, where to find
  9. the headers.
  10. ``$OPENALDIR`` is an environment variable that would correspond to the
  11. ``./configure --prefix=$OPENALDIR`` used in building OpenAL.
  12. Created by Eric Wing. This was influenced by the ``FindSDL.cmake``
  13. module.
  14. #]=======================================================================]
  15. # This makes the presumption that you are include al.h like
  16. # #include "al.h"
  17. # and not
  18. # #include <AL/al.h>
  19. # The reason for this is that the latter is not entirely portable.
  20. # Windows/Creative Labs does not by default put their headers in AL/ and
  21. # OS X uses the convention <OpenAL/al.h>.
  22. #
  23. # For Windows, Creative Labs seems to have added a registry key for their
  24. # OpenAL 1.1 installer. I have added that key to the list of search paths,
  25. # however, the key looks like it could be a little fragile depending on
  26. # if they decide to change the 1.00.0000 number for bug fix releases.
  27. # Also, they seem to have laid down groundwork for multiple library platforms
  28. # which puts the library in an extra subdirectory. Currently there is only
  29. # Win32 and I have hardcoded that here. This may need to be adjusted as
  30. # platforms are introduced.
  31. # The OpenAL 1.0 installer doesn't seem to have a useful key I can use.
  32. # I do not know if the Nvidia OpenAL SDK has a registry key.
  33. #
  34. # For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger).
  35. # To support the framework, I originally wrote special framework detection
  36. # code in this module which I have now removed with CMake's introduction
  37. # of native support for frameworks.
  38. # In addition, OpenAL is open source, and it is possible to compile on Panther.
  39. # Furthermore, due to bugs in the initial OpenAL release, and the
  40. # transition to OpenAL 1.1, it is common to need to override the built-in
  41. # framework.
  42. # Per my request, CMake should search for frameworks first in
  43. # the following order:
  44. # ~/Library/Frameworks/OpenAL.framework/Headers
  45. # /Library/Frameworks/OpenAL.framework/Headers
  46. # /System/Library/Frameworks/OpenAL.framework/Headers
  47. #
  48. # On OS X, this will prefer the Framework version (if found) over others.
  49. # People will have to manually change the cache values of
  50. # OPENAL_LIBRARY to override this selection or set the CMake environment
  51. # CMAKE_INCLUDE_PATH to modify the search paths.
  52. find_path(OPENAL_INCLUDE_DIR al.h
  53. HINTS
  54. ENV OPENALDIR
  55. PATH_SUFFIXES include/AL include/OpenAL include AL OpenAL
  56. PATHS
  57. ~/Library/Frameworks
  58. /Library/Frameworks
  59. /opt
  60. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
  61. )
  62. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  63. set(_OpenAL_ARCH_DIR libs/Win64)
  64. else()
  65. set(_OpenAL_ARCH_DIR libs/Win32)
  66. endif()
  67. find_library(OPENAL_LIBRARY
  68. NAMES OpenAL al openal OpenAL32
  69. HINTS
  70. ENV OPENALDIR
  71. PATH_SUFFIXES libx32 lib64 lib libs64 libs ${_OpenAL_ARCH_DIR}
  72. PATHS
  73. ~/Library/Frameworks
  74. /Library/Frameworks
  75. /opt
  76. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
  77. )
  78. unset(_OpenAL_ARCH_DIR)
  79. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  80. FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
  81. mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR)