Skip to content

Commit

Permalink
More cmake webview build fixes
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 17, 2024
1 parent 52c2e78 commit cab7f3a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ifeq ($(HAVE_CAIRO),true)
endif
ifeq ($(HAVE_DGL),true)
$(MAKE) all -C examples/EmbedExternalUI
$(MAKE) all -C examples/WebMeters
endif

ifeq ($(CAN_GENERATE_TTL),true)
Expand Down Expand Up @@ -68,6 +69,7 @@ clean:
$(MAKE) clean -C examples/Parameters
$(MAKE) clean -C examples/SendNote
$(MAKE) clean -C examples/States
$(MAKE) clean -C examples/WebMeters
$(MAKE) clean -C utils/lv2-ttl-generator
rm -rf bin build

Expand Down
7 changes: 2 additions & 5 deletions Makefile.plugins.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ endif
# Check for proper UI_TYPE parameter

ifeq ($(UI_TYPE),)
else ifeq ($(UI_TYPE),generic)
else ifeq ($(UI_TYPE),external)
else ifeq ($(UI_TYPE),cairo)
else ifeq ($(UI_TYPE),external)
else ifeq ($(UI_TYPE),generic)
else ifeq ($(UI_TYPE),opengl)
else ifeq ($(UI_TYPE),opengl3)
USE_OPENGL3 = true
Expand Down Expand Up @@ -512,9 +512,6 @@ $(DGL_BUILD_DIR)/libdgl-stub.a: $(DGL_POSSIBLE_DEPS)
$(DGL_BUILD_DIR)/libdgl-vulkan.a: $(DGL_POSSIBLE_DEPS)
$(MAKE) -C $(DPF_PATH)/dgl vulkan

$(DGL_BUILD_DIR)/libdgl-web.a: $(DGL_POSSIBLE_DEPS)
$(MAKE) -C $(DPF_PATH)/dgl web

# ---------------------------------------------------------------------------------------------------------------------

$(BUILD_DIR)/DistrhoPluginMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp $(EXTRA_DEPENDENCIES) $(EXTRA_DSP_DEPENDENCIES)
Expand Down
38 changes: 25 additions & 13 deletions cmake/DPF-plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,15 @@ function(dpf_add_plugin NAME)
target_link_libraries("${NAME}-ui" PUBLIC "${NAME}" ${_dgl_library})
if((NOT WIN32) AND (NOT APPLE) AND (NOT HAIKU))
target_link_libraries("${NAME}-ui" PRIVATE "dl")
if(_dpf_plugin_USE_WEB_VIEW)
if(LINUX AND _dpf_plugin_USE_WEB_VIEW)
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-file-name=Scrt1.o
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE _dpf_plugin_shared_crt)
target_link_libraries("${NAME}-ui" PRIVATE "rt")
endif()
endif()
# add the files containing C++17 or Objective-C classes
dpf__add_plugin_specific_ui_sources("${NAME}-ui" $<BOOL:${_dpf_plugin_USE_WEB_VIEW}>)
dpf__add_plugin_specific_ui_sources("${NAME}-ui" "${_dpf_plugin_USE_WEB_VIEW}")
else()
add_library("${NAME}-ui" INTERFACE)
endif()
Expand All @@ -212,13 +215,13 @@ function(dpf_add_plugin NAME)
elseif(_target STREQUAL "dssi")
dpf__build_dssi("${NAME}" "${_dgl_has_ui}")
elseif(_target STREQUAL "lv2")
dpf__build_lv2("${NAME}" "${_dgl_has_ui}" "${_dpf_plugin_MONOLITHIC}")
dpf__build_lv2("${NAME}" "${_dgl_has_ui}" "${_dpf_plugin_MONOLITHIC}" "${_dpf_plugin_shared_crt}")
elseif(_target STREQUAL "vst2")
dpf__build_vst2("${NAME}" "${_dgl_has_ui}")
dpf__build_vst2("${NAME}" "${_dgl_has_ui}" "${_dpf_plugin_shared_crt}")
elseif(_target STREQUAL "vst3")
dpf__build_vst3("${NAME}" "${_dgl_has_ui}")
dpf__build_vst3("${NAME}" "${_dgl_has_ui}" "${_dpf_plugin_shared_crt}")
elseif(_target STREQUAL "clap")
dpf__build_clap("${NAME}" "${_dgl_has_ui}")
dpf__build_clap("${NAME}" "${_dgl_has_ui}" "${_dpf_plugin_shared_crt}")
elseif(_target STREQUAL "au")
if (APPLE)
dpf__build_au("${NAME}" "${_dgl_has_ui}")
Expand Down Expand Up @@ -372,7 +375,7 @@ endfunction()
#
# Add build rules for an LV2 plugin.
#
function(dpf__build_lv2 NAME HAS_UI MONOLITHIC)
function(dpf__build_lv2 NAME HAS_UI MONOLITHIC EXTRA_UI_LINK_OPTS)
dpf__create_dummy_source_list(_no_srcs)

dpf__add_module("${NAME}-lv2" ${_no_srcs})
Expand All @@ -393,12 +396,14 @@ function(dpf__build_lv2 NAME HAS_UI MONOLITHIC)
if(MONOLITHIC)
dpf__add_ui_main("${NAME}-lv2" "lv2" "${HAS_UI}")
target_link_libraries("${NAME}-lv2" PRIVATE "${NAME}-ui")
target_link_options("${NAME}-lv2" PRIVATE "${EXTRA_UI_LINK_OPTS}")
set_target_properties("${NAME}-lv2" PROPERTIES
OUTPUT_NAME "${NAME}")
else()
dpf__add_module("${NAME}-lv2-ui" ${_no_srcs})
dpf__add_ui_main("${NAME}-lv2-ui" "lv2" "${HAS_UI}")
dpf__set_module_export_list("${NAME}-lv2-ui" "lv2-ui")
target_link_options("${NAME}-lv2-ui" PRIVATE "${EXTRA_UI_LINK_OPTS}")
target_link_libraries("${NAME}-lv2-ui" PRIVATE "${NAME}-ui")
set_target_properties("${NAME}-lv2-ui" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NAME}.lv2/$<0:>"
Expand Down Expand Up @@ -427,14 +432,15 @@ endfunction()
#
# Add build rules for a VST2 plugin.
#
function(dpf__build_vst2 NAME HAS_UI)
function(dpf__build_vst2 NAME HAS_UI EXTRA_UI_LINK_OPTS)
dpf__create_dummy_source_list(_no_srcs)

dpf__add_module("${NAME}-vst2" ${_no_srcs})
dpf__add_plugin_main("${NAME}-vst2" "vst2")
dpf__add_ui_main("${NAME}-vst2" "vst2" "${HAS_UI}")
dpf__set_module_export_list("${NAME}-vst2" "vst2")
target_link_libraries("${NAME}-vst2" PRIVATE "${NAME}-dsp" "${NAME}-ui")
target_link_options("${NAME}-vst2" PRIVATE "${EXTRA_UI_LINK_OPTS}")
set_target_properties("${NAME}-vst2" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/$<0:>"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/obj/vst2/$<0:>"
Expand Down Expand Up @@ -505,7 +511,7 @@ endfunction()
#
# Add build rules for a VST3 plugin.
#
function(dpf__build_vst3 NAME HAS_UI)
function(dpf__build_vst3 NAME HAS_UI EXTRA_UI_LINK_OPTS)
dpf__determine_vst3_package_architecture(vst3_arch)

dpf__create_dummy_source_list(_no_srcs)
Expand All @@ -515,6 +521,7 @@ function(dpf__build_vst3 NAME HAS_UI)
dpf__add_ui_main("${NAME}-vst3" "vst3" "${HAS_UI}")
dpf__set_module_export_list("${NAME}-vst3" "vst3")
target_link_libraries("${NAME}-vst3" PRIVATE "${NAME}-dsp" "${NAME}-ui")
target_link_options("${NAME}-vst3" PRIVATE "${EXTRA_UI_LINK_OPTS}")
set_target_properties("${NAME}-vst3" PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/obj/vst3/$<0:>"
OUTPUT_NAME "${NAME}"
Expand Down Expand Up @@ -547,14 +554,15 @@ endfunction()
#
# Add build rules for a CLAP plugin.
#
function(dpf__build_clap NAME HAS_UI)
function(dpf__build_clap NAME HAS_UI EXTRA_UI_LINK_OPTS)
dpf__create_dummy_source_list(_no_srcs)

dpf__add_module("${NAME}-clap" ${_no_srcs})
dpf__add_plugin_main("${NAME}-clap" "clap")
dpf__add_ui_main("${NAME}-clap" "clap" "${HAS_UI}")
dpf__set_module_export_list("${NAME}-clap" "clap")
target_link_libraries("${NAME}-clap" PRIVATE "${NAME}-dsp" "${NAME}-ui")
target_link_options("${NAME}-clap" PRIVATE "${EXTRA_UI_LINK_OPTS}")
set_target_properties("${NAME}-clap" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/$<0:>"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/obj/clap/$<0:>"
Expand Down Expand Up @@ -983,15 +991,15 @@ endfunction()
# dpf__add_plugin_specific_ui_sources
# ------------------------------------------------------------------------------
#
# Compile system specific files, for now it is just Objective-C code
# Compile system specific files
#
function(dpf__add_plugin_specific_ui_sources NAME USE_WEB_VIEW)
if(APPLE)
target_sources("${NAME}" PRIVATE
"${DPF_ROOT_DIR}/distrho/DistrhoUI_macOS.mm")
if (USE_WEB_VIEW)
if(USE_WEB_VIEW)
find_library(APPLE_WEBKIT_FRAMEWORK "WebKit")
target_link_libraries(dgl-system-libs INTERFACE "${APPLE_WEBKIT_FRAMEWORK}")
target_link_libraries("${NAME}" PRIVATE "${APPLE_WEBKIT_FRAMEWORK}")
endif()
elseif(WIN32 AND USE_WEB_VIEW)
target_sources("${NAME}" PRIVATE
Expand All @@ -1003,6 +1011,7 @@ function(dpf__add_plugin_specific_ui_sources NAME USE_WEB_VIEW)
set_source_files_properties("${DPF_ROOT_DIR}/distrho/DistrhoUI_win32.cpp"
PROPERTIES COMPILE_FLAGS -std=gnu++17)
endif()
target_link_libraries("${NAME}" PRIVATE "ole32" "uuid")
endif()
endfunction()

Expand Down Expand Up @@ -1154,6 +1163,9 @@ function(dpf__set_target_defaults NAME)
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options("${NAME}" PUBLIC "-fno-gnu-unique")
endif()
if ((NOT APPLE) AND (NOT MSVC))
target_link_options("${NAME}" PUBLIC "-Wl,--no-undefined")
endif()
endfunction()

# dpf__add_plugin_main
Expand Down
13 changes: 13 additions & 0 deletions distrho/DistrhoUIMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@
# define DISTRHO_IS_STANDALONE 0
# endif
# include "src/DistrhoUtils.cpp"
#else
# ifdef DISTRHO_PLUGIN_TARGET_JACK
# define DISTRHO_IS_STANDALONE 1
# else
# define DISTRHO_IS_STANDALONE 0
# endif
#endif

#if defined(DPF_USING_LD_LINUX_WEBVIEW) && !DISTRHO_IS_STANDALONE
int main(int argc, char* argv[])
{
return DISTRHO_NAMESPACE::dpf_webview_start(argc, argv);
}
#endif

#endif
8 changes: 6 additions & 2 deletions distrho/src/DistrhoPluginChecks.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
# error typo detected use DGL_USE_FILE_BROWSER instead of DISTRHO_UI_FILEBROWSER
#endif

#ifdef DISTRHO_UI_WEBVIEW
# error typo detected use DISTRHO_UI_WEB_VIEW instead of DISTRHO_UI_WEBVIEW
#endif

#ifdef DISTRHO_UI_USE_WEBVIEW
# error typo detected use DISTRHO_UI_USE_WEB_VIEW instead of DISTRHO_UI_USE_WEBVIEW
#endif
Expand All @@ -163,7 +167,7 @@
# error invalid build config: file browser requested but `USE_FILE_BROWSER` build option is not set
#endif

#if DISTRHO_UI_USE_WEB_VIEW && !defined(DGL_USE_WEB_VIEW)
#if DISTRHO_UI_WEB_VIEW && !defined(DGL_USE_WEB_VIEW)
# error invalid build config: web view requested but `USE_WEB_VIEW` build option is not set
#endif

Expand Down Expand Up @@ -278,7 +282,7 @@ static_assert(sizeof(STRINGIFY(DISTRHO_PLUGIN_UNIQUE_ID)) == 5, "The macro DISTR
// --------------------------------------------------------------------------------------------------------------------
// Set DPF_USING_LD_LINUX_WEBVIEW for internal use

#if DISTRHO_UI_WEB_VIEW && defined(__linux__)
#if DISTRHO_UI_WEB_VIEW && defined(DISTRHO_OS_LINUX)
# define DPF_USING_LD_LINUX_WEBVIEW
#endif

Expand Down
7 changes: 0 additions & 7 deletions distrho/src/DistrhoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,3 @@ int dpf_webview_start(int argc, char* argv[]);
// --------------------------------------------------------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#if defined(DPF_USING_LD_LINUX_WEBVIEW) && !DISTRHO_IS_STANDALONE
int main(int argc, char* argv[])
{
return DISTRHO_NAMESPACE::dpf_webview_start(argc, argv);
}
#endif
1 change: 1 addition & 0 deletions examples/EmbedExternalUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
dpf_add_plugin(d_embed_external_ui
TARGETS jack lv2 vst2 vst3 clap
UI_TYPE external
USE_WEB_VIEW
FILES_DSP
EmbedExternalExamplePlugin.cpp
FILES_UI
Expand Down

0 comments on commit cab7f3a

Please sign in to comment.