cmake: Move detection of OpenAL to AudioCommon

This commit is contained in:
Florent Castelli 2017-02-06 00:28:11 +01:00
parent 662a6e836d
commit d1eaa59a8e
2 changed files with 16 additions and 20 deletions

View File

@ -447,23 +447,6 @@ else()
message(STATUS "PulseAudio explicitly disabled, disabling PulseAudio sound backend")
endif()
if(ENABLE_OPENAL)
if(WIN32)
set(ENV{OPENALDIR} ${CMAKE_CURRENT_LIST_DIR}/Externals/OpenAL)
endif()
find_package(OpenAL)
if(OPENAL_FOUND)
add_definitions(-DHAVE_OPENAL=1)
include_directories(${OPENAL_INCLUDE_DIR})
message(STATUS "OpenAL found, enabling OpenAL sound backend")
else()
add_definitions(-DHAVE_OPENAL=0)
message(STATUS "OpenAL NOT found, disabling OpenAL sound backend")
endif()
else()
message(STATUS "OpenAL explicitly disabled, disabling OpenAL sound backend")
endif()
if(ENABLE_LLVM)
find_package(LLVM)
if (LLVM_FOUND)
@ -678,6 +661,7 @@ else()
set(PNG png)
endif()
find_package(OpenAL)
if(OPENAL_FOUND)
if(NOT APPLE)
check_lib(SOUNDTOUCH soundtouch SoundTouch soundtouch/SoundTouch.h QUIET)

View File

@ -43,9 +43,21 @@ else()
message(STATUS "ao explicitly disabled, disabling ao sound backend")
endif()
if(OPENAL_FOUND)
target_sources(audiocommon PRIVATE OpenALStream.cpp aldlist.cpp)
target_link_libraries(audiocommon PRIVATE ${OPENAL_LIBRARY} SoundTouch)
if(ENABLE_OPENAL)
if(WIN32)
set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/Externals/OpenAL)
endif()
find_package(OpenAL)
if(OPENAL_FOUND)
message(STATUS "OpenAL found, enabling OpenAL sound backend")
target_sources(audiocommon PRIVATE OpenALStream.cpp aldlist.cpp)
target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL SoundTouch)
target_compile_definitions(audiocommon PRIVATE HAVE_OPENAL=1)
else()
message(STATUS "OpenAL NOT found, disabling OpenAL sound backend")
endif()
else()
message(STATUS "OpenAL explicitly disabled, disabling OpenAL sound backend")
endif()
if(PULSEAUDIO_FOUND)