summaryrefslogtreecommitdiff
path: root/indra/cmake/OPENAL.cmake
blob: 6555027dc13da4ca8b65487ee2baa7edaba5617b (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- cmake -*-
include(Linking)
include(Prebuilt)

include_guard()

# ND: Turn this off by default, the openal code in the viewer isn't very well maintained, seems
# to have memory leaks, has no option to play music streams
# It probably makes sense to to completely remove it

set(USE_OPENAL OFF CACHE BOOL "Enable OpenAL")
# ND: To streamline arguments passed, switch from OPENAL to USE_OPENAL
# To not break all old build scripts convert old arguments but warn about it
if(OPENAL)
  message( WARNING "Use of the OPENAL argument is deprecated, please switch to USE_OPENAL")
  set(USE_OPENAL ${OPENAL})
endif()

if (USE_OPENAL)
  add_library( ll::openal INTERFACE IMPORTED )

  if (NOT (USE_AUTOBUILD_3P OR USE_CONAN))
    target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1)
    include(FindPkgConfig)
    pkg_check_modules(Openal REQUIRED freealut)
    target_include_directories(ll::openal SYSTEM INTERFACE ${Openal_INCLUDE_DIRS})
    target_link_directories(ll::openal INTERFACE ${Openal_LIBRARY_DIRS})
    target_link_libraries(ll::openal INTERFACE ${Openal_LIBRARIES})
    return ()
  endif ()

  target_include_directories( ll::openal SYSTEM INTERFACE "${LIBS_PREBUILT_DIR}/include/AL")
  target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1)
  use_prebuilt_binary(openal)

  if(WINDOWS)
    target_link_libraries( ll::openal INTERFACE
            OpenAL32
            alut
            )
  elseif(LINUX)
    target_link_libraries( ll::openal INTERFACE
            openal
            alut
            )
  else()
    target_link_libraries( ll::openal INTERFACE
            openal
            alut
            )
  endif()
endif ()