cmake: Move OpenSLES detection to AudioCommon through find_package()

This commit is contained in:
Florent Castelli 2017-02-04 00:55:29 +01:00
parent 529dc6aa53
commit fb02a321b6
3 changed files with 31 additions and 11 deletions

View File

@ -873,16 +873,6 @@ if(NOT ANDROID)
add_definitions(-DHAVE_HIDAPI=1)
endif()
find_library(OPENSLES_LIBRARIES NAMES OpenSLES)
find_path(OPENSLES_INCLUDE_DIR NAMES SLES/OpenSLES.h)
if (OPENSLES_LIBRARIES AND OPENSLES_INCLUDE_DIR)
set(OPENSLES_FOUND 1)
add_definitions(-DHAVE_OPENSLES=1)
include_directories(${OPENSLES_INCLUDE_DIR})
message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
endif()
if(NOT DISABLE_WX)
find_package(wxWidgets COMPONENTS core aui adv)

View File

@ -0,0 +1,28 @@
# - Try to find OpenSLES
# Once done this will define
# OPENSLES_FOUND - System has OpenSLES
# OPENSLES_INCLUDE_DIR - The OpenSLES include directory
# OPENSLES_LIBRARY - The library needed to use OpenSLES
# An imported target OpenSLES::OpenSLES is also created, prefer this
find_path(OPENSLES_INCLUDE_DIR
NAMES SLES/OpenSLES.h
)
find_library(OPENSLES_LIBRARY
NAMES OpenSLES
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenSLES DEFAULT_MSG
OPENSLES_LIBRARY OPENSLES_INCLUDE_DIR)
if(OpenSLES_FOUND)
add_library(OpenSLES::OpenSLES UNKNOWN IMPORTED)
set_target_properties(OpenSLES::OpenSLES PROPERTIES
IMPORTED_LOCATION ${OPENSLES_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${OPENSLES_INCLUDE_DIR}
)
endif()
mark_as_advanced(OPENSLES_INCLUDE_DIR OPENSLES_LIBRARY )

View File

@ -6,9 +6,11 @@ set(SRCS AudioCommon.cpp
set(LIBS "")
find_package(OpenSLES)
if(OPENSLES_FOUND)
message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
set(SRCS ${SRCS} OpenSLESStream.cpp)
set(LIBS ${LIBS} ${OPENSLES_LIBRARIES})
set(LIBS ${LIBS} OpenSLES::OpenSLES)
endif()
if(ALSA_FOUND)