vuze: drop (#358309)
[NixPkgs.git] / pkgs / tools / audio / opl3bankeditor / 0001-opl3bankeditor-Look-for-system-installed-Rt-libs.patch
blob36adff53a011bf2ed4c59486c4766a8c0845ed6e
1 From 11711398a1ec16f4eaeac8523b77165a560b69cc Mon Sep 17 00:00:00 2001
2 From: OPNA2608 <christoph.neidahl@gmail.com>
3 Date: Sun, 13 Jun 2021 13:55:53 +0200
4 Subject: [PATCH] Look for system-installed Rt libs
6 ---
7 CMakeLists.txt | 159 +++++++++++++++++++++++++++++++------------------
8 1 file changed, 102 insertions(+), 57 deletions(-)
10 diff --git a/CMakeLists.txt b/CMakeLists.txt
11 index f3e53c3..027c1b1 100644
12 --- a/CMakeLists.txt
13 +++ b/CMakeLists.txt
14 @@ -50,15 +50,6 @@ message("!! Optional feature summary:")
15 message("!! RtMidi: ${USE_RTMIDI}")
16 message("!! RtAudio: ${USE_RTAUDIO}")
18 -if(USE_RTAUDIO)
19 - if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
20 - pkg_check_modules(JACK "jack")
21 - message("!! -- Jack driver: ${JACK_FOUND}")
22 - pkg_check_modules(PULSEAUDIO "libpulse-simple")
23 - message("!! -- Pulseaudio driver: ${PULSEAUDIO_FOUND}")
24 - endif()
25 -endif()
27 if(ENABLE_PLOTS)
28 message("!! Qwt: ${QWT_LIBRARY}")
29 endif()
30 @@ -250,65 +241,119 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
31 endif()
33 if(USE_RTMIDI)
34 - add_library(RtMidi STATIC "src/midi/external/rtmidi/RtMidi.cpp")
35 - target_include_directories(RtMidi PUBLIC "src/midi/external/rtmidi")
36 - if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
37 - target_compile_definitions(RtMidi PUBLIC "__LINUX_ALSA__")
38 - target_link_libraries(RtMidi PUBLIC "asound")
39 - elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
40 - target_compile_definitions(RtMidi PUBLIC "__WINDOWS_MM__")
41 - target_link_libraries(RtMidi PUBLIC "winmm")
42 - elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
43 - target_compile_definitions(RtMidi PUBLIC "__MACOSX_CORE__")
44 - find_library(COREMIDI_LIBRARY "CoreMIDI")
45 - target_link_libraries(RtMidi PUBLIC "${COREMIDI_LIBRARY}")
46 + if(PKG_CONFIG_FOUND)
47 + pkg_check_modules(RTMIDI rtmidi)
48 + if(RTMIDI_FOUND)
49 + message("Using system-installed RtMidi found by pkg-config.")
50 + target_link_libraries(OPL3BankEditor PUBLIC ${RTMIDI_LDFLAGS})
51 + target_include_directories(OPL3BankEditor PUBLIC ${RTMIDI_INCLUDE_DIRS})
52 + target_compile_options(OPL3BankEditor PUBLIC ${RTMIDI_CFLAGS})
53 + endif()
54 endif()
56 + if(NOT RTMIDI_FOUND)
57 + find_library(RTMIDI_LIBRARY "rtmidi")
58 + find_path(RTMIDI_INCLUDE_DIRS "RtMidi.h")
59 + message("RtMidi library: ${RTMIDI_LIBRARY}")
60 + message("RtMidi header directory: ${RTMIDI_INCLUDE_DIRS}")
61 + if(NOT RTMIDI_LIBRARY-NOTFOUND AND NOT RTMIDI_INCLUDE_DIRS STREQUAL RTMIDI_INCLUDE_DIRS-NOTFOUND)
62 + message("Using system-installed RtMidi.")
63 + set(RTMIDI_FOUND TRUE)
64 + target_link_libraries(OPL3BankEditor PUBLIC ${RTMIDI_LIBRARY})
65 + target_include_directories(OPL3BankEditor PUBLIC ${RTMIDI_INCLUDE_DIRS})
66 + endif()
67 + endif()
69 + if(NOT RTMIDI_FOUND)
70 + message("Using bundled RtMidi.")
71 + add_library(RtMidi STATIC "src/midi/external/rtmidi/RtMidi.cpp")
72 + target_include_directories(RtMidi PUBLIC "src/midi/external/rtmidi")
73 + if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
74 + target_compile_definitions(RtMidi PUBLIC "__LINUX_ALSA__")
75 + target_link_libraries(RtMidi PUBLIC "asound")
76 + elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
77 + target_compile_definitions(RtMidi PUBLIC "__WINDOWS_MM__")
78 + target_link_libraries(RtMidi PUBLIC "winmm")
79 + elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
80 + target_compile_definitions(RtMidi PUBLIC "__MACOSX_CORE__")
81 + find_library(COREMIDI_LIBRARY "CoreMIDI")
82 + target_link_libraries(RtMidi PUBLIC "${COREMIDI_LIBRARY}")
83 + endif()
84 + target_link_libraries(OPL3BankEditor PRIVATE RtMidi)
85 + endif()
87 target_sources(OPL3BankEditor PRIVATE "src/midi/midi_rtmidi.cpp")
88 target_compile_definitions(OPL3BankEditor PRIVATE "ENABLE_MIDI")
89 - target_link_libraries(OPL3BankEditor PRIVATE RtMidi)
90 endif()
92 if(USE_RTAUDIO)
93 - add_library(RtAudio STATIC "src/audio/external/rtaudio/RtAudio.cpp")
94 - target_include_directories(RtAudio PUBLIC "src/audio/external/rtaudio")
95 - if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
96 - target_compile_definitions(RtAudio PUBLIC "__LINUX_ALSA__")
97 - target_link_libraries(RtAudio PUBLIC "asound")
98 - if(JACK_FOUND)
99 - target_compile_definitions(RtAudio PUBLIC "__UNIX_JACK__")
100 - target_include_directories(RtAudio PUBLIC ${JACK_INCLUDE_DIRS})
101 - link_directories(${JACK_LIBRARY_DIRS})
102 - target_link_libraries(RtAudio PUBLIC ${JACK_LIBRARIES})
103 + if(PKG_CONFIG_FOUND)
104 + pkg_check_modules(RTAUDIO rtaudio)
105 + if(RTAUDIO_FOUND)
106 + message("Using system-installed RtAudio found by pkg-config.")
107 + target_link_libraries(OPL3BankEditor PUBLIC ${RTAUDIO_LDFLAGS})
108 + target_include_directories(OPL3BankEditor PUBLIC ${RTAUDIO_INCLUDE_DIRS})
109 + target_compile_options(OPL3BankEditor PUBLIC ${RTAUDIO_CFLAGS})
110 + endif()
111 + endif()
113 + if(NOT RTAUDIO_FOUND)
114 + find_library(RTAUDIO_LIBRARY "rtaudio")
115 + find_path(RTAUDIO_INCLUDE_DIRS "RtAudio.h")
116 + message("RtAudio library: ${RTAUDIO_LIBRARY}")
117 + message("RtAudio header directory: ${RTAUDIO_INCLUDE_DIRS}")
118 + if(NOT RTAUDIO_LIBRARY-NOTFOUND AND NOT RTAUDIO_INCLUDE_DIRS STREQUAL RTAUDIO_INCLUDE_DIRS-NOTFOUND)
119 + message("Using system-installed RtAudio.")
120 + set(RTAUDIO_FOUND TRUE)
121 + target_link_libraries(OPL3BankEditor PUBLIC ${RTAUDIO_LIBRARY})
122 + target_include_directories(OPL3BankEditor PUBLIC ${RTAUDIO_INCLUDE_DIRS})
123 endif()
124 - if(PULSEAUDIO_FOUND)
125 - target_compile_definitions(RtAudio PUBLIC "__LINUX_PULSE__")
126 - target_include_directories(RtAudio PUBLIC ${PULSEAUDIO_INCLUDE_DIRS})
127 - link_directories(${PULSEAUDIO_LIBRARY_DIRS})
128 - target_link_libraries(RtAudio PUBLIC ${PULSEAUDIO_LIBRARIES})
129 + endif()
131 + if(NOT RTAUDIO_FOUND)
132 + message("Using bundled RtAudio.")
133 + add_library(RtAudio STATIC "src/audio/external/rtaudio/RtAudio.cpp")
134 + target_include_directories(RtAudio PUBLIC "src/audio/external/rtaudio")
135 + if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
136 + target_compile_definitions(RtAudio PUBLIC "__LINUX_ALSA__")
137 + target_link_libraries(RtAudio PUBLIC "asound")
138 + if(JACK_FOUND)
139 + target_compile_definitions(RtAudio PUBLIC "__UNIX_JACK__")
140 + target_include_directories(RtAudio PUBLIC ${JACK_INCLUDE_DIRS})
141 + link_directories(${JACK_LIBRARY_DIRS})
142 + target_link_libraries(RtAudio PUBLIC ${JACK_LIBRARIES})
143 + endif()
144 + if(PULSEAUDIO_FOUND)
145 + target_compile_definitions(RtAudio PUBLIC "__LINUX_PULSE__")
146 + target_include_directories(RtAudio PUBLIC ${PULSEAUDIO_INCLUDE_DIRS})
147 + link_directories(${PULSEAUDIO_LIBRARY_DIRS})
148 + target_link_libraries(RtAudio PUBLIC ${PULSEAUDIO_LIBRARIES})
149 + endif()
150 + elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
151 + target_compile_definitions(RtAudio PUBLIC "__WINDOWS_DS__")
152 + target_link_libraries(RtAudio PUBLIC "dsound" "ole32")
153 + target_compile_definitions(RtAudio PUBLIC "__WINDOWS_WASAPI__")
154 + target_link_libraries(RtAudio PUBLIC "ksguid")
155 + target_compile_definitions(RtAudio PUBLIC "__WINDOWS_ASIO__")
156 + target_include_directories(RtAudio PRIVATE
157 + "src/audio/external/rtaudio/include")
158 + target_sources(RtAudio PRIVATE
159 + "src/audio/external/rtaudio/include/asio.cpp"
160 + "src/audio/external/rtaudio/include/asiodrivers.cpp"
161 + "src/audio/external/rtaudio/include/asiolist.cpp"
162 + "src/audio/external/rtaudio/include/iasiothiscallresolver.cpp")
163 + elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
164 + target_compile_definitions(RtAudio PUBLIC "__MACOSX_CORE__")
165 + find_library(COREAUDIO_LIBRARY "CoreAudio")
166 + target_link_libraries(RtAudio PUBLIC "${COREAUDIO_LIBRARY}")
167 + find_library(COREFOUNDATION_LIBRARY "CoreFoundation")
168 + target_link_libraries(RtAudio PUBLIC "${COREFOUNDATION_LIBRARY}")
169 endif()
170 - elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
171 - target_compile_definitions(RtAudio PUBLIC "__WINDOWS_DS__")
172 - target_link_libraries(RtAudio PUBLIC "dsound" "ole32")
173 - target_compile_definitions(RtAudio PUBLIC "__WINDOWS_WASAPI__")
174 - target_link_libraries(RtAudio PUBLIC "ksguid")
175 - target_compile_definitions(RtAudio PUBLIC "__WINDOWS_ASIO__")
176 - target_include_directories(RtAudio PRIVATE
177 - "src/audio/external/rtaudio/include")
178 - target_sources(RtAudio PRIVATE
179 - "src/audio/external/rtaudio/include/asio.cpp"
180 - "src/audio/external/rtaudio/include/asiodrivers.cpp"
181 - "src/audio/external/rtaudio/include/asiolist.cpp"
182 - "src/audio/external/rtaudio/include/iasiothiscallresolver.cpp")
183 - elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
184 - target_compile_definitions(RtAudio PUBLIC "__MACOSX_CORE__")
185 - find_library(COREAUDIO_LIBRARY "CoreAudio")
186 - target_link_libraries(RtAudio PUBLIC "${COREAUDIO_LIBRARY}")
187 - find_library(COREFOUNDATION_LIBRARY "CoreFoundation")
188 - target_link_libraries(RtAudio PUBLIC "${COREFOUNDATION_LIBRARY}")
189 + target_link_libraries(OPL3BankEditor PRIVATE RtAudio)
190 endif()
192 target_sources(OPL3BankEditor PRIVATE "src/audio/ao_rtaudio.cpp")
193 target_compile_definitions(OPL3BankEditor PRIVATE "ENABLE_AUDIO_TESTING")
194 - target_link_libraries(OPL3BankEditor PRIVATE RtAudio)
195 endif()
197 add_executable(measurer_tool
199 2.29.3