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

CMake: Use a different namespace for plugins, avoid unneeded virtual directories #123

Merged
merged 1 commit into from
Jan 12, 2024
Merged
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ option_ex(PLUGIN_VST3 "Enable VST3 plug-in build" ON)
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)

# This is useful with some IDE like QtCreator to avoid them to create additional virtual directories
option_ex(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS "Use CMake source_group by passing empty name" OFF)

set(MIDI_CC_COUNT 512 CACHE STRING "Maximum amount of Control Change Messages")

if(PLUGIN_LV2 AND SFIZZ_SNDFILE_STATIC)
Expand Down
51 changes: 33 additions & 18 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,38 @@ set(PLUGINSCOMMON_SOURCES
common/plugin/SfizzSettings.h
common/plugin/SfizzSettings.cpp
)
source_group("Sources" FILES ${PLUGINSCOMMON_SOURCES})
add_library(plugins-common STATIC EXCLUDE_FROM_ALL ${PLUGINSCOMMON_SOURCES})
if(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS)
source_group("" FILES ${PLUGINSCOMMON_SOURCES})
endif()
add_library(plugins_common STATIC EXCLUDE_FROM_ALL ${PLUGINSCOMMON_SOURCES})

if(APPLE)
target_sources(plugins-common PRIVATE
target_sources(plugins_common PRIVATE
"common/plugin/SfizzForeignPaths.mm"
"common/plugin/SfizzSettings.mm"
"common/plugin/NativeHelpers.mm"
)
set_property(SOURCE
"common/plugin/SfizzForeignPaths.mm"
"common/plugin/SfizzSettings.mm"
"common/plugin/NativeHelpers.mm")
set_property(
SOURCE "common/plugin/SfizzForeignPaths.mm"
"common/plugin/SfizzSettings.mm"
"common/plugin/NativeHelpers.mm"
"common/plugin/NativeHelpers.mm"
APPEND_STRING
PROPERTY COMPILE_FLAGS " -fobjc-arc")
PROPERTY COMPILE_FLAGS " -fobjc-arc"
)
endif()
target_include_directories(plugins-common PUBLIC "common")
target_link_libraries(plugins-common
PUBLIC sfizz::spin_mutex
PUBLIC sfizz::simde sfizz::filesystem absl::strings
PRIVATE sfizz::pugixml
PRIVATE sfizz::internal sfizz::sfizz)
add_library(sfizz::plugins-common ALIAS plugins-common)
target_include_directories(plugins_common PUBLIC "common")
target_link_libraries(plugins_common
PUBLIC
sfizz::spin_mutex
sfizz::simde
sfizz::filesystem
absl::strings
PRIVATE
sfizz::pugixml
sfizz::internal
sfizz::sfizz
)
add_library(plugins::common ALIAS plugins_common)

add_custom_target(generate_plugins_git_build_id
COMMAND
Expand All @@ -48,10 +58,15 @@ add_custom_target(generate_plugins_git_build_id
BYPRODUCTS
"${PROJECT_BINARY_DIR}/git-build-id/PluginGitBuildId.c"
)
add_library(plugins_git_build_id STATIC EXCLUDE_FROM_ALL
set(PLUGINS_GIT_BUILD_ID_SOURCES
"${PROJECT_SOURCE_DIR}/plugins/git-build-id/PluginGitBuildId.h"
"${PROJECT_BINARY_DIR}/git-build-id/PluginGitBuildId.c"
)
if(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS)
source_group("" FILES ${PLUGINS_GIT_BUILD_ID_SOURCES})
endif()

add_library(plugins_git_build_id STATIC EXCLUDE_FROM_ALL ${PLUGINS_GIT_BUILD_ID_SOURCES})
target_include_directories(plugins_git_build_id PUBLIC "${PROJECT_SOURCE_DIR}/plugins/git-build-id")
add_dependencies(plugins_git_build_id generate_plugins_git_build_id)
add_library(plugins::git_build_id ALIAS plugins_git_build_id)
Expand All @@ -60,7 +75,7 @@ add_library(plugins::git_build_id ALIAS plugins_git_build_id)
if(WIN32)
elseif(ANDROID)
elseif(APPLE)
target_link_libraries(plugins-common PRIVATE
target_link_libraries(plugins_common PRIVATE
"${APPLE_FOUNDATION_LIBRARY}")
else()
endif()
Expand Down
58 changes: 33 additions & 25 deletions plugins/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,47 +88,52 @@ set(EDITOR_SOURCES
src/editor/utility/vstgui_after.h
src/editor/utility/vstgui_before.h
)
source_group("Sources" FILES ${EDITOR_SOURCES})
source_group("Editor UI" FILES ${EDITOR_UI_FILES})
source_group("Editor Themes" FILES ${EDITOR_THEMES})
if(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS)
source_group("" FILES ${EDITOR_SOURCES})
source_group("" FILES ${EDITOR_UI_FILES})
source_group("" FILES ${EDITOR_THEMES})
endif()

add_library(sfizz_editor STATIC EXCLUDE_FROM_ALL
add_library(plugins_editor STATIC EXCLUDE_FROM_ALL
${EDITOR_SOURCES}
${EDITOR_THEMES}
${EDITOR_UI_FILES}
)
add_library(sfizz::editor ALIAS sfizz_editor)
add_library(plugins::editor ALIAS plugins_editor)

target_include_directories(sfizz_editor PUBLIC src)
target_link_libraries(sfizz_editor PUBLIC sfizz::messaging sfizz::plugins-common)
target_link_libraries(sfizz_editor PRIVATE
sfizz::vstgui
target_include_directories(plugins_editor PUBLIC src)
target_link_libraries(plugins_editor PUBLIC
sfizz::messaging
plugins::common
)
target_link_libraries(plugins_editor PRIVATE
plugins::vstgui
plugins::git_build_id
)
target_compile_definitions(sfizz_editor PRIVATE
target_compile_definitions(plugins_editor PRIVATE
"SFIZZ_VERSION=\"${CMAKE_PROJECT_VERSION}\"")
if(APPLE)
find_library(APPLE_APPKIT_LIBRARY "AppKit")
find_library(APPLE_CORESERVICES_LIBRARY "CoreServices")
find_library(APPLE_FOUNDATION_LIBRARY "Foundation")
target_sources(sfizz_editor PRIVATE
target_sources(plugins_editor PRIVATE
src/editor/NativeHelpers.mm
src/editor/VSTGUIHelpers.mm)
target_link_libraries(sfizz_editor PRIVATE
target_link_libraries(plugins_editor PRIVATE
"${APPLE_APPKIT_LIBRARY}"
"${APPLE_CORESERVICES_LIBRARY}"
"${APPLE_FOUNDATION_LIBRARY}")
target_compile_options(sfizz_editor PRIVATE "-fobjc-arc")
target_compile_options(plugins_editor PRIVATE "-fobjc-arc")
endif()

# dependencies
add_library(sfizz_colorspaces INTERFACE)
add_library(sfizz::colorspaces ALIAS sfizz_colorspaces)
target_include_directories(sfizz_colorspaces INTERFACE "external/color-spaces")
add_library(plugins_colorspaces INTERFACE)
add_library(plugins::colorspaces ALIAS plugins_colorspaces)
target_include_directories(plugins_colorspaces INTERFACE "external/color-spaces")

add_library(sfizz_stb_image INTERFACE)
add_library(sfizz::stb_image ALIAS sfizz_stb_image)
target_include_directories(sfizz_stb_image INTERFACE "external/stb_image")
add_library(plugins_stb_image INTERFACE)
add_library(plugins::stb_image ALIAS plugins_stb_image)
target_include_directories(plugins_stb_image INTERFACE "external/stb_image")

if(WIN32)
#
Expand All @@ -137,12 +142,12 @@ elseif(APPLE)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(sfizz-gio "gio-2.0" REQUIRED)
target_include_directories(sfizz_editor PRIVATE ${sfizz-gio_INCLUDE_DIRS})
target_link_libraries(sfizz_editor PRIVATE ${sfizz-gio_LIBRARIES})
target_include_directories(plugins_editor PRIVATE ${sfizz-gio_INCLUDE_DIRS})
target_link_libraries(plugins_editor PRIVATE ${sfizz-gio_LIBRARIES})
endif()
target_link_libraries(sfizz_editor PRIVATE
sfizz::colorspaces
sfizz::stb_image
target_link_libraries(plugins_editor PRIVATE
plugins::colorspaces
plugins::stb_image
sfizz::bit_array
sfizz::filesystem
sfizz::pugixml
Expand All @@ -155,7 +160,10 @@ if(NOT CMAKE_CROSSCOMPILING)
tools/layout-maker/sources/reader.h
tools/layout-maker/sources/main.cpp
)
source_group("Sources" FILES ${LAYOUTMAKER_SOURCES})
if(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS)
source_group("" FILES ${LAYOUTMAKER_SOURCES})
endif()

add_executable(layout-maker ${LAYOUTMAKER_SOURCES})
target_link_libraries(layout-maker PRIVATE absl::strings)

Expand Down
32 changes: 16 additions & 16 deletions plugins/editor/cmake/Vstgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ string(REGEX MATCH "\#define VSTGUI_VERSION_MINOR ([0-9]*)" _ ${VSTGUIBASE_HEAD
set(VSTGUI_VERSION_MINOR ${CMAKE_MATCH_1})
set(VSTGUI_VERSION "${VSTGUI_VERSION_MAJOR}.${VSTGUI_VERSION_MINOR}")

add_library(sfizz_vstgui STATIC EXCLUDE_FROM_ALL
add_library(plugins_vstgui STATIC EXCLUDE_FROM_ALL
"${VSTGUI_BASEDIR}/vstgui/lib/animation/animations.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/animation/animator.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/animation/timingfunctions.cpp"
Expand Down Expand Up @@ -72,10 +72,10 @@ add_library(sfizz_vstgui STATIC EXCLUDE_FROM_ALL
"${VSTGUI_BASEDIR}/vstgui/lib/vstguidebug.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/vstguiinit.cpp"
)
add_library(sfizz::vstgui ALIAS sfizz_vstgui)
add_library(plugins::vstgui ALIAS plugins_vstgui)

if(WIN32)
target_sources(sfizz_vstgui PRIVATE
target_sources(plugins_vstgui PRIVATE
"${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dbitmap.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2dbitmapcache.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/direct2d/d2ddrawcontext.cpp"
Expand All @@ -98,7 +98,7 @@ if(WIN32)
"${VSTGUI_BASEDIR}/vstgui/lib/platform/win32/wintimer.cpp"
)
elseif(APPLE)
target_sources(sfizz_vstgui PRIVATE
target_sources(plugins_vstgui PRIVATE
"${VSTGUI_BASEDIR}/vstgui/lib/platform/mac/cocoa/autoreleasepool.mm"
"${VSTGUI_BASEDIR}/vstgui/lib/platform/mac/cocoa/cocoahelpers.mm"
"${VSTGUI_BASEDIR}/vstgui/lib/platform/mac/cocoa/cocoaopenglview.mm"
Expand All @@ -119,7 +119,7 @@ elseif(APPLE)
"${VSTGUI_BASEDIR}/vstgui/lib/platform/mac/quartzgraphicspath.cpp"
)
else()
target_sources(sfizz_vstgui PRIVATE
target_sources(plugins_vstgui PRIVATE
"${VSTGUI_BASEDIR}/vstgui/lib/platform/linux/cairobitmap.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/platform/linux/cairocontext.cpp"
"${VSTGUI_BASEDIR}/vstgui/lib/platform/linux/cairofont.cpp"
Expand All @@ -136,12 +136,12 @@ else()
)
endif()

target_include_directories(sfizz_vstgui PUBLIC "${VSTGUI_BASEDIR}")
target_include_directories(plugins_vstgui PUBLIC "${VSTGUI_BASEDIR}")

if(WIN32)
if (NOT MSVC)
# autolinked on MSVC with pragmas
target_link_libraries(sfizz_vstgui PRIVATE
target_link_libraries(plugins_vstgui PRIVATE
"opengl32"
"d2d1"
"dwrite"
Expand All @@ -151,7 +151,7 @@ if(WIN32)
)
endif()
elseif(APPLE)
target_link_libraries(sfizz_vstgui PRIVATE
target_link_libraries(plugins_vstgui PRIVATE
"${APPLE_COREFOUNDATION_LIBRARY}"
"${APPLE_FOUNDATION_LIBRARY}"
"${APPLE_COCOA_LIBRARY}"
Expand All @@ -178,7 +178,7 @@ else()
pkg_check_modules(PANGO REQUIRED pangocairo pangoft2)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(GLIB REQUIRED glib-2.0)
target_include_directories(sfizz_vstgui PRIVATE
target_include_directories(plugins_vstgui PRIVATE
${X11_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
${LIBXCB_INCLUDE_DIRS}
Expand All @@ -193,7 +193,7 @@ else()
${FONTCONFIG_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
)
target_link_libraries(sfizz_vstgui PRIVATE
target_link_libraries(plugins_vstgui PRIVATE
${X11_LIBRARIES}
${FREETYPE_LIBRARIES}
${LIBXCB_LIBRARIES}
Expand All @@ -210,21 +210,21 @@ else()
)
find_library(DL_LIBRARY "dl")
if(DL_LIBRARY)
target_link_libraries(sfizz_vstgui PRIVATE "${DL_LIBRARY}")
target_link_libraries(plugins_vstgui PRIVATE "${DL_LIBRARY}")
endif()
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
target_compile_definitions(sfizz_vstgui PUBLIC "DEVELOPMENT")
target_compile_definitions(plugins_vstgui PUBLIC "DEVELOPMENT")
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "Release")
target_compile_definitions(sfizz_vstgui PUBLIC "RELEASE")
target_compile_definitions(plugins_vstgui PUBLIC "RELEASE")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows 10 RS2 DDI for custom fonts
target_compile_definitions(sfizz_vstgui PRIVATE "NTDDI_VERSION=0x0A000003")
target_compile_definitions(plugins_vstgui PRIVATE "NTDDI_VERSION=0x0A000003")
# disable custom fonts if dwrite3 API is unavailable in MinGW
if(MINGW)
check_cxx_source_compiles("
Expand All @@ -240,13 +240,13 @@ int main()
}" SFIZZ_MINGW_SUPPORTS_DWRITE3)
if(NOT SFIZZ_MINGW_SUPPORTS_DWRITE3)
message(WARNING "This version of MinGW does not support DirectWrite 3. Custom font support is disabled.")
target_compile_definitions(sfizz_vstgui PRIVATE "VSTGUI_WIN32_CUSTOMFONT_SUPPORT=0")
target_compile_definitions(plugins_vstgui PRIVATE "VSTGUI_WIN32_CUSTOMFONT_SUPPORT=0")
endif()
endif()
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
gw_target_warn(sfizz_vstgui PRIVATE
gw_target_warn(plugins_vstgui PRIVATE
"-Wno-deprecated-copy"
"-Wno-deprecated-declarations"
"-Wno-extra"
Expand Down
43 changes: 30 additions & 13 deletions plugins/lv2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(LV2_PLUGIN_PRJ_NAME "${PROJECT_NAME}_lv2")
set(LV2_PLUGIN_PRJ_NAME "plugins_lv2")
paulfd marked this conversation as resolved.
Show resolved Hide resolved

# Set the build directory as <build_dir>/lv2/<plugin_name>.lv2/
set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.lv2")
Expand All @@ -7,30 +7,47 @@ set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.lv2")
include(LV2Config)

# Keep non build turtle files in IDE
set(LV2_PLUGIN_TTL_SRC_FILES
set(LV2_PLUGIN_TTL_SOURCES
manifest.ttl.in
${PROJECT_NAME}.ttl.in
)
if(PLUGIN_LV2_UI)
list(APPEND LV2_PLUGIN_TTL_SRC_FILES
${PROJECT_NAME}_ui.ttl.in)
list(APPEND LV2_PLUGIN_TTL_SOURCES ${PROJECT_NAME}_ui.ttl.in)
endif()
source_group("Turtle Files" FILES
${LV2_PLUGIN_TTL_SRC_FILES}
)
add_library(${LV2_PLUGIN_PRJ_NAME} MODULE
set(LV2_PLUGIN_SOURCES
${PROJECT_NAME}.cpp
${PROJECT_NAME}_lv2_common.cpp
${LV2_PLUGIN_TTL_SRC_FILES})
target_link_libraries(${LV2_PLUGIN_PRJ_NAME} PRIVATE sfizz::sfizz sfizz::import sfizz::plugins-common)
${LV2_PLUGIN_TTL_SOURCES}
)
if(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS)
source_group("" FILES ${LV2_PLUGIN_SOURCES})
endif()
source_group("Turtle Files" FILES ${LV2_PLUGIN_TTL_SOURCES})

add_library(${LV2_PLUGIN_PRJ_NAME} MODULE ${LV2_PLUGIN_SOURCES})
target_link_libraries(${LV2_PLUGIN_PRJ_NAME} PRIVATE
sfizz::sfizz
sfizz::import
plugins::common
)
if(PLUGIN_LV2_UI)
add_library(${LV2_PLUGIN_PRJ_NAME}_ui MODULE
set(LV2_PLUGIN_UI_FILES
${PROJECT_NAME}_ui.cpp
${PROJECT_NAME}_lv2_common.cpp
vstgui_helpers.h
vstgui_helpers.cpp)
target_link_libraries(${LV2_PLUGIN_PRJ_NAME}_ui PRIVATE sfizz::editor sfizz::vstgui sfizz::plugins-common)
vstgui_helpers.cpp
)
if(SFIZZ_CMAKE_USE_EMPTY_SOURCE_GROUPS)
source_group("" FILES ${LV2_PLUGIN_UI_FILES})
endif()

add_library(${LV2_PLUGIN_PRJ_NAME}_ui MODULE ${LV2_PLUGIN_UI_FILES})

target_link_libraries(${LV2_PLUGIN_PRJ_NAME}_ui PRIVATE
plugins::editor
plugins::vstgui
plugins::common
)
endif()

if(PLUGIN_LV2_PSA)
Expand Down
Loading