FindOpenAL.cmake 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Locate OpenAL
  2. # This module defines
  3. # OPENAL_LIBRARY
  4. # OPENAL_FOUND, if false, do not try to link to OpenAL
  5. # OPENAL_INCLUDE_DIR, where to find the headers
  6. #
  7. # $OPENALDIR is an environment variable that would
  8. # correspond to the ./configure --prefix=$OPENALDIR
  9. # used in building OpenAL.
  10. #
  11. # Created by Eric Wing. This was influenced by the FindSDL.cmake module.
  12. #=============================================================================
  13. # Copyright 2005-2009 Kitware, Inc.
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  18. # This software is distributed WITHOUT ANY WARRANTY; without even the
  19. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. # See the License for more information.
  21. #=============================================================================
  22. # (To distributed this file outside of CMake, substitute the full
  23. # License text for the above reference.)
  24. # This makes the presumption that you are include al.h like
  25. # #include "al.h"
  26. # and not
  27. # #include <AL/al.h>
  28. # The reason for this is that the latter is not entirely portable.
  29. # Windows/Creative Labs does not by default put their headers in AL/ and
  30. # OS X uses the convention <OpenAL/al.h>.
  31. #
  32. # For Windows, Creative Labs seems to have added a registry key for their
  33. # OpenAL 1.1 installer. I have added that key to the list of search paths,
  34. # however, the key looks like it could be a little fragile depending on
  35. # if they decide to change the 1.00.0000 number for bug fix releases.
  36. # Also, they seem to have laid down groundwork for multiple library platforms
  37. # which puts the library in an extra subdirectory. Currently there is only
  38. # Win32 and I have hardcoded that here. This may need to be adjusted as
  39. # platforms are introduced.
  40. # The OpenAL 1.0 installer doesn't seem to have a useful key I can use.
  41. # I do not know if the Nvidia OpenAL SDK has a registry key.
  42. #
  43. # For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger).
  44. # To support the framework, I originally wrote special framework detection
  45. # code in this module which I have now removed with CMake's introduction
  46. # of native support for frameworks.
  47. # In addition, OpenAL is open source, and it is possible to compile on Panther.
  48. # Furthermore, due to bugs in the initial OpenAL release, and the
  49. # transition to OpenAL 1.1, it is common to need to override the built-in
  50. # framework.
  51. # Per my request, CMake should search for frameworks first in
  52. # the following order:
  53. # ~/Library/Frameworks/OpenAL.framework/Headers
  54. # /Library/Frameworks/OpenAL.framework/Headers
  55. # /System/Library/Frameworks/OpenAL.framework/Headers
  56. #
  57. # On OS X, this will prefer the Framework version (if found) over others.
  58. # People will have to manually change the cache values of
  59. # OPENAL_LIBRARY to override this selection or set the CMake environment
  60. # CMAKE_INCLUDE_PATH to modify the search paths.
  61. FIND_PATH(OPENAL_INCLUDE_DIR al.h
  62. HINTS
  63. $ENV{OPENALDIR}
  64. PATH_SUFFIXES include/AL include/OpenAL include
  65. PATHS
  66. ~/Library/Frameworks
  67. /Library/Frameworks
  68. /usr/local
  69. /usr
  70. /sw # Fink
  71. /opt/local # DarwinPorts
  72. /opt/csw # Blastwave
  73. /opt
  74. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
  75. )
  76. FIND_LIBRARY(OPENAL_LIBRARY
  77. NAMES OpenAL al openal OpenAL32
  78. HINTS
  79. $ENV{OPENALDIR}
  80. PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
  81. PATHS
  82. ~/Library/Frameworks
  83. /Library/Frameworks
  84. /usr/local
  85. /usr
  86. /sw
  87. /opt/local
  88. /opt/csw
  89. /opt
  90. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
  91. )
  92. SET(OPENAL_FOUND "NO")
  93. IF(OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
  94. SET(OPENAL_FOUND "YES")
  95. ENDIF(OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)