aboutsummaryrefslogtreecommitdiff
path: root/externals/cmake-modules/FindOpenAL.cmake
blob: dfb768062fd95192c09dc0de7734fade4e43a2cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if(NOT OPENAL_FOUND)
    pkg_check_modules(OPENAL_TMP openal)

    find_path(OPENAL_INCLUDE_DIRS NAMES al.h
            PATHS
            ${OPENAL_TMP_INCLUDE_DIRS}
            /usr/include/AL
            /usr/include
            /usr/local/include/AL
            /usr/local/include
            )

    find_library(OPENAL_LIBRARY_DIRS NAMES openal
            PATHS
            ${OPENAL_TMP_LIBRARY_DIRS}
            /usr/lib
            /usr/local/lib
            )

    if(OPENAL_INCLUDE_DIRS AND OPENAL_LIBRARY_DIRS)
        set(OPENAL_FOUND TRUE CACHE INTERNAL "OpenAL found")
        message(STATUS "Found OpenAL: ${OPENAL_LIBRARY_DIRS}, ${OPENAL_INCLUDE_DIRS}")
    else()
        set(OPENAL_FOUND FALSE CACHE INTERNAL "OpenAL found")
        message(STATUS "OpenAL not found.")
    endif()
endif()

if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL)
    add_library(OpenAL::OpenAL UNKNOWN IMPORTED)
    set_target_properties(OpenAL::OpenAL PROPERTIES
            INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIRS}
            INTERFACE_LINK_LIBRARIES ${OPENAL_LIBRARY_DIRS}
            IMPORTED_LOCATION ${OPENAL_LIBRARY_DIRS}
            )
endif()