DISTRHO / DPF

DISTRHO Plugin Framework
ISC License
672 stars 97 forks source link

Nothing ever defines HAVE_JACK for CMake builds #382

Closed thirtythreeforty closed 2 years ago

thirtythreeforty commented 2 years ago

When building a DPF-based plugin with CMake and the dpf_add_plugin() helper, HAVE_JACK always evaluates false here:

https://github.com/DISTRHO/DPF/blob/ac545ac660cd2fcdd6a598c57111766e378ee445/distrho/src/jackbridge/JackBridge.cpp#L449

Leading to the confusing error message

Failed to create the JACK client, reason was:
Communication error with the JACK server.

(which is wrong; a better error message would indicate that we were not built with support for JACK).

This simple patch allows JACK to load in my build:

diff --git a/cmake/DPF-plugin.cmake b/cmake/DPF-plugin.cmake
index 858c49c8..949b982a 100644
--- a/cmake/DPF-plugin.cmake
+++ b/cmake/DPF-plugin.cmake
@@ -191,6 +191,7 @@ function(dpf__build_jack NAME DGL_LIBRARY)
   set_target_properties("${NAME}-jack" PROPERTIES
     RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/$<0:>"
     OUTPUT_NAME "${NAME}")
+  target_compile_definitions(${NAME}-jack PRIVATE HAVE_JACK=1)

   # for RtAudio native fallback
   if(APPLE)

however that is not a complete patch because it ought to do similar is-static detection that the existing makefile does.

falkTX commented 2 years ago

I have been doing some changes on the makefile side of things that need to be applied to cmake. It is possible to use jack in dlopen mode, or link mode or not use it at all and fallback to native audio. this is not implemented yet on cmake side.

I think I need to start a project that uses cmake to properly test these scenarios. just setting compiler flags is not enough here, the behaviour must be tweakable from the initial dpf entry point function.

falkTX commented 2 years ago

I have added this definition in 30cf55aa1570553947c0e5add45cf9e6bf4fe1e2 Would be best to make it optional the same way as the Makefile stuff, but my knowledge of cmake is limited. For now this works