Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone using wrapper #105

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ option_ex(PLUGIN_LV2_UI "Enable LV2 plug-in user interface" ON)
option_ex(PLUGIN_PUREDATA "Enable Puredata plug-in build" OFF)
option_ex(PLUGIN_VST2 "Enable VST2 plug-in build (unsupported)" OFF)
option_ex(PLUGIN_VST3 "Enable VST3 plug-in build" ON)
option_ex(SFIZZ_STANDALONE "Enable standalone build" OFF)
option_ex(SFIZZ_USE_SYSTEM_LV2 "Use LV2 headers preinstalled on system" OFF)
option_ex(SFIZZ_USE_SYSTEM_VST3SDK "Use VST3SDK source files preinstalled on system" OFF)

Expand All @@ -52,13 +53,17 @@ if(WIN32)
endif()

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

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

if(SFIZZ_STANDALONE)
include(StandaloneDeps)
endif()

add_subdirectory(library)
add_subdirectory(plugins)

Expand Down
29 changes: 29 additions & 0 deletions cmake/StandaloneDeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Find Linux system libraries
add_library(dl INTERFACE)

if(NOT WIN32 AND NOT APPLE)
find_library(DL_LIBRARY "dl")
target_link_libraries(dl INTERFACE "${DL_LIBRARY}")

# JACK
find_package(PkgConfig REQUIRED)
pkg_check_modules(JACK "jack" REQUIRED)

# The X11 library
find_package(X11 REQUIRED)
add_library(sfizz_x11 INTERFACE)
target_include_directories(sfizz_x11 INTERFACE "${X11_INCLUDE_DIR}")
target_link_libraries(sfizz_x11 INTERFACE "${X11_X11_LIB}")
add_library(sfizz::x11 ALIAS sfizz_x11)

# The GtkMM library
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM "gtkmm-3.0" REQUIRED)
add_library(sfizz_gtkmm INTERFACE)
target_include_directories(sfizz_gtkmm INTERFACE ${GTKMM_INCLUDE_DIRS})
target_link_libraries(sfizz_gtkmm INTERFACE ${GTKMM_LIBRARIES})
link_libraries(${GTKMM_LIBRARY_DIRS})
add_library(sfizz::gtkmm ALIAS sfizz_gtkmm)
endif()

add_library(sfizz::dl ALIAS dl)
73 changes: 73 additions & 0 deletions plugins/vst/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,76 @@ if(PLUGIN_VST2)
endif()
endif()
endif()

# --- Standalone program --- #

if(SFIZZ_STANDALONE)
set(SOURCES_STANDALONE
standalone/standalonehost.h
standalone/standalonehost.cpp
standalone/media/audioclient.h
standalone/media/imediaserver.h
standalone/media/iparameterclient.h
standalone/media/miditovst.h
standalone/media/audioclient.cpp
standalone/platform/appinit.h
standalone/platform/iapplication.h
standalone/platform/iplatform.h
standalone/platform/iwindow.h
)
set(SOURCES_STANDALONE_WIN32
standalone/platform/win32/platform.cpp
standalone/platform/win32/window.h
standalone/platform/win32/window.cpp
)
set(SOURCES_STANDALONE_MACOS
standalone/platform/mac/platform.mm
standalone/platform/mac/window.h
standalone/platform/mac/window.mm
)
set(SOURCES_STANDALONE_UNIX
standalone/media/jack/jackclient.cpp
standalone/platform/linux/platform.cpp
# Was used for X11 version
# standalone/platform/linux/runloop.h
# standalone/platform/linux/runloop.cpp
standalone/platform/linux/window.h
standalone/platform/linux/window.cpp
)
source_group("Sources" FILES
${SOURCES_STANDALONE}
${SOURCES_STANDALONE_WIN32}
${SOURCES_STANDALONE_MACOS}
${SOURCES_STANDALONE_UNIX}
)
set_source_files_properties(
standalone/platform/mac/window.mm
standalone/platform/mac/platform.mm
PROPERTIES
COMPILE_FLAGS "-fobjc-arc"
)
add_executable(sfizz_standalone WIN32
${SOURCES_STANDALONE}
)
set_target_properties(sfizz_standalone PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/$<0:>"
)
target_include_directories(sfizz_standalone PRIVATE "standalone" "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(sfizz_standalone PRIVATE vst3sdk_hosting sfizz::filesystem)
if(WIN32)
target_sources(sfizz_standalone PRIVATE ${SOURCES_STANDALONE_WIN32}
)
elseif(APPLE)
target_sources(sfizz_standalone PRIVATE ${SOURCES_STANDALONE_MACOS})
target_link_libraries(sfizz_standalone PRIVATE "${APPLE_COCOA_LIBRARY}")
else()
target_sources(sfizz_standalone PRIVATE ${SOURCES_STANDALONE_UNIX})
target_compile_definitions(sfizz_standalone PRIVATE "EDITORHOST_GTK=1")
target_link_libraries(sfizz_standalone PRIVATE
sfizz::jack
sfizz::gtkmm
sfizz::x11
)
endif()
install(TARGETS sfizz_standalone DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT "standalone")
endif()
125 changes: 99 additions & 26 deletions plugins/vst/cmake/Vst3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,36 @@ add_library(vst3sdk STATIC EXCLUDE_FROM_ALL
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstparameters.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstpresetfile.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstrepresentation.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/utility/stringconvert.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/vst/utility/stringconvert.cpp"
)
if(WIN32)
target_sources(vst3sdk PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp"
)
elseif(APPLE)
target_sources(vst3sdk PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_mac.mm")
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_mac.mm"
)
else()
target_sources(vst3sdk PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_linux.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_linux.cpp"
)
endif()
target_include_directories(vst3sdk PUBLIC "${VST3SDK_BASEDIR}")
target_link_libraries(vst3sdk PUBLIC Threads::Threads)

if(APPLE)
target_link_libraries(vst3sdk PUBLIC ${APPLE_FOUNDATION_LIBRARY})
endif()

if(MINGW)
target_compile_definitions(vst3sdk PUBLIC
"_NATIVE_WCHAR_T_DEFINED=1" "__wchar_t=wchar_t")
"_NATIVE_WCHAR_T_DEFINED=1" "__wchar_t=wchar_t"
)
endif()

set(_vst_release_build_types MinSizeRel Release RelWithDebInfo)

if(CMAKE_BUILD_TYPE IN_LIST _vst_release_build_types)
target_compile_definitions(vst3sdk PUBLIC "RELEASE")
else()
Expand All @@ -62,50 +71,112 @@ function(plugin_add_vst3sdk NAME)
target_link_libraries("${NAME}" PRIVATE vst3sdk)
target_sources("${NAME}" PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/main/moduleinit.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/main/pluginfactory.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/main/pluginfactory.cpp"
)
if(WIN32)
target_sources("${NAME}" PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp"
)
elseif(APPLE)
target_sources("${NAME}" PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp"
)
else()
target_sources("${NAME}" PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/main/linuxmain.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/main/linuxmain.cpp"
)
endif()
endfunction()

# --- VST3SDK hosting ---

# Find C++ filesystem
function(sfizz_find_std_fs TARGET)
add_library("${TARGET}" INTERFACE)

set(_fs_src
"#include <filesystem>
int main() { return std::filesystem::exists(\"myfile\") ? 0 : 1; }")
set(_expfs_src
"#include <experimental/filesystem>
int main() { return std::experimental::filesystem::exists(\"myfile\") ? 0 : 1; }")

check_cxx_source_compiles("${_fs_src}" HAVE_STDFS_DIRECT)
check_cxx_source_compiles("${_expfs_src}" HAVE_STDFS_EXPERIMENTAL_DIRECT)
if(HAVE_STDFS_DIRECT OR HAVE_STDFS_EXPERIMENTAL_DIRECT)
return()
endif()

find_library(STDCPPFS_LIBRARY "stdc++fs")
if(STDCPPFS_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES "${STDCPPFS_LIBRARY}")
check_cxx_source_compiles("${_fs_src}" HAVE_STDFS_LIBSTDCPPFS)
check_cxx_source_compiles("${_expfs_src}" HAVE_STDFS_EXPERIMENTAL_LIBSTDCPPFS)
if(HAVE_STDFS_LIBSTDCPPFS OR HAVE_STDFS_EXPERIMENTAL_LIBSTDCPPFS)
target_link_libraries("${TARGET}" INTERFACE "${STDCPPFS_LIBRARY}")
return()
endif()
endif()

find_library(CPPFS_LIBRARY "c++fs")
if(CPPFS_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES "${CPPFS_LIBRARY}")
check_cxx_source_compiles("${_fs_src}" HAVE_STDFS_STDCPPFS)
check_cxx_source_compiles("${_expfs_src}" HAVE_STDFS_EXPERIMENTAL_STDCPPFS)
if(HAVE_STDFS_STDCPPFS OR HAVE_STDFS_EXPERIMENTAL_STDCPPFS)
target_link_libraries("${TARGET}" INTERFACE "${CPPFS_LIBRARY}")
return()
endif()
endif()
endfunction()
sfizz_find_std_fs(stdfs)
add_library(sfizz::stdfs ALIAS stdfs)

add_library(vst3sdk_hosting STATIC EXCLUDE_FROM_ALL
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/connectionproxy.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/eventlist.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/hostclasses.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/parameterchanges.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/pluginterfacesupport.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/plugprovider.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/processdata.cpp")
if(FALSE)
if(WIN32)
target_sources(vst3sdk_hosting PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_win32.cpp")
elseif(APPLE)
target_sources(vst3sdk_hosting PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_mac.mm")
else()
target_sources(vst3sdk_hosting PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_linux.cpp")
endif()
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/processdata.cpp"
)
if(WIN32)
target_sources(vst3sdk_hosting PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_win32.cpp"
)
elseif(APPLE)
target_sources(vst3sdk_hosting PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_mac.mm"
)
set_source_files_properties(
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_mac.mm"
PROPERTIES
COMPILE_FLAGS "-fobjc-arc"
)
else()
target_sources(vst3sdk_hosting PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/hosting/module_linux.cpp"
)
endif()
target_link_libraries(vst3sdk_hosting PUBLIC vst3sdk)

target_link_libraries(vst3sdk_hosting
PUBLIC vst3sdk
PRIVATE sfizz::stdfs
)
# --- VSTGUI ---

add_library(vst3sdk_vstgui STATIC EXCLUDE_FROM_ALL
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstguieditor.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstguieditor.cpp"
)
if(WIN32)
target_sources(vst3sdk_vstgui PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstgui_win32_bundle_support.cpp")
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstgui_win32_bundle_support.cpp"
)
target_compile_definitions(vst3sdk_vstgui PRIVATE "SMTG_MODULE_IS_BUNDLE=1")
endif()

target_link_libraries(vst3sdk_vstgui PUBLIC vst3sdk sfizz::vstgui)

function(plugin_add_vstgui NAME)
Expand All @@ -116,7 +187,8 @@ endfunction()
foreach(_target vst3sdk_vstgui vst3sdk)
gw_target_warn("${_target}" PUBLIC
"-Wno-extra"
"-Wno-class-memaccess")
"-Wno-class-memaccess"
)
gw_target_warn("${_target}" PRIVATE
"-Wno-multichar"
"-Wno-reorder"
Expand All @@ -125,5 +197,6 @@ foreach(_target vst3sdk_vstgui vst3sdk)
"-Wno-unknown-pragmas"
"-Wno-unused-function"
"-Wno-unused-parameter"
"-Wno-unused-variable")
"-Wno-unused-variable"
)
endforeach()
Loading