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