toxic: 0.15.1 -> 0.16.0
[NixPkgs.git] / pkgs / tools / audio / opl3bankeditor / 0001-opn2bankeditor-Look-for-system-installed-Rt-libs.patch
blobf62c3236b33fe94d162ededc05b0fa7e4175bb91
1 From 69c993dacc7dc0cb9d105c3dfa764cd7be5c343e Mon Sep 17 00:00:00 2001
2 From: OPNA2608 <christoph.neidahl@gmail.com>
3 Date: Sun, 13 Jun 2021 14:21:17 +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 f428dc4..18ba8c3 100644
12 --- a/CMakeLists.txt
13 +++ b/CMakeLists.txt
14 @@ -41,15 +41,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 @@ -198,65 +189,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(OPN2BankEditor PUBLIC ${RTMIDI_LDFLAGS})
51 + target_include_directories(OPN2BankEditor PUBLIC ${RTMIDI_INCLUDE_DIRS})
52 + target_compile_options(OPN2BankEditor 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(OPN2BankEditor PUBLIC ${RTMIDI_LIBRARY})
65 + target_include_directories(OPN2BankEditor 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(OPN2BankEditor PRIVATE RtMidi)
85 endif()
87 target_sources(OPN2BankEditor PRIVATE "src/midi/midi_rtmidi.cpp")
88 target_compile_definitions(OPN2BankEditor PRIVATE "ENABLE_MIDI")
89 - target_link_libraries(OPN2BankEditor 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(OPN2BankEditor PUBLIC ${RTAUDIO_LDFLAGS})
108 + target_include_directories(OPN2BankEditor PUBLIC ${RTAUDIO_INCLUDE_DIRS})
109 + target_compile_options(OPN2BankEditor PUBLIC ${RTAUDIO_CFLAGS})
110 endif()
111 - if(PULSEAUDIO_FOUND)
112 - target_compile_definitions(RtAudio PUBLIC "__LINUX_PULSE__")
113 - target_include_directories(RtAudio PUBLIC ${PULSEAUDIO_INCLUDE_DIRS})
114 - link_directories(${PULSEAUDIO_LIBRARY_DIRS})
115 - target_link_libraries(RtAudio PUBLIC ${PULSEAUDIO_LIBRARIES})
116 + endif()
118 + if(NOT RTAUDIO_FOUND)
119 + find_library(RTAUDIO_LIBRARY "rtaudio")
120 + find_path(RTAUDIO_INCLUDE_DIRS "RtAudio.h")
121 + message("RtAudio library: ${RTAUDIO_LIBRARY}")
122 + message("RtAudio header directory: ${RTAUDIO_INCLUDE_DIRS}")
123 + if(NOT RTAUDIO_LIBRARY-NOTFOUND AND NOT RTAUDIO_INCLUDE_DIRS STREQUAL RTAUDIO_INCLUDE_DIRS-NOTFOUND)
124 + message("Using system-installed RtAudio.")
125 + set(RTAUDIO_FOUND TRUE)
126 + target_link_libraries(OPN2BankEditor PUBLIC ${RTAUDIO_LIBRARY})
127 + target_include_directories(OPN2BankEditor PUBLIC ${RTAUDIO_INCLUDE_DIRS})
128 endif()
129 - elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
130 - target_compile_definitions(RtAudio PUBLIC "__WINDOWS_DS__")
131 - target_link_libraries(RtAudio PUBLIC "dsound" "ole32")
132 - target_compile_definitions(RtAudio PUBLIC "__WINDOWS_WASAPI__")
133 - target_link_libraries(RtAudio PUBLIC "ksguid")
134 - target_compile_definitions(RtAudio PUBLIC "__WINDOWS_ASIO__")
135 - target_include_directories(RtAudio PRIVATE
136 - "src/audio/external/rtaudio/include")
137 - target_sources(RtAudio PRIVATE
138 - "src/audio/external/rtaudio/include/asio.cpp"
139 - "src/audio/external/rtaudio/include/asiodrivers.cpp"
140 - "src/audio/external/rtaudio/include/asiolist.cpp"
141 - "src/audio/external/rtaudio/include/iasiothiscallresolver.cpp")
142 - elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
143 - target_compile_definitions(RtAudio PUBLIC "__MACOSX_CORE__")
144 - find_library(COREAUDIO_LIBRARY "CoreAudio")
145 - target_link_libraries(RtAudio PUBLIC "${COREAUDIO_LIBRARY}")
146 - find_library(COREFOUNDATION_LIBRARY "CoreFoundation")
147 - target_link_libraries(RtAudio PUBLIC "${COREFOUNDATION_LIBRARY}")
148 endif()
150 + if(NOT RTAUDIO_FOUND)
151 + message("Using bundled RtAudio.")
152 + add_library(RtAudio STATIC "src/audio/external/rtaudio/RtAudio.cpp")
153 + target_include_directories(RtAudio PUBLIC "src/audio/external/rtaudio")
154 + if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
155 + target_compile_definitions(RtAudio PUBLIC "__LINUX_ALSA__")
156 + target_link_libraries(RtAudio PUBLIC "asound")
157 + if(JACK_FOUND)
158 + target_compile_definitions(RtAudio PUBLIC "__UNIX_JACK__")
159 + target_include_directories(RtAudio PUBLIC ${JACK_INCLUDE_DIRS})
160 + link_directories(${JACK_LIBRARY_DIRS})
161 + target_link_libraries(RtAudio PUBLIC ${JACK_LIBRARIES})
162 + endif()
163 + if(PULSEAUDIO_FOUND)
164 + target_compile_definitions(RtAudio PUBLIC "__LINUX_PULSE__")
165 + target_include_directories(RtAudio PUBLIC ${PULSEAUDIO_INCLUDE_DIRS})
166 + link_directories(${PULSEAUDIO_LIBRARY_DIRS})
167 + target_link_libraries(RtAudio PUBLIC ${PULSEAUDIO_LIBRARIES})
168 + endif()
169 + elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
170 + target_compile_definitions(RtAudio PUBLIC "__WINDOWS_DS__")
171 + target_link_libraries(RtAudio PUBLIC "dsound" "ole32")
172 + target_compile_definitions(RtAudio PUBLIC "__WINDOWS_WASAPI__")
173 + target_link_libraries(RtAudio PUBLIC "ksguid")
174 + target_compile_definitions(RtAudio PUBLIC "__WINDOWS_ASIO__")
175 + target_include_directories(RtAudio PRIVATE
176 + "src/audio/external/rtaudio/include")
177 + target_sources(RtAudio PRIVATE
178 + "src/audio/external/rtaudio/include/asio.cpp"
179 + "src/audio/external/rtaudio/include/asiodrivers.cpp"
180 + "src/audio/external/rtaudio/include/asiolist.cpp"
181 + "src/audio/external/rtaudio/include/iasiothiscallresolver.cpp")
182 + elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
183 + target_compile_definitions(RtAudio PUBLIC "__MACOSX_CORE__")
184 + find_library(COREAUDIO_LIBRARY "CoreAudio")
185 + target_link_libraries(RtAudio PUBLIC "${COREAUDIO_LIBRARY}")
186 + find_library(COREFOUNDATION_LIBRARY "CoreFoundation")
187 + target_link_libraries(RtAudio PUBLIC "${COREFOUNDATION_LIBRARY}")
188 + endif()
189 + target_link_libraries(OPN2BankEditor PRIVATE RtAudio)
190 + endif()
192 target_sources(OPN2BankEditor PRIVATE "src/audio/ao_rtaudio.cpp")
193 target_compile_definitions(OPN2BankEditor PRIVATE "ENABLE_AUDIO_TESTING")
194 - target_link_libraries(OPN2BankEditor PRIVATE RtAudio)
195 endif()
197 add_executable(measurer_tool
199 2.29.3