Browse Source

modules: rewrite FindOpenAL to support static and subproject AL Soft.

Strange build breakages, I'm ready for you now!
pull/454/head
Vladimír Vondruš 6 years ago
parent
commit
25f7d79a96
  1. 10
      doc/changelog.dox
  2. 15
      doc/namespaces.dox
  3. 4
      modules/FindMagnum.cmake
  4. 259
      modules/FindOpenAL.cmake
  5. 4
      package/ci/appveyor-desktop-gles.bat
  6. 4
      package/ci/appveyor-desktop-mingw.bat
  7. 2
      package/ci/appveyor-desktop-vulkan.bat
  8. 8
      package/ci/appveyor-desktop.bat
  9. 6
      package/ci/appveyor.yml
  10. 27
      src/Magnum/Audio/CMakeLists.txt
  11. 15
      src/Magnum/Audio/Extensions.h

10
doc/changelog.dox

@ -494,6 +494,16 @@ See also:
- Properly installing plugin binaries in Gentoo packages (see - Properly installing plugin binaries in Gentoo packages (see
[mosra/magnum-plugins#85](https://github.com/mosra/magnum-plugins/issues/85)) [mosra/magnum-plugins#85](https://github.com/mosra/magnum-plugins/issues/85))
- Warning fixes for MSVC (see [mosra/magnum#445](https://github.com/mosra/magnum/pull/445)) - Warning fixes for MSVC (see [mosra/magnum#445](https://github.com/mosra/magnum/pull/445))
- `FindOpenAL.cmake` was rewritten from scratch to support linking against
statically built OpenAL Soft (through its CMake config file) as well as
OpenAL Soft added as a CMake subproject. Moreover, when using Magnum as a
CMake subproject, the @ref Audio library now copies the OpenAL DLL to
`CMAKE_RUNTIME_OUTPUT_DIRECTORY` (if set) as a post-build step. The DLL
location, if found, is also available through an `OPENAL_DLL_RELEASE`
variable for use by 3rd party code. See also
[mosra/magnum#402](https://github.com/mosra/magnum/issues/402) and
[mosra/magnum#412](https://github.com/mosra/magnum/issues/412) for more
information.
@subsection changelog-latest-bugfixes Bug fixes @subsection changelog-latest-bugfixes Bug fixes

15
doc/namespaces.dox

@ -270,13 +270,18 @@ find_package(Magnum REQUIRED Audio)
target_link_libraries(your-app PRIVATE Magnum::Audio) target_link_libraries(your-app PRIVATE Magnum::Audio)
@endcode @endcode
Additionally, if you're using Magnum as a CMake subproject, do the following Additionally, if you're using Magnum as a CMake subproject, bundle the
* *before* calling @cmake find_package() @ce to ensure it's enabled, as the [openal-soft repository](https://github.com/kcat/openal-soft) and do the
library is not built by default. Using OpenAL itself as a CMake subproject following *before* calling @cmake find_package() @ce to ensure it's enabled, as
isn't tested at the moment, so you need to provide it as a system dependency the library is not built by default. If you want to use system-installed
and point `CMAKE_PREFIX_PATH` to its installation dir if necessary. OpenAL, omit the first part and point `CMAKE_PREFIX_PATH` to its installation
dir if necessary.
@code{.cmake} @code{.cmake}
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # needed if building dynamic libraries
set(LIBTYPE STATIC) # omit or set to SHARED if you want a shared OpenAL library
add_subdirectory(openal-soft EXCLUDE_FROM_ALL)
set(WITH_AUDIO ON CACHE BOOL "" FORCE) set(WITH_AUDIO ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL) add_subdirectory(magnum EXCLUDE_FROM_ALL)
@endcode @endcode

4
modules/FindMagnum.cmake

@ -817,9 +817,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
elseif(_component STREQUAL Audio) elseif(_component STREQUAL Audio)
find_package(OpenAL) find_package(OpenAL)
set_property(TARGET Magnum::${_component} APPEND PROPERTY set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR}) INTERFACE_LINK_LIBRARIES Corrade::PluginManager OpenAL::OpenAL)
set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENAL_LIBRARY} Corrade::PluginManager)
# No special setup for DebugTools library # No special setup for DebugTools library

259
modules/FindOpenAL.cmake

@ -1,145 +1,160 @@
#.rst: #.rst:
# FindOpenAL # Find OpenAL
# ---------- # -----------
# #
# Finds the OpenAL library. This module defines:
# #
# OpenAL_FOUND - True if the OpenAL library is found
# OpenAL::OpenAL - OpenAL imported target
# #
# Locate OpenAL This module defines OPENAL_LIBRARY OPENAL_FOUND, if # Additionally these variables are defined for internal usage:
# false, do not try to link to OpenAL OPENAL_INCLUDE_DIR, where to find
# the headers
# #
# $OPENALDIR is an environment variable that would correspond to the # OPENAL_LIBRARY - OpenAL library
# ./configure --prefix=$OPENALDIR used in building OpenAL. # OPENAL_DLL_RELEASE - OpenAL release DLL on Windows, if found. Note that
# (at least in case of the binary OpenAL Soft distribution) it's named
# soft_oal.dll and you need to rename it to OpenAL32.dll to make it work.
# OPENAL_INCLUDE_DIR - Include dir
# #
# Created by Eric Wing. This was influenced by the FindSDL.cmake
# module.
#=============================================================================
# CMake - Cross Platform Makefile Generator
# Copyright 2000-2016 Kitware, Inc.
# Copyright 2000-2011 Insight Software Consortium
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# #
# * Redistributions in binary form must reproduce the above copyright # This file is part of Magnum.
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# #
# * Neither the names of Kitware, Inc., the Insight Software Consortium, # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
# nor the names of their contributors may be used to endorse or promote # 2020 Vladimír Vondruš <mosra@centrum.cz>
# products derived from this software without specific prior written
# permission.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # Permission is hereby granted, free of charge, to any person obtaining a
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # copy of this software and associated documentation files (the "Software"),
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # to deal in the Software without restriction, including without limitation
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # the rights to use, copy, modify, merge, publish, distribute, sublicense,
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # and/or sell copies of the Software, and to permit persons to whom the
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # Software is furnished to do so, subject to the following conditions:
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
# This makes the presumption that you are include al.h like
# #include "al.h"
# and not
# #include <AL/al.h>
# The reason for this is that the latter is not entirely portable.
# Windows/Creative Labs does not by default put their headers in AL/ and
# OS X uses the convention <OpenAL/al.h>.
# #
# For Windows, Creative Labs seems to have added a registry key for their # The above copyright notice and this permission notice shall be included
# OpenAL 1.1 installer. I have added that key to the list of search paths, # in all copies or substantial portions of the Software.
# however, the key looks like it could be a little fragile depending on
# if they decide to change the 1.00.0000 number for bug fix releases.
# Also, they seem to have laid down groundwork for multiple library platforms
# which puts the library in an extra subdirectory. Currently there is only
# Win32 and I have hardcoded that here. This may need to be adjusted as
# platforms are introduced.
# The OpenAL 1.0 installer doesn't seem to have a useful key I can use.
# I do not know if the Nvidia OpenAL SDK has a registry key.
# #
# For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger). # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# To support the framework, I originally wrote special framework detection # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# code in this module which I have now removed with CMake's introduction # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# of native support for frameworks. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# In addition, OpenAL is open source, and it is possible to compile on Panther. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# Furthermore, due to bugs in the initial OpenAL release, and the # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# transition to OpenAL 1.1, it is common to need to override the built-in # DEALINGS IN THE SOFTWARE.
# framework.
# Per my request, CMake should search for frameworks first in
# the following order:
# ~/Library/Frameworks/OpenAL.framework/Headers
# /Library/Frameworks/OpenAL.framework/Headers
# /System/Library/Frameworks/OpenAL.framework/Headers
# #
# On OS X, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of # OpenAL Soft installs cmake package config files which handles dependencies in
# OPENAL_LIBRARY to override this selection or set the CMake environment # case OpenAL Soft is built statically. Try to find first, quietly, so it
# CMAKE_INCLUDE_PATH to modify the search paths. # doesn't print loud messages when it's not found, since that's okay. If the
# OpenAL target already exists, it means we're using it through a CMake
# This version is modified for Magnum and was forked from # subproject -- don't attempt to find the package in that case.
# https://github.com/Kitware/CMake/blob/v3.6.1/Modules/FindOpenAL.cmake if(NOT TARGET OpenAL)
# The file was modified to add a new path suffix for finding OpenAL for find_package(OpenAL CONFIG QUIET)
# Emscripten on macOS. Additionally, in case of Emscripten, there's no library endif()
# to find but instead one says -lopenal (and if MINIMAL_RUNTIME is not
# specified, this is implicit). # If either an OpenAL Soft config file was found or we have a subproject, point
# OpenAL::OpenAL to that and exit -- nothing else to do here.
find_path(OPENAL_INCLUDE_DIR al.h if(TARGET OpenAL OR TARGET OpenAL::OpenAL)
HINTS # OpenAL Soft config file already defines this one, so this is just for
ENV OPENALDIR # the subproject case.
# The AL was added in order to make the module working for Emscripten on macOS. if(NOT TARGET OpenAL::OpenAL)
# Not sure why include/AL wasn't enough. # Aliases of (global) targets are only supported in CMake 3.11, so we
PATH_SUFFIXES include/AL include/OpenAL include AL # work around it by this. This is easier than fetching all possible
PATHS # properties (which are impossible to track of) and then attempting to
~/Library/Frameworks # rebuild them into a new target.
/Library/Frameworks add_library(OpenAL::OpenAL INTERFACE IMPORTED)
/sw # Fink set_target_properties(OpenAL::OpenAL PROPERTIES INTERFACE_LINK_LIBRARIES OpenAL)
/opt/local # DarwinPorts
/opt/csw # Blastwave # The OpenAL target doesn't define any usable
/opt # INTERFACE_INCLUDE_DIRECTORIES for some reason (apparently the
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] # $<BUILD_INTERFACE:> in there doesn't work or whatever), so let's do
) # that ourselves.
get_target_property(_OPENAL_SOURCE_DIR OpenAL SOURCE_DIR)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) set_target_properties(OpenAL::OpenAL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${_OPENAL_SOURCE_DIR}/include/AL)
set(_OpenAL_ARCH_DIR libs/Win64) endif()
else()
set(_OpenAL_ARCH_DIR libs/Win32) # Just to make FPHSA print some meaningful location, nothing else.
# Fortunately because of the INTERFACE_INCLUDE_DIRECTORIES workaround above
# we can have the same handling both in case of an imported target and a
# CMake subproject.
get_target_property(_OPENAL_INTERFACE_INCLUDE_DIRECTORIES OpenAL::OpenAL INTERFACE_INCLUDE_DIRECTORIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("OpenAL" DEFAULT_MSG
_OPENAL_INTERFACE_INCLUDE_DIRECTORIES)
if(CORRADE_TARGET_WINDOWS)
# TODO: investigate if OpenAL Soft has IMPORTED_LOCATION_ / IMPLIB like
# GLFW does so we can provide OPENAL_DLL
endif()
return()
endif() endif()
# Under Emscripten, OpenAL is linked implicitly. With MINIMAL_RUNTIME you need
# to specify -lopenal. Simply set the library name to that.
if(CORRADE_TARGET_EMSCRIPTEN) if(CORRADE_TARGET_EMSCRIPTEN)
set(OPENAL_LIBRARY openal CACHE STRING "Path to a library." FORCE) set(OPENAL_LIBRARY openal CACHE STRING "Path to a library." FORCE)
else() else()
find_library(OPENAL_LIBRARY # OpenAL Soft Windows binary distribution puts the library into a subdir,
NAMES OpenAL al openal OpenAL32 # the legacy one from Creative uses the same. OpenAL Soft puts DLLs into
HINTS # bin/Win{32,64}/soft_oal.dll
ENV OPENALDIR if(WIN32)
PATH_SUFFIXES lib64 lib libs64 libs ${_OpenAL_ARCH_DIR} if(CMAKE_SIZEOF_VOID_P EQUAL 8)
PATHS set(_OPENAL_LIBRARY_PATH_SUFFIX libs/Win64)
~/Library/Frameworks set(_OPENAL_DLL_PATH_SUFFIX bin/Win64)
/Library/Frameworks elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
/sw set(_OPENAL_LIBRARY_PATH_SUFFIX libs/Win32)
/opt/local set(_OPENAL_DLL_PATH_SUFFIX bin/Win32)
/opt/csw endif()
/opt endif()
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
) find_library(OPENAL_LIBRARY
# Names same as in CMake's vanilla FindOpenAL
NAMES OpenAL al openal OpenAL32
# For binary OpenAL Soft distribution on Windows
PATH_SUFFIXES ${_OPENAL_LIBRARY_PATH_SUFFIX}
# The other PATHS from CMake's vanilla FindOpenAL seem to be a legacy
# cruft, skipping those. The Windows registry used by the vanilla
# FindOpenAL doesn't seem to be set anymore either.
)
endif() endif()
unset(_OpenAL_ARCH_DIR) # Include dir
find_path(OPENAL_INCLUDE_DIR NAMES al.h
# AL/ used by OpenAL Soft, OpenAL/ used by the macOS framework. The legacy
# Creative SDK puts al.h directly into include/, ffs.
PATH_SUFFIXES AL OpenAL
# As above, skipping the obsolete PATHS and registry in vanilla FindOpenAL
)
# OpenAL DLL on Windows
if(CORRADE_TARGET_WINDOWS)
# TODO: debug?
find_file(OPENAL_DLL_RELEASE
NAMES soft_oal.dll
PATH_SUFFIXES ${_OPENAL_DLL_PATH_SUFFIX})
endif()
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) find_package_handle_standard_args(OpenAL DEFAULT_MSG
OPENAL_LIBRARY
OPENAL_INCLUDE_DIR)
if(NOT TARGET OpenAL::OpenAL)
# Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((APPLE AND ${OPENAL_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(OpenAL::OpenAL INTERFACE IMPORTED)
set_property(TARGET OpenAL::OpenAL APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENAL_LIBRARY})
else()
add_library(OpenAL::OpenAL UNKNOWN IMPORTED)
set_property(TARGET OpenAL::OpenAL PROPERTY
IMPORTED_LOCATION ${OPENAL_LIBRARY})
endif()
set_target_properties(OpenAL::OpenAL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR})
endif()
mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR)

4
package/ci/appveyor-desktop-gles.bat

@ -1,6 +1,8 @@
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" x64 || exit /b if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" x64 || exit /b
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" x64 || exit /b if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" x64 || exit /b
set PATH=%APPVEYOR_BUILD_FOLDER%/openal/bin/Win64;%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH% set PATH=%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH%
rem OpenAL DLL is renamed & copied to magnum's bin dir automatically by the
rem buildsystem, no need to do that here anymore
rem Build Corrade rem Build Corrade
git clone --depth 1 git://github.com/mosra/corrade.git || exit /b git clone --depth 1 git://github.com/mosra/corrade.git || exit /b

4
package/ci/appveyor-desktop-mingw.bat

@ -1,6 +1,8 @@
rem Workaround for CMake not wanting sh.exe on PATH for MinGW. AARGH. rem Workaround for CMake not wanting sh.exe on PATH for MinGW. AARGH.
set PATH=%PATH:C:\Program Files\Git\usr\bin;=% set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%APPVEYOR_BUILD_FOLDER%/openal/bin/Win64;%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH% set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH%
rem OpenAL DLL is renamed & copied to magnum's bin dir automatically by the
rem buildsystem, no need to do that here anymore
rem Build Corrade rem Build Corrade
git clone --depth 1 git://github.com/mosra/corrade.git || exit /b git clone --depth 1 git://github.com/mosra/corrade.git || exit /b

2
package/ci/appveyor-desktop-vulkan.bat

@ -1,5 +1,5 @@
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" x64 || exit /b if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" x64 || exit /b
set PATH=%APPVEYOR_BUILD_FOLDER%/openal/bin/Win64;%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH% set PATH=%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH%
rem Build Corrade rem Build Corrade
git clone --depth 1 git://github.com/mosra/corrade.git || exit /b git clone --depth 1 git://github.com/mosra/corrade.git || exit /b

8
package/ci/appveyor-desktop.bat

@ -2,12 +2,8 @@ if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" call "C:/Program File
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" %PLATFORM% || exit /b if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" %PLATFORM% || exit /b
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" %PLATFORM% || exit /b if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" %PLATFORM% || exit /b
set PATH=%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH% set PATH=%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH%
if "%PLATFORM%" == "" set PATH=%APPVEYOR_BUILD_FOLDER%/openal/bin/Win32;%PATH% rem OpenAL DLL is renamed & copied to magnum's bin dir automatically by the
rem for SOME FREAKING REASON vcvarsall.bat in MSVC2015 sets %PLATFORM% to rem buildsystem, no need to do that here anymore
rem X64 while I expect it to be x64. With a 32-bit build it fortunately stays
rem empty. Not a problem on 2017 or 2019. So doing a case-insensitive compare
rem here to make things work properly.
if /I "%PLATFORM%" == "x64" set PATH=%APPVEYOR_BUILD_FOLDER%/openal/bin/Win64;%PATH%
rem need to explicitly specify a 64-bit target, otherwise CMake+Ninja can't rem need to explicitly specify a 64-bit target, otherwise CMake+Ninja can't
rem figure that out -- https://gitlab.kitware.com/cmake/cmake/issues/16259 rem figure that out -- https://gitlab.kitware.com/cmake/cmake/issues/16259

6
package/ci/appveyor.yml

@ -97,12 +97,10 @@ install:
# For ES builds, otherwise the "%COMPILER:~0,4%" below doesn't work, sigh # For ES builds, otherwise the "%COMPILER:~0,4%" below doesn't work, sigh
- IF "%COMPILER%" == "" set COMPILER=msvc - IF "%COMPILER%" == "" set COMPILER=msvc
# OpenAL # OpenAL. The DLL is copied & renamed by the buildsystem, no need to do that
# here anymore.
- IF NOT "%TARGET%" == "rt" IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\openal-soft-1.19.1-bin.zip appveyor DownloadFile https://openal-soft.org/openal-binaries/openal-soft-1.19.1-bin.zip - IF NOT "%TARGET%" == "rt" IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\openal-soft-1.19.1-bin.zip appveyor DownloadFile https://openal-soft.org/openal-binaries/openal-soft-1.19.1-bin.zip
- IF NOT "%TARGET%" == "rt" 7z x openal-soft-1.19.1-bin.zip && ren openal-soft-1.19.1-bin openal && echo [General] > %APPDATA%/alsoft.ini & echo drivers=null >> %APPDATA%/alsoft.ini - IF NOT "%TARGET%" == "rt" 7z x openal-soft-1.19.1-bin.zip && ren openal-soft-1.19.1-bin openal && echo [General] > %APPDATA%/alsoft.ini & echo drivers=null >> %APPDATA%/alsoft.ini
- IF "%TARGET%" == "desktop" ren openal\bin\Win64\soft_oal.dll OpenAL32.dll
- IF "%TARGET%" == "desktop" ren openal\bin\Win32\soft_oal.dll OpenAL32.dll
- IF "%TARGET%" == "desktop-gles" ren openal\bin\Win64\soft_oal.dll OpenAL32.dll
# Build apps on both GL and Vulkan to verify these can build w/o GL as well. # Build apps on both GL and Vulkan to verify these can build w/o GL as well.
# Not on GLES, as there's not much GLES-dependent. # Not on GLES, as there's not much GLES-dependent.

27
src/Magnum/Audio/CMakeLists.txt

@ -71,7 +71,7 @@ add_library(MagnumAudioObjects OBJECT
${MagnumAudio_SRCS} ${MagnumAudio_SRCS}
${MagnumAudio_HEADERS}) ${MagnumAudio_HEADERS})
target_include_directories(MagnumAudioObjects PUBLIC target_include_directories(MagnumAudioObjects PUBLIC
${OPENAL_INCLUDE_DIR} $<TARGET_PROPERTY:OpenAL::OpenAL,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Corrade::PluginManager,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:Corrade::PluginManager,INTERFACE_INCLUDE_DIRECTORIES>)
if(NOT BUILD_STATIC) if(NOT BUILD_STATIC)
@ -95,9 +95,12 @@ if(NOT BUILD_STATIC)
elseif(BUILD_STATIC_PIC) elseif(BUILD_STATIC_PIC)
set_target_properties(MagnumAudio PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumAudio PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_link_libraries(MagnumAudio Magnum Corrade::PluginManager ${OPENAL_LIBRARY}) target_link_libraries(MagnumAudio PUBLIC
Magnum
Corrade::PluginManager
OpenAL::OpenAL)
if(WITH_SCENEGRAPH) if(WITH_SCENEGRAPH)
target_link_libraries(MagnumAudio MagnumSceneGraph) target_link_libraries(MagnumAudio PUBLIC MagnumSceneGraph)
endif() endif()
install(TARGETS MagnumAudio install(TARGETS MagnumAudio
@ -106,12 +109,22 @@ install(TARGETS MagnumAudio
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumAudio_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Audio) install(FILES ${MagnumAudio_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Audio)
# Copy the OpenAL DLL next to the place where all executables are stored to
# help people running the apps. TODO: update if we ever have a debug DLL
if(CMAKE_RUNTIME_OUTPUT_DIRECTORY AND CORRADE_TARGET_WINDOWS AND OPENAL_DLL_RELEASE)
# Not exactly sure why, but in the OpenAL Soft binary distribution it's
# named soft_oal.dll and needs to be renamed to OpenAL32.dll to work
# correctly
add_custom_command(TARGET MagnumAudio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENAL_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll)
endif()
# Magnum Audio target alias for superprojects # Magnum Audio target alias for superprojects
add_library(Magnum::Audio ALIAS MagnumAudio) add_library(Magnum::Audio ALIAS MagnumAudio)
if(WITH_AL_INFO) if(WITH_AL_INFO)
add_executable(magnum-al-info al-info.cpp) add_executable(magnum-al-info al-info.cpp)
target_link_libraries(magnum-al-info MagnumAudio) target_link_libraries(magnum-al-info PRIVATE MagnumAudio)
set_target_properties(magnum-al-info PROPERTIES FOLDER "Magnum/Audio") set_target_properties(magnum-al-info PROPERTIES FOLDER "Magnum/Audio")
if(NOT MAGNUM_TARGET_EMSCRIPTEN) if(NOT MAGNUM_TARGET_EMSCRIPTEN)
@ -162,12 +175,12 @@ if(BUILD_TESTS)
if(BUILD_STATIC_PIC) if(BUILD_STATIC_PIC)
set_target_properties(MagnumAudioTestLib PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumAudioTestLib PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_link_libraries(MagnumAudioTestLib target_link_libraries(MagnumAudioTestLib PUBLIC
Magnum Magnum
Corrade::PluginManager Corrade::PluginManager
${OPENAL_LIBRARY}) OpenAL::OpenAL)
if(WITH_SCENEGRAPH) if(WITH_SCENEGRAPH)
target_link_libraries(MagnumAudioTestLib MagnumSceneGraph) target_link_libraries(MagnumAudioTestLib PUBLIC MagnumSceneGraph)
endif() endif()
add_subdirectory(Test) add_subdirectory(Test)

15
src/Magnum/Audio/Extensions.h

@ -59,13 +59,18 @@ find_package(Magnum REQUIRED Audio)
target_link_libraries(your-app PRIVATE Magnum::Audio) target_link_libraries(your-app PRIVATE Magnum::Audio)
@endcode @endcode
Additionally, if you're using Magnum as a CMake subproject, do the following Additionally, if you're using Magnum as a CMake subproject, bundle the
* *before* calling @cmake find_package() @ce to ensure it's enabled, as the [openal-soft repository](https://github.com/kcat/openal-soft) and do the
library is not built by default. Using OpenAL itself as a CMake subproject following *before* calling @cmake find_package() @ce to ensure it's enabled, as
isn't isn't tested at the moment, so you need to provide it as a system the library is not built by default. If you want to use system-installed
dependency and point `CMAKE_PREFIX_PATH` to its installation dir if necessary. OpenAL, omit the first part and point `CMAKE_PREFIX_PATH` to its installation
dir if necessary.
@code{.cmake} @code{.cmake}
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # needed if building dynamic libraries
set(LIBTYPE STATIC) # omit or set to SHARED if you want a shared OpenAL library
add_subdirectory(openal-soft EXCLUDE_FROM_ALL)
set(WITH_AUDIO ON CACHE BOOL "" FORCE) set(WITH_AUDIO ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL) add_subdirectory(magnum EXCLUDE_FROM_ALL)
@endcode @endcode

Loading…
Cancel
Save