Skip to content

Commit 3ce3844

Browse files
committed
Standalone using wrapper
Work started by @jpcima in sfztools/sfizz#848 adapted after repository split with newer VST3 SDK
1 parent bfad651 commit 3ce3844

27 files changed

+5436
-27
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ option_ex(PLUGIN_LV2_UI "Enable LV2 plug-in user interface" ON)
3737
option_ex(PLUGIN_PUREDATA "Enable Puredata plug-in build" OFF)
3838
option_ex(PLUGIN_VST2 "Enable VST2 plug-in build (unsupported)" OFF)
3939
option_ex(PLUGIN_VST3 "Enable VST3 plug-in build" ON)
40+
option_ex(SFIZZ_STANDALONE "Enable standalone build" OFF)
4041
option_ex(SFIZZ_USE_SYSTEM_LV2 "Use LV2 headers preinstalled on system" OFF)
4142
option_ex(SFIZZ_USE_SYSTEM_VST3SDK "Use VST3SDK source files preinstalled on system" OFF)
4243

@@ -52,13 +53,17 @@ if(WIN32)
5253
endif()
5354

5455
# Override sfizz CXX standard since vstgui requires 17 anyway
55-
if (PLUGIN_AU OR PLUGIN_LV2_UI OR PLUGIN_VST3 OR PLUGIN_VST2)
56+
if (PLUGIN_AU OR PLUGIN_LV2_UI OR PLUGIN_VST3 OR PLUGIN_VST2 OR SFIZZ_STANDALONE)
5657
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used")
5758
endif()
5859

5960
include(SfizzConfig) # Re-used for this project
6061
include(BundleDylibs)
6162

63+
if(SFIZZ_STANDALONE)
64+
include(StandaloneDeps)
65+
endif()
66+
6267
add_subdirectory(library)
6368
add_subdirectory(plugins)
6469

cmake/StandaloneDeps.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Find Linux system libraries
2+
add_library(dl INTERFACE)
3+
4+
if(NOT WIN32 AND NOT APPLE)
5+
find_library(DL_LIBRARY "dl")
6+
target_link_libraries(dl INTERFACE "${DL_LIBRARY}")
7+
8+
# JACK
9+
find_package(PkgConfig REQUIRED)
10+
pkg_check_modules(JACK "jack" REQUIRED)
11+
12+
# The X11 library
13+
find_package(X11 REQUIRED)
14+
add_library(sfizz_x11 INTERFACE)
15+
target_include_directories(sfizz_x11 INTERFACE "${X11_INCLUDE_DIR}")
16+
target_link_libraries(sfizz_x11 INTERFACE "${X11_X11_LIB}")
17+
add_library(sfizz::x11 ALIAS sfizz_x11)
18+
19+
# The GtkMM library
20+
find_package(PkgConfig REQUIRED)
21+
pkg_check_modules(GTKMM "gtkmm-3.0" REQUIRED)
22+
add_library(sfizz_gtkmm INTERFACE)
23+
target_include_directories(sfizz_gtkmm INTERFACE ${GTKMM_INCLUDE_DIRS})
24+
target_link_libraries(sfizz_gtkmm INTERFACE ${GTKMM_LIBRARIES})
25+
link_libraries(${GTKMM_LIBRARY_DIRS})
26+
add_library(sfizz::gtkmm ALIAS sfizz_gtkmm)
27+
endif()
28+
29+
add_library(sfizz::dl ALIAS dl)

plugins/vst/CMakeLists.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,76 @@ if(PLUGIN_VST2)
374374
endif()
375375
endif()
376376
endif()
377+
378+
# --- Standalone program --- #
379+
380+
if(SFIZZ_STANDALONE)
381+
set(SOURCES_STANDALONE
382+
standalone/standalonehost.h
383+
standalone/standalonehost.cpp
384+
standalone/media/audioclient.h
385+
standalone/media/imediaserver.h
386+
standalone/media/iparameterclient.h
387+
standalone/media/miditovst.h
388+
standalone/media/audioclient.cpp
389+
standalone/platform/appinit.h
390+
standalone/platform/iapplication.h
391+
standalone/platform/iplatform.h
392+
standalone/platform/iwindow.h
393+
)
394+
set(SOURCES_STANDALONE_WIN32
395+
standalone/platform/win32/platform.cpp
396+
standalone/platform/win32/window.h
397+
standalone/platform/win32/window.cpp
398+
)
399+
set(SOURCES_STANDALONE_MACOS
400+
standalone/platform/mac/platform.mm
401+
standalone/platform/mac/window.h
402+
standalone/platform/mac/window.mm
403+
)
404+
set(SOURCES_STANDALONE_UNIX
405+
standalone/media/jack/jackclient.cpp
406+
standalone/platform/linux/platform.cpp
407+
# Was used for X11 version
408+
# standalone/platform/linux/runloop.h
409+
# standalone/platform/linux/runloop.cpp
410+
standalone/platform/linux/window.h
411+
standalone/platform/linux/window.cpp
412+
)
413+
source_group("Sources" FILES
414+
${SOURCES_STANDALONE}
415+
${SOURCES_STANDALONE_WIN32}
416+
${SOURCES_STANDALONE_MACOS}
417+
${SOURCES_STANDALONE_UNIX}
418+
)
419+
set_source_files_properties(
420+
standalone/platform/mac/window.mm
421+
standalone/platform/mac/platform.mm
422+
PROPERTIES
423+
COMPILE_FLAGS "-fobjc-arc"
424+
)
425+
add_executable(sfizz_standalone WIN32
426+
${SOURCES_STANDALONE}
427+
)
428+
set_target_properties(sfizz_standalone PROPERTIES
429+
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/$<0:>"
430+
)
431+
target_include_directories(sfizz_standalone PRIVATE "standalone" "${CMAKE_CURRENT_BINARY_DIR}")
432+
target_link_libraries(sfizz_standalone PRIVATE vst3sdk_hosting sfizz::filesystem)
433+
if(WIN32)
434+
target_sources(sfizz_standalone PRIVATE ${SOURCES_STANDALONE_WIN32}
435+
)
436+
elseif(APPLE)
437+
target_sources(sfizz_standalone PRIVATE ${SOURCES_STANDALONE_MACOS})
438+
target_link_libraries(sfizz_standalone PRIVATE "${APPLE_COCOA_LIBRARY}")
439+
else()
440+
target_sources(sfizz_standalone PRIVATE ${SOURCES_STANDALONE_UNIX})
441+
target_compile_definitions(sfizz_standalone PRIVATE "EDITORHOST_GTK=1")
442+
target_link_libraries(sfizz_standalone PRIVATE
443+
sfizz::jack
444+
sfizz::gtkmm
445+
sfizz::x11
446+
)
447+
endif()
448+
install(TARGETS sfizz_standalone DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT "standalone")
449+
endif()

plugins/vst/cmake/Vst3.cmake

Lines changed: 99 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,36 @@ add_library(vst3sdk STATIC EXCLUDE_FROM_ALL
3131
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstparameters.cpp"
3232
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstpresetfile.cpp"
3333
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstrepresentation.cpp"
34-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/utility/stringconvert.cpp")
34+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/utility/stringconvert.cpp"
35+
)
3536
if(WIN32)
3637
target_sources(vst3sdk PRIVATE
37-
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp")
38+
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp"
39+
)
3840
elseif(APPLE)
3941
target_sources(vst3sdk PRIVATE
40-
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_mac.mm")
42+
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_mac.mm"
43+
)
4144
else()
4245
target_sources(vst3sdk PRIVATE
43-
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_linux.cpp")
46+
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_linux.cpp"
47+
)
4448
endif()
4549
target_include_directories(vst3sdk PUBLIC "${VST3SDK_BASEDIR}")
4650
target_link_libraries(vst3sdk PUBLIC Threads::Threads)
51+
4752
if(APPLE)
4853
target_link_libraries(vst3sdk PUBLIC ${APPLE_FOUNDATION_LIBRARY})
4954
endif()
55+
5056
if(MINGW)
5157
target_compile_definitions(vst3sdk PUBLIC
52-
"_NATIVE_WCHAR_T_DEFINED=1" "__wchar_t=wchar_t")
58+
"_NATIVE_WCHAR_T_DEFINED=1" "__wchar_t=wchar_t"
59+
)
5360
endif()
61+
5462
set(_vst_release_build_types MinSizeRel Release RelWithDebInfo)
63+
5564
if(CMAKE_BUILD_TYPE IN_LIST _vst_release_build_types)
5665
target_compile_definitions(vst3sdk PUBLIC "RELEASE")
5766
else()
@@ -62,50 +71,112 @@ function(plugin_add_vst3sdk NAME)
6271
target_link_libraries("${NAME}" PRIVATE vst3sdk)
6372
target_sources("${NAME}" PRIVATE
6473
"${VST3SDK_BASEDIR}/public.sdk/source/main/moduleinit.cpp"
65-
"${VST3SDK_BASEDIR}/public.sdk/source/main/pluginfactory.cpp")
74+
"${VST3SDK_BASEDIR}/public.sdk/source/main/pluginfactory.cpp"
75+
)
6676
if(WIN32)
6777
target_sources("${NAME}" PRIVATE
68-
"${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp")
78+
"${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp"
79+
)
6980
elseif(APPLE)
7081
target_sources("${NAME}" PRIVATE
71-
"${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp")
82+
"${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp"
83+
)
7284
else()
7385
target_sources("${NAME}" PRIVATE
74-
"${VST3SDK_BASEDIR}/public.sdk/source/main/linuxmain.cpp")
86+
"${VST3SDK_BASEDIR}/public.sdk/source/main/linuxmain.cpp"
87+
)
7588
endif()
7689
endfunction()
7790

7891
# --- VST3SDK hosting ---
92+
93+
# Find C++ filesystem
94+
function(sfizz_find_std_fs TARGET)
95+
add_library("${TARGET}" INTERFACE)
96+
97+
set(_fs_src
98+
"#include <filesystem>
99+
int main() { return std::filesystem::exists(\"myfile\") ? 0 : 1; }")
100+
set(_expfs_src
101+
"#include <experimental/filesystem>
102+
int main() { return std::experimental::filesystem::exists(\"myfile\") ? 0 : 1; }")
103+
104+
check_cxx_source_compiles("${_fs_src}" HAVE_STDFS_DIRECT)
105+
check_cxx_source_compiles("${_expfs_src}" HAVE_STDFS_EXPERIMENTAL_DIRECT)
106+
if(HAVE_STDFS_DIRECT OR HAVE_STDFS_EXPERIMENTAL_DIRECT)
107+
return()
108+
endif()
109+
110+
find_library(STDCPPFS_LIBRARY "stdc++fs")
111+
if(STDCPPFS_LIBRARY)
112+
set(CMAKE_REQUIRED_LIBRARIES "${STDCPPFS_LIBRARY}")
113+
check_cxx_source_compiles("${_fs_src}" HAVE_STDFS_LIBSTDCPPFS)
114+
check_cxx_source_compiles("${_expfs_src}" HAVE_STDFS_EXPERIMENTAL_LIBSTDCPPFS)
115+
if(HAVE_STDFS_LIBSTDCPPFS OR HAVE_STDFS_EXPERIMENTAL_LIBSTDCPPFS)
116+
target_link_libraries("${TARGET}" INTERFACE "${STDCPPFS_LIBRARY}")
117+
return()
118+
endif()
119+
endif()
120+
121+
find_library(CPPFS_LIBRARY "c++fs")
122+
if(CPPFS_LIBRARY)
123+
set(CMAKE_REQUIRED_LIBRARIES "${CPPFS_LIBRARY}")
124+
check_cxx_source_compiles("${_fs_src}" HAVE_STDFS_STDCPPFS)
125+
check_cxx_source_compiles("${_expfs_src}" HAVE_STDFS_EXPERIMENTAL_STDCPPFS)
126+
if(HAVE_STDFS_STDCPPFS OR HAVE_STDFS_EXPERIMENTAL_STDCPPFS)
127+
target_link_libraries("${TARGET}" INTERFACE "${CPPFS_LIBRARY}")
128+
return()
129+
endif()
130+
endif()
131+
endfunction()
132+
sfizz_find_std_fs(stdfs)
133+
add_library(sfizz::stdfs ALIAS stdfs)
134+
79135
add_library(vst3sdk_hosting STATIC EXCLUDE_FROM_ALL
80136
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/connectionproxy.cpp"
81137
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/eventlist.cpp"
82138
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/hostclasses.cpp"
139+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module.cpp"
83140
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/parameterchanges.cpp"
84141
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/pluginterfacesupport.cpp"
85142
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/plugprovider.cpp"
86-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/processdata.cpp")
87-
if(FALSE)
88-
if(WIN32)
89-
target_sources(vst3sdk_hosting PRIVATE
90-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_win32.cpp")
91-
elseif(APPLE)
92-
target_sources(vst3sdk_hosting PRIVATE
93-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_mac.mm")
94-
else()
95-
target_sources(vst3sdk_hosting PRIVATE
96-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_linux.cpp")
97-
endif()
143+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/processdata.cpp"
144+
)
145+
if(WIN32)
146+
target_sources(vst3sdk_hosting PRIVATE
147+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_win32.cpp"
148+
)
149+
elseif(APPLE)
150+
target_sources(vst3sdk_hosting PRIVATE
151+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_mac.mm"
152+
)
153+
set_source_files_properties(
154+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_mac.mm"
155+
PROPERTIES
156+
COMPILE_FLAGS "-fobjc-arc"
157+
)
158+
else()
159+
target_sources(vst3sdk_hosting PRIVATE
160+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_linux.cpp"
161+
)
98162
endif()
99-
target_link_libraries(vst3sdk_hosting PUBLIC vst3sdk)
100163

164+
target_link_libraries(vst3sdk_hosting
165+
PUBLIC vst3sdk
166+
PRIVATE sfizz::stdfs
167+
)
101168
# --- VSTGUI ---
169+
102170
add_library(vst3sdk_vstgui STATIC EXCLUDE_FROM_ALL
103-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstguieditor.cpp")
171+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstguieditor.cpp"
172+
)
104173
if(WIN32)
105174
target_sources(vst3sdk_vstgui PRIVATE
106-
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstgui_win32_bundle_support.cpp")
175+
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstgui_win32_bundle_support.cpp"
176+
)
107177
target_compile_definitions(vst3sdk_vstgui PRIVATE "SMTG_MODULE_IS_BUNDLE=1")
108178
endif()
179+
109180
target_link_libraries(vst3sdk_vstgui PUBLIC vst3sdk sfizz::vstgui)
110181

111182
function(plugin_add_vstgui NAME)
@@ -116,7 +187,8 @@ endfunction()
116187
foreach(_target vst3sdk_vstgui vst3sdk)
117188
gw_target_warn("${_target}" PUBLIC
118189
"-Wno-extra"
119-
"-Wno-class-memaccess")
190+
"-Wno-class-memaccess"
191+
)
120192
gw_target_warn("${_target}" PRIVATE
121193
"-Wno-multichar"
122194
"-Wno-reorder"
@@ -125,5 +197,6 @@ foreach(_target vst3sdk_vstgui vst3sdk)
125197
"-Wno-unknown-pragmas"
126198
"-Wno-unused-function"
127199
"-Wno-unused-parameter"
128-
"-Wno-unused-variable")
200+
"-Wno-unused-variable"
201+
)
129202
endforeach()

0 commit comments

Comments
 (0)