Browse Source

modules: find the OpenAL DLL also with the imported target.

And update the DLL copying to handle Debug as well.
pull/454/head
Vladimír Vondruš 6 years ago
parent
commit
1b1347f571
  1. 20
      modules/FindOpenAL.cmake
  2. 18
      src/Magnum/Audio/CMakeLists.txt

20
modules/FindOpenAL.cmake

@ -11,8 +11,8 @@
#
# OPENAL_LIBRARY - OpenAL library
# 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.
# 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
#
@ -69,6 +69,17 @@ if(TARGET OpenAL OR TARGET OpenAL::OpenAL)
# that ourselves.
get_target_property(_OPENAL_SOURCE_DIR OpenAL SOURCE_DIR)
set_target_properties(OpenAL::OpenAL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${_OPENAL_SOURCE_DIR}/include/AL)
# For the imported target get the DLL location
else()
if(CORRADE_TARGET_WINDOWS)
get_target_property(OPENAL_DLL_DEBUG OpenAL::OpenAL IMPORTED_LOCATION_DEBUG)
get_target_property(OPENAL_DLL_RELEASE OpenAL::OpenAL IMPORTED_LOCATION_RELEASE)
# Release not found, fall back to RelWithDebInfo
if(NOT OPENAL_DLL_RELEASE)
get_target_property(OPENAL_DLL_RELEASE OpenAL::OpenAL IMPORTED_LOCATION_RELWITHDEBINFO)
endif()
endif()
endif()
# Just to make FPHSA print some meaningful location, nothing else.
@ -81,11 +92,6 @@ if(TARGET OpenAL OR TARGET OpenAL::OpenAL)
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()

18
src/Magnum/Audio/CMakeLists.txt

@ -110,13 +110,21 @@ install(TARGETS MagnumAudio
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)
# help people running the apps.
if(CMAKE_RUNTIME_OUTPUT_DIRECTORY AND CORRADE_TARGET_WINDOWS AND (OPENAL_DLL_DEBUG OR 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)
# correctly. Not the case with OpenAL Soft built by hand.
if(OPENAL_DLL_DEBUG AND OPENAL_DLL_RELEASE)
add_custom_command(TARGET MagnumAudio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<$<CONFIG:Debug>:${OPENAL_DLL_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${OPENAL_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll)
elseif(OPENAL_DLL_DEBUG)
add_custom_command(TARGET MagnumAudio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENAL_DLL_DEBUG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll)
else()
add_custom_command(TARGET MagnumAudio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENAL_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll)
endif()
endif()
# Magnum Audio target alias for superprojects

Loading…
Cancel
Save