nixpkgs/pkgs/tools/audio/opl3bankeditor/0001-opl3bankeditor-Look-for-system-installed-Rt-libs.patch

201 lines
9 KiB
Diff
Raw Normal View History

From 11711398a1ec16f4eaeac8523b77165a560b69cc Mon Sep 17 00:00:00 2001
From: OPNA2608 <christoph.neidahl@gmail.com>
Date: Sun, 13 Jun 2021 13:55:53 +0200
Subject: [PATCH] Look for system-installed Rt libs
---
CMakeLists.txt | 159 +++++++++++++++++++++++++++++++------------------
1 file changed, 102 insertions(+), 57 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3e53c3..027c1b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,15 +50,6 @@ message("!! Optional feature summary:")
message("!! RtMidi: ${USE_RTMIDI}")
message("!! RtAudio: ${USE_RTAUDIO}")
-if(USE_RTAUDIO)
- if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- pkg_check_modules(JACK "jack")
- message("!! -- Jack driver: ${JACK_FOUND}")
- pkg_check_modules(PULSEAUDIO "libpulse-simple")
- message("!! -- Pulseaudio driver: ${PULSEAUDIO_FOUND}")
- endif()
-endif()
-
if(ENABLE_PLOTS)
message("!! Qwt: ${QWT_LIBRARY}")
endif()
@@ -250,65 +241,119 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()
if(USE_RTMIDI)
- add_library(RtMidi STATIC "src/midi/external/rtmidi/RtMidi.cpp")
- target_include_directories(RtMidi PUBLIC "src/midi/external/rtmidi")
- if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- target_compile_definitions(RtMidi PUBLIC "__LINUX_ALSA__")
- target_link_libraries(RtMidi PUBLIC "asound")
- elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- target_compile_definitions(RtMidi PUBLIC "__WINDOWS_MM__")
- target_link_libraries(RtMidi PUBLIC "winmm")
- elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- target_compile_definitions(RtMidi PUBLIC "__MACOSX_CORE__")
- find_library(COREMIDI_LIBRARY "CoreMIDI")
- target_link_libraries(RtMidi PUBLIC "${COREMIDI_LIBRARY}")
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(RTMIDI rtmidi)
+ if(RTMIDI_FOUND)
+ message("Using system-installed RtMidi found by pkg-config.")
+ target_link_libraries(OPL3BankEditor PUBLIC ${RTMIDI_LDFLAGS})
+ target_include_directories(OPL3BankEditor PUBLIC ${RTMIDI_INCLUDE_DIRS})
+ target_compile_options(OPL3BankEditor PUBLIC ${RTMIDI_CFLAGS})
+ endif()
endif()
+
+ if(NOT RTMIDI_FOUND)
+ find_library(RTMIDI_LIBRARY "rtmidi")
+ find_path(RTMIDI_INCLUDE_DIRS "RtMidi.h")
+ message("RtMidi library: ${RTMIDI_LIBRARY}")
+ message("RtMidi header directory: ${RTMIDI_INCLUDE_DIRS}")
+ if(NOT RTMIDI_LIBRARY-NOTFOUND AND NOT RTMIDI_INCLUDE_DIRS STREQUAL RTMIDI_INCLUDE_DIRS-NOTFOUND)
+ message("Using system-installed RtMidi.")
+ set(RTMIDI_FOUND TRUE)
+ target_link_libraries(OPL3BankEditor PUBLIC ${RTMIDI_LIBRARY})
+ target_include_directories(OPL3BankEditor PUBLIC ${RTMIDI_INCLUDE_DIRS})
+ endif()
+ endif()
+
+ if(NOT RTMIDI_FOUND)
+ message("Using bundled RtMidi.")
+ add_library(RtMidi STATIC "src/midi/external/rtmidi/RtMidi.cpp")
+ target_include_directories(RtMidi PUBLIC "src/midi/external/rtmidi")
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ target_compile_definitions(RtMidi PUBLIC "__LINUX_ALSA__")
+ target_link_libraries(RtMidi PUBLIC "asound")
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ target_compile_definitions(RtMidi PUBLIC "__WINDOWS_MM__")
+ target_link_libraries(RtMidi PUBLIC "winmm")
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ target_compile_definitions(RtMidi PUBLIC "__MACOSX_CORE__")
+ find_library(COREMIDI_LIBRARY "CoreMIDI")
+ target_link_libraries(RtMidi PUBLIC "${COREMIDI_LIBRARY}")
+ endif()
+ target_link_libraries(OPL3BankEditor PRIVATE RtMidi)
+ endif()
+
target_sources(OPL3BankEditor PRIVATE "src/midi/midi_rtmidi.cpp")
target_compile_definitions(OPL3BankEditor PRIVATE "ENABLE_MIDI")
- target_link_libraries(OPL3BankEditor PRIVATE RtMidi)
endif()
if(USE_RTAUDIO)
- add_library(RtAudio STATIC "src/audio/external/rtaudio/RtAudio.cpp")
- target_include_directories(RtAudio PUBLIC "src/audio/external/rtaudio")
- if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- target_compile_definitions(RtAudio PUBLIC "__LINUX_ALSA__")
- target_link_libraries(RtAudio PUBLIC "asound")
- if(JACK_FOUND)
- target_compile_definitions(RtAudio PUBLIC "__UNIX_JACK__")
- target_include_directories(RtAudio PUBLIC ${JACK_INCLUDE_DIRS})
- link_directories(${JACK_LIBRARY_DIRS})
- target_link_libraries(RtAudio PUBLIC ${JACK_LIBRARIES})
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(RTAUDIO rtaudio)
+ if(RTAUDIO_FOUND)
+ message("Using system-installed RtAudio found by pkg-config.")
+ target_link_libraries(OPL3BankEditor PUBLIC ${RTAUDIO_LDFLAGS})
+ target_include_directories(OPL3BankEditor PUBLIC ${RTAUDIO_INCLUDE_DIRS})
+ target_compile_options(OPL3BankEditor PUBLIC ${RTAUDIO_CFLAGS})
+ endif()
+ endif()
+
+ if(NOT RTAUDIO_FOUND)
+ find_library(RTAUDIO_LIBRARY "rtaudio")
+ find_path(RTAUDIO_INCLUDE_DIRS "RtAudio.h")
+ message("RtAudio library: ${RTAUDIO_LIBRARY}")
+ message("RtAudio header directory: ${RTAUDIO_INCLUDE_DIRS}")
+ if(NOT RTAUDIO_LIBRARY-NOTFOUND AND NOT RTAUDIO_INCLUDE_DIRS STREQUAL RTAUDIO_INCLUDE_DIRS-NOTFOUND)
+ message("Using system-installed RtAudio.")
+ set(RTAUDIO_FOUND TRUE)
+ target_link_libraries(OPL3BankEditor PUBLIC ${RTAUDIO_LIBRARY})
+ target_include_directories(OPL3BankEditor PUBLIC ${RTAUDIO_INCLUDE_DIRS})
endif()
- if(PULSEAUDIO_FOUND)
- target_compile_definitions(RtAudio PUBLIC "__LINUX_PULSE__")
- target_include_directories(RtAudio PUBLIC ${PULSEAUDIO_INCLUDE_DIRS})
- link_directories(${PULSEAUDIO_LIBRARY_DIRS})
- target_link_libraries(RtAudio PUBLIC ${PULSEAUDIO_LIBRARIES})
+ endif()
+
+ if(NOT RTAUDIO_FOUND)
+ message("Using bundled RtAudio.")
+ add_library(RtAudio STATIC "src/audio/external/rtaudio/RtAudio.cpp")
+ target_include_directories(RtAudio PUBLIC "src/audio/external/rtaudio")
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ target_compile_definitions(RtAudio PUBLIC "__LINUX_ALSA__")
+ target_link_libraries(RtAudio PUBLIC "asound")
+ if(JACK_FOUND)
+ target_compile_definitions(RtAudio PUBLIC "__UNIX_JACK__")
+ target_include_directories(RtAudio PUBLIC ${JACK_INCLUDE_DIRS})
+ link_directories(${JACK_LIBRARY_DIRS})
+ target_link_libraries(RtAudio PUBLIC ${JACK_LIBRARIES})
+ endif()
+ if(PULSEAUDIO_FOUND)
+ target_compile_definitions(RtAudio PUBLIC "__LINUX_PULSE__")
+ target_include_directories(RtAudio PUBLIC ${PULSEAUDIO_INCLUDE_DIRS})
+ link_directories(${PULSEAUDIO_LIBRARY_DIRS})
+ target_link_libraries(RtAudio PUBLIC ${PULSEAUDIO_LIBRARIES})
+ endif()
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ target_compile_definitions(RtAudio PUBLIC "__WINDOWS_DS__")
+ target_link_libraries(RtAudio PUBLIC "dsound" "ole32")
+ target_compile_definitions(RtAudio PUBLIC "__WINDOWS_WASAPI__")
+ target_link_libraries(RtAudio PUBLIC "ksguid")
+ target_compile_definitions(RtAudio PUBLIC "__WINDOWS_ASIO__")
+ target_include_directories(RtAudio PRIVATE
+ "src/audio/external/rtaudio/include")
+ target_sources(RtAudio PRIVATE
+ "src/audio/external/rtaudio/include/asio.cpp"
+ "src/audio/external/rtaudio/include/asiodrivers.cpp"
+ "src/audio/external/rtaudio/include/asiolist.cpp"
+ "src/audio/external/rtaudio/include/iasiothiscallresolver.cpp")
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ target_compile_definitions(RtAudio PUBLIC "__MACOSX_CORE__")
+ find_library(COREAUDIO_LIBRARY "CoreAudio")
+ target_link_libraries(RtAudio PUBLIC "${COREAUDIO_LIBRARY}")
+ find_library(COREFOUNDATION_LIBRARY "CoreFoundation")
+ target_link_libraries(RtAudio PUBLIC "${COREFOUNDATION_LIBRARY}")
endif()
- elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- target_compile_definitions(RtAudio PUBLIC "__WINDOWS_DS__")
- target_link_libraries(RtAudio PUBLIC "dsound" "ole32")
- target_compile_definitions(RtAudio PUBLIC "__WINDOWS_WASAPI__")
- target_link_libraries(RtAudio PUBLIC "ksguid")
- target_compile_definitions(RtAudio PUBLIC "__WINDOWS_ASIO__")
- target_include_directories(RtAudio PRIVATE
- "src/audio/external/rtaudio/include")
- target_sources(RtAudio PRIVATE
- "src/audio/external/rtaudio/include/asio.cpp"
- "src/audio/external/rtaudio/include/asiodrivers.cpp"
- "src/audio/external/rtaudio/include/asiolist.cpp"
- "src/audio/external/rtaudio/include/iasiothiscallresolver.cpp")
- elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- target_compile_definitions(RtAudio PUBLIC "__MACOSX_CORE__")
- find_library(COREAUDIO_LIBRARY "CoreAudio")
- target_link_libraries(RtAudio PUBLIC "${COREAUDIO_LIBRARY}")
- find_library(COREFOUNDATION_LIBRARY "CoreFoundation")
- target_link_libraries(RtAudio PUBLIC "${COREFOUNDATION_LIBRARY}")
+ target_link_libraries(OPL3BankEditor PRIVATE RtAudio)
endif()
+
target_sources(OPL3BankEditor PRIVATE "src/audio/ao_rtaudio.cpp")
target_compile_definitions(OPL3BankEditor PRIVATE "ENABLE_AUDIO_TESTING")
- target_link_libraries(OPL3BankEditor PRIVATE RtAudio)
endif()
add_executable(measurer_tool
--
2.29.3