forked from thestk/rtaudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
125 lines (107 loc) · 4.01 KB
/
CMakeLists.txt
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
cmake_minimum_required(VERSION 2.8.10)
project(RtAudio)
include(CTest)
include(CheckFunctionExists)
option(BUILD_PYTHON "Build PyRtAudio python bindings" OFF)
option(AUDIO_WINDOWS_DS "Build Windows DirectSound API" OFF)
option(AUDIO_WINDOWS_ASIO "Build Windows ASIO API" OFF)
option(AUDIO_WINDOWS_WASAPI "Build Windows WASAPI API" OFF)
option(AUDIO_LINUX_OSS "Build Linux OSS API" OFF)
option(AUDIO_LINUX_ALSA "Build Linux ALSA API" OFF)
option(AUDIO_LINUX_PULSE "Build Linux PulseAudio API" OFF)
option(AUDIO_UNIX_JACK "Build Unix JACK audio server API" OFF)
option(AUDIO_OSX_CORE "Build Mac OSX CoreAudio API" OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D__RTAUDIO_DEBUG__)
endif ()
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
if (HAVE_GETTIMEOFDAY)
add_definitions(-DHAVE_GETTIMEOFDAY)
endif ()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif (CMAKE_COMPILER_IS_GNUCXX)
set(rtaudio_SOURCES src/RtAudio.cpp)
set(LINKLIBS)
if (CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
message(STATUS "NetBSD detected, using OSS")
find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD)
list(APPEND LINKLIBS ossaudio ${CMAKE_THREAD_LIBS_INIT})
set(AUDIO_LINUX_OSS ON)
elseif (UNIX AND NOT APPLE)
if (NOT AUDIO_LINUX_PULSE AND NOT AUDIO_LINUX_ALSA AND NOT AUDIO_LINUX_OSS AND NOT AUDIO_UNIX_JACK)
set(AUDIO_LINUX_ALSA ON)
endif()
if (AUDIO_LINUX_PULSE)
find_library(PULSE_LIB pulse)
find_library(PULSESIMPLE_LIB pulse-simple)
list(APPEND LINKLIBS ${PULSE_LIB} ${PULSESIMPLE_LIB})
add_definitions(-D__LINUX_PULSE__)
message(STATUS "Using Linux PulseAudio")
endif (AUDIO_LINUX_PULSE)
if (AUDIO_LINUX_ALSA)
find_package(ALSA)
find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD)
if (NOT ALSA_FOUND)
message(FATAL_ERROR "ALSA API requested but no ALSA dev libraries found")
endif()
include_directories(${ALSA_INCLUDE_DIR})
list(APPEND LINKLIBS ${ALSA_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
add_definitions(-D__LINUX_ALSA__)
message(STATUS "Using Linux ALSA")
endif (AUDIO_LINUX_ALSA)
endif ()
if (APPLE)
if (NOT AUDIO_OSX_CORE AND NOT AUDIO_UNIX_JACK)
set(AUDIO_OSX_CORE ON)
endif()
if (AUDIO_OSX_CORE)
find_library(COREAUDIO_LIB CoreAudio)
find_library(COREFOUNDATION_LIB CoreFoundation)
list(APPEND LINKLIBS ${COREAUDIO_LIB} ${COREFOUNDATION_LIB})
add_definitions(-D__MACOSX_CORE__)
message(STATUS "Using OSX CoreAudio")
endif (AUDIO_OSX_CORE)
endif (APPLE)
# JACK supported on many Unices
if (UNIX)
if (AUDIO_UNIX_JACK)
find_library(JACK_LIB jack)
list(APPEND LINKLIBS ${JACK_LIB})
add_definitions(-D__UNIX_JACK__)
message(STATUS "Using JACK")
endif (AUDIO_UNIX_JACK)
endif (UNIX)
if (WIN32)
if (NOT AUDIO_WINDOWS_DS AND NOT AUDIO_WINDOWS_ASIO AND NOT AUDIO_WINDOWS_WASAPI)
set(AUDIO_WINDOWS_WASAPI ON)
endif()
include_directories(include)
list(APPEND LINKLIBS winmm ole32)
if (AUDIO_WINDOWS_DS)
add_definitions(-D__WINDOWS_DS__)
message(STATUS "Using Windows DirectSound")
list(APPEND LINKLIBS dsound)
endif (AUDIO_WINDOWS_DS)
if (AUDIO_WINDOWS_WASAPI)
add_definitions(-D__WINDOWS_WASAPI__)
message(STATUS "Using Windows WASAPI")
list(APPEND LINKLIBS uuid ksuser)
endif (AUDIO_WINDOWS_WASAPI)
if (AUDIO_WINDOWS_ASIO)
list(APPEND rtaudio_SOURCES
include/asio.cpp
include/asiodrivers.cpp
include/asiolist.cpp
include/iasiothiscallresolver.cpp)
add_definitions(-D__WINDOWS_ASIO__)
message(STATUS "Using Windows ASIO")
endif (AUDIO_WINDOWS_ASIO)
endif (WIN32)
cmake_policy(SET CMP0042 OLD)
add_library(rtaudio ${rtaudio_SOURCES})
target_include_directories(rtaudio PUBLIC src)
target_link_libraries(rtaudio ${LINKLIBS})
if (BUILD_TESTING)
add_subdirectory(tests)
endif (BUILD_TESTING)