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: 5FindOpenAL 6---------- 7 8Finds Open Audio Library (OpenAL). 9 10Projects using this module should use ``#include "al.h"`` to include the OpenAL 11header file, **not** ``#include <AL/al.h>``. The reason for this is that the 12latter is not entirely portable. Windows/Creative Labs does not by default put 13their headers in ``AL/`` and macOS uses the convention ``<OpenAL/al.h>``. 14 15Hints 16^^^^^ 17 18Environment variable ``$OPENALDIR`` can be used to set the prefix of OpenAL 19installation to be found. 20 21By default on macOS, system framework is search first. In other words, 22OpenAL is searched in the following order: 23 241. System framework: ``/System/Library/Frameworks``, whose priority can be 25 changed via setting the :variable:`CMAKE_FIND_FRAMEWORK` variable. 262. Environment variable ``$OPENALDIR``. 273. System paths. 284. User-compiled framework: ``~/Library/Frameworks``. 295. Manually compiled framework: ``/Library/Frameworks``. 306. Add-on package: ``/opt``. 31 32Result Variables 33^^^^^^^^^^^^^^^^ 34 35This module defines the following variables: 36 37``OPENAL_FOUND`` 38 If false, do not try to link to OpenAL 39``OPENAL_INCLUDE_DIR`` 40 OpenAL include directory 41``OPENAL_LIBRARY`` 42 Path to the OpenAL library 43``OPENAL_VERSION_STRING`` 44 Human-readable string containing the version of OpenAL 45#]=======================================================================] 46 47# For Windows, Creative Labs seems to have added a registry key for their 48# OpenAL 1.1 installer. I have added that key to the list of search paths, 49# however, the key looks like it could be a little fragile depending on 50# if they decide to change the 1.00.0000 number for bug fix releases. 51# Also, they seem to have laid down groundwork for multiple library platforms 52# which puts the library in an extra subdirectory. Currently there is only 53# Win32 and I have hardcoded that here. This may need to be adjusted as 54# platforms are introduced. 55# The OpenAL 1.0 installer doesn't seem to have a useful key I can use. 56# I do not know if the Nvidia OpenAL SDK has a registry key. 57 58find_path(OPENAL_INCLUDE_DIR al.h 59 HINTS 60 ENV OPENALDIR 61 PATHS 62 ~/Library/Frameworks 63 /Library/Frameworks 64 /opt 65 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] 66 PATH_SUFFIXES include/AL include/OpenAL include AL OpenAL 67 ) 68 69if(CMAKE_SIZEOF_VOID_P EQUAL 8) 70 set(_OpenAL_ARCH_DIR libs/Win64) 71else() 72 set(_OpenAL_ARCH_DIR libs/Win32) 73endif() 74 75find_library(OPENAL_LIBRARY 76 NAMES OpenAL al openal OpenAL32 77 HINTS 78 ENV OPENALDIR 79 PATHS 80 ~/Library/Frameworks 81 /Library/Frameworks 82 /opt 83 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] 84 PATH_SUFFIXES libx32 lib64 lib libs64 libs ${_OpenAL_ARCH_DIR} 85 ) 86 87unset(_OpenAL_ARCH_DIR) 88 89include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) 90find_package_handle_standard_args( 91 OpenAL 92 REQUIRED_VARS OPENAL_LIBRARY OPENAL_INCLUDE_DIR 93 VERSION_VAR OPENAL_VERSION_STRING 94 ) 95 96mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) 97