Debian Codegraph @

CMake/FindOpenAL.cmake

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