Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
obs-vst: Update CMakeLists for modern builds
Browse files Browse the repository at this point in the history
  • Loading branch information
PatTheMav authored and jp9000 committed Mar 17, 2022
1 parent 8ad3f64 commit 937ba79
Showing 1 changed file with 116 additions and 68 deletions.
184 changes: 116 additions & 68 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,84 +1,132 @@
if(DISABLE_UI)
message(STATUS "UI disabled,so vst plugin disabled")
return()
project(obs-vst)

macro(find_qt)
set(oneValueArgs VERSION)
set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC COMPONENTS_LINUX)
cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}"
${ARGN})

if(OS_WINDOWS)
find_package(
Qt${FIND_QT_VERSION}
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_WIN}
REQUIRED)
elseif(OS_MACOS)
find_package(
Qt${FIND_QT_VERSION}
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_MAC}
REQUIRED)
else()
find_package(
Qt${FIND_QT_VERSION}
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_LINUX}
REQUIRED)
endif()

foreach(_COMPONENT IN LISTS FIND_QT_COMPONENTS FIND_QT_COMPONENTS_WIN
FIND_QT_COMPONENTS_MAC FIND_QT_COMPONENTS_LINUX)
if(NOT TARGET Qt::${_COMPONENT} AND TARGET
Qt${FIND_QT_VERSION}::${_COMPONENT})

add_library(Qt::${_COMPONENT} INTERFACE IMPORTED)
set_target_properties(
Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES
"Qt${FIND_QT_VERSION}::${_COMPONENT}")
endif()
endforeach()
endmacro()

option(ENABLE_VST "Enable building OBS with VST plugin" ON)

if(NOT ENABLE_VST)
message(STATUS "OBS: DISABLED obs-vst")
return()
endif()
if(DISABLE_VST)
message(STATUS "obs-vst is disabled")
return()

option(ENABLE_VST_BUNDLED_HEADERS "Build with Bundled Headers" ON)
mark_as_advanced(ENABLE_VST_BUNDLED_HEADERS)

if(NOT QT_VERSION)
set(QT_VERSION
"5"
CACHE STRING
"OBS Qt version [5, 6]" FORCE)
set_property(CACHE QT_VERSION PROPERTY STRINGS 5 6)
endif()

project(obs-vst)
add_library(obs-vst MODULE)
add_library(OBS::vst ALIAS obs-vst)

find_qt(VERSION ${QT_VERSION} COMPONENTS Widgets)

set_target_properties(
obs-vst
PROPERTIES AUTOMOC ON
AUTOUIC ON
AUTORCC ON)

target_include_directories(
obs-vst PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
target_sources(
obs-vst
PRIVATE obs-vst.cpp VSTPlugin.cpp EditorWidget.cpp
headers/vst-plugin-callbacks.hpp headers/EditorWidget.h
headers/VSTPlugin.h)

set(CMAKE_AUTOMOC TRUE)
find_package(Qt5Widgets REQUIRED)
target_link_libraries(obs-vst PRIVATE OBS::libobs Qt::Widgets)

option(VST_USE_BUNDLED_HEADERS "Build with Bundled Headers" ON)
target_include_directories(
obs-vst PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/headers)

if(VST_USE_BUNDLED_HEADERS)
message(STATUS "Using the bundled VST header.")
include_directories(vst_header)
set(vst_HEADER
vst_header/aeffectx.h)
target_compile_features(obs-vst PRIVATE cxx_std_17)

if(ENABLE_VST_BUNDLED_HEADERS)
message(STATUS "OBS: - obs-vst uses bundled VST headers")

target_sources(obs-vst PRIVATE vst_header/aeffectx.h)

target_include_directories(obs-vst
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vst_header)
else()
set(VST_INCLUDE_DIR "" CACHE PATH
"Path to Steinburg headers (e.g. C:/VST3 SDK/pluginterfaces/vst2.x)")

message(WARNING "You should only use the Steinburg headers for debugging or local
builds. It is illegal to distribute the Steinburg headers with anything, and
possibly against the GPL to distribute the binaries from the resultant compile.")
include_directories(${VST_INCLUDE_DIR})
set(vst_HEADER
${VST_INCLUDE_DIR}/aeffectx.h)
set(VST_INCLUDE_DIR
""
CACHE PATH
"Path to Steinburg headers (e.g. C:/VST3 SDK/pluginterfaces/vst2.x)"
FORCE)
mark_as_advanced(VST_INCLUDE_DIR)

message(
WARNING
"OBS: You should only use the Steinburg headers for debugging or local builds. "
"It is illegal to distribute the Steinburg headers with anything, and "
"possibly against the GPL to distribute the binaries from the resultant compile."
)

target_sources(obs-vst PRIVATE ${VST_INCLUDE_DIR}/aeffectx.h)
endif()

if(APPLE)
find_library(FOUNDATION_FRAMEWORK Foundation)
find_library(COCOA_FRAMEWORK Cocoa)
endif(APPLE)

set(obs-vst_SOURCES
obs-vst.cpp
VSTPlugin.cpp
EditorWidget.cpp)

if(APPLE)
list(APPEND obs-vst_SOURCES
mac/VSTPlugin-osx.mm
mac/EditorWidget-osx.mm)

elseif(WIN32)
list(APPEND obs-vst_SOURCES
win/VSTPlugin-win.cpp
win/EditorWidget-win.cpp)

elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
list (APPEND obs-vst_SOURCES
linux/VSTPlugin-linux.cpp
linux/EditorWidget-linux.cpp)
endif()
if(OS_MACOS)
find_library(FOUNDATION Foundation)
find_library(COCOA Cocoa)
mark_as_advanced(COCOA FOUNDATION)

list(APPEND obs-vst_HEADERS
headers/vst-plugin-callbacks.hpp
headers/EditorWidget.h
headers/VSTPlugin.h)
target_sources(obs-vst PRIVATE mac/VSTPlugin-osx.mm mac/EditorWidget-osx.mm)

add_library(obs-vst MODULE
${obs-vst_SOURCES}
${obs-vst_HEADERS}
${vst-HEADER})
target_link_libraries(obs-vst PRIVATE ${COCOA} ${FOUNDATION})

target_link_libraries(obs-vst
libobs
Qt5::Widgets)
elseif(OS_WINDOWS)
target_sources(obs-vst PRIVATE win/VSTPlugin-win.cpp win/EditorWidget-win.cpp)

set_target_properties(obs-vst PROPERTIES FOLDER "plugins")
target_compile_definitions(obs-vst PRIVATE UNICODE _UNICODE)

elseif(OS_POSIX)
target_sources(obs-vst PRIVATE linux/VSTPlugin-linux.cpp
linux/EditorWidget-linux.cpp)

endif()

if(APPLE)
target_link_libraries(obs-vst
${COCOA_FRAMEWORK}
${FOUNDATION_FRAMEWORK})
endif(APPLE)
set_target_properties(obs-vst PROPERTIES FOLDER "plugins" PREFIX "")

install_obs_plugin_with_data(obs-vst data)
setup_plugin_target(obs-vst)

0 comments on commit 937ba79

Please sign in to comment.