Skip to content

Commit 6d95cd9

Browse files
committed
Add VisageTemplate
1 parent 6fae3d2 commit 6d95cd9

File tree

134 files changed

+13987
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+13987
-39
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ include(${IPLUG2_DIR}/iPlug2.cmake)
1414

1515
find_package(iPlug2 REQUIRED)
1616

17+
# Add subdirectories for each project
1718
add_subdirectory(TemplateProject)
19+
add_subdirectory(VisageTemplate)

TemplateProject/CMakeLists.txt

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,13 @@ project(TemplateProject VERSION 1.0.0)
44
# Set up iPlug2 paths
55
set(IPLUG2_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../iPlug2 CACHE PATH "iPlug2 root directory")
66
include(${IPLUG2_DIR}/iPlug2.cmake)
7-
find_package(iPlug2 REQUIRED)
87

9-
# IGraphics backend selection
10-
set(IGRAPHICS_BACKEND "NANOVG" CACHE STRING "IGraphics drawing backend")
11-
set_property(CACHE IGRAPHICS_BACKEND PROPERTY STRINGS "NANOVG" "SKIA")
12-
13-
# IGraphics renderer selection (platform-aware defaults)
14-
# NANOVG supports: GL2, GL3, METAL (Metal is macOS/iOS only)
15-
# SKIA supports: GL3, METAL, CPU
16-
if(WIN32)
17-
set(DEFAULT_RENDERER "GL2")
18-
elseif(APPLE)
19-
set(DEFAULT_RENDERER "METAL")
20-
else()
21-
set(DEFAULT_RENDERER "GL2")
22-
endif()
23-
set(IGRAPHICS_RENDERER "${DEFAULT_RENDERER}" CACHE STRING "IGraphics renderer")
24-
set_property(CACHE IGRAPHICS_RENDERER PROPERTY STRINGS "GL2" "GL3" "METAL" "CPU")
25-
26-
# Construct the IGraphics library target based on selections
27-
if(IGRAPHICS_BACKEND STREQUAL "SKIA")
28-
if(IGRAPHICS_RENDERER STREQUAL "CPU")
29-
set(IGRAPHICS_LIB iPlug2::IGraphics::Skia::CPU)
30-
elseif(IGRAPHICS_RENDERER STREQUAL "GL3")
31-
set(IGRAPHICS_LIB iPlug2::IGraphics::Skia::GL3)
32-
else()
33-
set(IGRAPHICS_LIB iPlug2::IGraphics::Skia::Metal)
34-
endif()
35-
else()
36-
# NanoVG
37-
if(IGRAPHICS_RENDERER STREQUAL "GL3")
38-
set(IGRAPHICS_LIB iPlug2::IGraphics::NanoVG::GL3)
39-
elseif(IGRAPHICS_RENDERER STREQUAL "METAL")
40-
set(IGRAPHICS_LIB iPlug2::IGraphics::NanoVG::Metal)
41-
else()
42-
# Default to GL2 for NanoVG
43-
set(IGRAPHICS_LIB iPlug2::IGraphics::NanoVG)
44-
endif()
45-
endif()
46-
message(STATUS "IGraphics: ${IGRAPHICS_BACKEND}/${IGRAPHICS_RENDERER} -> ${IGRAPHICS_LIB}")
8+
# IGraphics backend/renderer can be set via command line:
9+
# cmake -DIGRAPHICS_BACKEND=SKIA -DIGRAPHICS_RENDERER=GL3 ..
10+
# Defaults: NANOVG/METAL on macOS, NANOVG/GL2 on Windows
11+
# See iPlug2/Scripts/cmake/IGraphics.cmake for all options
12+
13+
find_package(iPlug2 REQUIRED)
4714

4815
set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
4916
set(PLUG_RESOURCES_DIR ${PROJECT_DIR}/resources)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"env": {
3+
"commonIncludePaths": [
4+
"${workspaceFolder}/**",
5+
"${workspaceFolder}/../../WDL/**",
6+
"${workspaceFolder}/../../IPlug/**",
7+
"${workspaceFolder}/../../IGraphics/**",
8+
"${workspaceFolder}/../../Dependencies/**"
9+
],
10+
"commonDefs": [
11+
"APP_API",
12+
"IPLUG_DSP=1",
13+
"IPLUG_EDITOR=1",
14+
"IGRAPHICS_NANOVG",
15+
"NOMINMAX"
16+
]
17+
},
18+
"configurations": [
19+
{
20+
"name": "Mac",
21+
"includePath": [
22+
"${commonIncludePaths}",
23+
"${workspaceFolder}/../../Dependencies/Build/mac/include/**"
24+
],
25+
"defines": [
26+
"${commonDefs}",
27+
"OS_MAC",
28+
"IGRAPHICS_METAL"
29+
],
30+
"macFrameworkPath": [
31+
"/System/Library/Frameworks",
32+
"/Library/Frameworks"
33+
],
34+
"cppStandard": "c++14"
35+
},
36+
{
37+
"name": "Win32",
38+
"includePath": [
39+
"${commonIncludePaths}"
40+
],
41+
"defines": [
42+
"${commonDefs}",
43+
"OS_WIN",
44+
"IGRAPHICS_GL2"
45+
]
46+
}
47+
],
48+
"version": 4
49+
}

VisageTemplate/CMakeLists.txt

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(VisageTemplate VERSION 1.0.0)
3+
4+
# Use static runtime on Windows to match iPlug2 (must be set before any targets)
5+
if(MSVC)
6+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "" FORCE)
7+
endif()
8+
9+
# Set up iPlug2 paths
10+
set(IPLUG2_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../iPlug2 CACHE PATH "iPlug2 root directory")
11+
include(${IPLUG2_DIR}/iPlug2.cmake)
12+
find_package(iPlug2 REQUIRED)
13+
14+
# Include Visage support from iPlug2
15+
include(${IPLUG2_DIR}/Scripts/cmake/Visage.cmake)
16+
17+
# Visage UI Library via FetchContent
18+
include(FetchContent)
19+
FetchContent_Declare(visage
20+
GIT_REPOSITORY https://github.com/iPlug2/visage.git
21+
GIT_TAG claude/compile-with-mt-flag-01GA2wfzj1g7Ki8NgB2SLGWA
22+
EXCLUDE_FROM_ALL
23+
)
24+
set(VISAGE_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
25+
set(VISAGE_BUILD_TESTS OFF CACHE BOOL "" FORCE)
26+
set(VISAGE_ENABLE_WIDGETS ON CACHE BOOL "" FORCE)
27+
FetchContent_MakeAvailable(visage)
28+
29+
# Link visage to iPlug2::Visage so the delegate can find it
30+
target_link_libraries(iPlug2_Visage PUBLIC visage)
31+
32+
# ============================================================================
33+
# Visage Libraries Target - builds only static libraries for non-CMake linking
34+
# ============================================================================
35+
# Output directory for collected static libraries
36+
set(VISAGE_LIB_OUTPUT_DIR ${CMAKE_BINARY_DIR}/visage-libs/$<CONFIG>)
37+
38+
# Custom target to build all visage static libraries
39+
add_custom_target(visage-libs
40+
COMMENT "Building Visage static libraries for external linking"
41+
)
42+
43+
# Depend on all visage and dependency targets (only actual STATIC library targets)
44+
add_dependencies(visage-libs
45+
visage
46+
VisageEmbeddedFonts
47+
VisageEmbeddedIcons
48+
VisageEmbeddedShaders
49+
bgfx
50+
bimg
51+
bimg_decode
52+
bimg_encode
53+
bx
54+
freetype
55+
)
56+
57+
# Copy all static libraries to output directory after build
58+
add_custom_command(TARGET visage-libs POST_BUILD
59+
COMMAND ${CMAKE_COMMAND} -E make_directory "${VISAGE_LIB_OUTPUT_DIR}"
60+
# Visage main library (contains all object libraries)
61+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:visage> "${VISAGE_LIB_OUTPUT_DIR}/"
62+
# Visage embedded resources
63+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:VisageEmbeddedFonts> "${VISAGE_LIB_OUTPUT_DIR}/"
64+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:VisageEmbeddedIcons> "${VISAGE_LIB_OUTPUT_DIR}/"
65+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:VisageEmbeddedShaders> "${VISAGE_LIB_OUTPUT_DIR}/"
66+
# bgfx/bx/bimg dependencies
67+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:bgfx> "${VISAGE_LIB_OUTPUT_DIR}/"
68+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:bimg> "${VISAGE_LIB_OUTPUT_DIR}/"
69+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:bimg_decode> "${VISAGE_LIB_OUTPUT_DIR}/"
70+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:bimg_encode> "${VISAGE_LIB_OUTPUT_DIR}/"
71+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:bx> "${VISAGE_LIB_OUTPUT_DIR}/"
72+
# freetype (rename to consistent name regardless of config since freetype adds 'd' suffix for debug)
73+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:freetype> "${VISAGE_LIB_OUTPUT_DIR}/$<IF:$<BOOL:${WIN32}>,freetype.lib,libfreetype.a>"
74+
COMMENT "Copying Visage libraries to ${VISAGE_LIB_OUTPUT_DIR}"
75+
)
76+
77+
set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
78+
set(PLUG_RESOURCES_DIR ${PROJECT_DIR}/resources)
79+
80+
set(SOURCE_FILES
81+
VisageTemplate.cpp
82+
VisageTemplate.h
83+
resources/resource.h
84+
)
85+
86+
# create a private library target called "__${PROJECT_NAME}-base" for shared code
87+
add_library(_${PROJECT_NAME}-base INTERFACE)
88+
iplug_add_target(_${PROJECT_NAME}-base INTERFACE
89+
INCLUDE ${PROJECT_DIR} ${PROJECT_DIR}/resources
90+
LINK iPlug2::Visage
91+
)
92+
93+
# ============================================================================
94+
# macOS/Windows targets (not iOS, not Emscripten)
95+
# ============================================================================
96+
if(NOT IOS AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
97+
# ============================================================================
98+
# APP Target (Standalone Application) - with Visage UI
99+
# ============================================================================
100+
set(APP_SOURCES ${SOURCE_FILES})
101+
102+
# Add Windows resource file for dialog/menu resources
103+
if(WIN32)
104+
list(APPEND APP_SOURCES ${PLUG_RESOURCES_DIR}/main.rc)
105+
endif()
106+
107+
add_executable(${PROJECT_NAME}-app ${APP_SOURCES})
108+
iplug_add_target(${PROJECT_NAME}-app PUBLIC
109+
LINK iPlug2::APP _${PROJECT_NAME}-base
110+
RESOURCE ${RESOURCES}
111+
)
112+
iplug_configure_target(${PROJECT_NAME}-app APP ${PROJECT_NAME})
113+
114+
# ============================================================================
115+
# VST3 Target - with Visage UI
116+
# ============================================================================
117+
add_library(${PROJECT_NAME}-vst3 MODULE ${SOURCE_FILES})
118+
iplug_add_target(${PROJECT_NAME}-vst3 PUBLIC
119+
LINK iPlug2::VST3 _${PROJECT_NAME}-base
120+
)
121+
iplug_configure_target(${PROJECT_NAME}-vst3 VST3 ${PROJECT_NAME})
122+
123+
# ============================================================================
124+
# CLAP Target - with Visage UI
125+
# ============================================================================
126+
add_library(${PROJECT_NAME}-clap MODULE ${SOURCE_FILES})
127+
iplug_add_target(${PROJECT_NAME}-clap PUBLIC
128+
LINK iPlug2::CLAP _${PROJECT_NAME}-base
129+
)
130+
iplug_configure_target(${PROJECT_NAME}-clap CLAP ${PROJECT_NAME})
131+
132+
# ============================================================================
133+
# AAX Target - with Visage UI
134+
# ============================================================================
135+
add_library(${PROJECT_NAME}-aax MODULE ${SOURCE_FILES})
136+
iplug_add_target(${PROJECT_NAME}-aax PUBLIC
137+
LINK iPlug2::AAX _${PROJECT_NAME}-base
138+
)
139+
iplug_configure_target(${PROJECT_NAME}-aax AAX ${PROJECT_NAME})
140+
141+
# ============================================================================
142+
# CLI Target (Command Line Interface) - NO UI, for offline processing
143+
# ============================================================================
144+
add_executable(${PROJECT_NAME}-cli
145+
VisageTemplate.cpp
146+
VisageTemplate.h
147+
resources/resource.h
148+
)
149+
iplug_add_target(${PROJECT_NAME}-cli PUBLIC
150+
INCLUDE ${PROJECT_DIR} ${PROJECT_DIR}/resources
151+
LINK iPlug2::CLI
152+
)
153+
iplug_configure_cli(${PROJECT_NAME}-cli ${PROJECT_NAME})
154+
endif()
155+
156+
# ============================================================================
157+
# AUv2 Target (macOS only) - with Visage UI
158+
# ============================================================================
159+
if(APPLE AND NOT IOS)
160+
add_library(${PROJECT_NAME}-au MODULE ${SOURCE_FILES})
161+
iplug_add_target(${PROJECT_NAME}-au PUBLIC
162+
LINK iPlug2::AUv2 _${PROJECT_NAME}-base
163+
)
164+
iplug_configure_target(${PROJECT_NAME}-au AUv2 ${PROJECT_NAME})
165+
endif()
166+
167+
# ============================================================================
168+
# AUv3 Targets (macOS only) - Framework + Appex embedded in APP
169+
# ============================================================================
170+
if(APPLE AND NOT IOS)
171+
# Framework containing AUv3 plugin code
172+
add_library(${PROJECT_NAME}AU-framework SHARED ${SOURCE_FILES})
173+
iplug_add_target(${PROJECT_NAME}AU-framework PUBLIC
174+
LINK iPlug2::AUv3 _${PROJECT_NAME}-base
175+
)
176+
iplug_configure_target(${PROJECT_NAME}AU-framework AUv3Framework ${PROJECT_NAME})
177+
178+
# App Extension (appex) - executable using NSExtensionMain entry point
179+
add_executable(${PROJECT_NAME}AUv3-appex
180+
${PLUG_RESOURCES_DIR}/${PROJECT_NAME}AUv3Appex.m
181+
)
182+
iplug_configure_target(${PROJECT_NAME}AUv3-appex AUv3Appex ${PROJECT_NAME})
183+
184+
# Embed AUv3 appex in the existing APP target
185+
iplug_embed_auv3_in_app(${PROJECT_NAME}-app ${PROJECT_NAME})
186+
endif()
187+
188+
# ============================================================================
189+
# iOS Targets - AUv3 Framework + Appex + Standalone App (Visage UI)
190+
# ============================================================================
191+
if(IOS)
192+
# iOS AUv3 Framework containing plugin code
193+
add_library(${PROJECT_NAME}AU-ios-framework SHARED ${SOURCE_FILES})
194+
iplug_add_target(${PROJECT_NAME}AU-ios-framework PUBLIC
195+
LINK iPlug2::AUv3iOS _${PROJECT_NAME}-base
196+
)
197+
iplug_configure_target(${PROJECT_NAME}AU-ios-framework AUv3iOSFramework ${PROJECT_NAME})
198+
199+
# iOS AUv3 App Extension (appex)
200+
add_executable(${PROJECT_NAME}AUv3-ios-appex
201+
${PLUG_RESOURCES_DIR}/${PROJECT_NAME}AUv3Appex.m
202+
)
203+
iplug_configure_target(${PROJECT_NAME}AUv3-ios-appex AUv3iOSAppex ${PROJECT_NAME})
204+
205+
# iOS Standalone App that hosts the AUv3 for testing
206+
add_executable(${PROJECT_NAME}-ios-app ${SOURCE_FILES})
207+
iplug_add_target(${PROJECT_NAME}-ios-app PUBLIC
208+
LINK iPlug2::AUv3iOS _${PROJECT_NAME}-base
209+
)
210+
iplug_configure_target(${PROJECT_NAME}-ios-app IOSApp ${PROJECT_NAME})
211+
212+
# Embed AUv3 appex and framework in the iOS app
213+
iplug_embed_auv3ios_in_app(${PROJECT_NAME}-ios-app ${PROJECT_NAME})
214+
endif()
215+
216+
# ============================================================================
217+
# WAM/Web Targets (Emscripten only)
218+
# ============================================================================
219+
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
220+
# WAM Processor target (DSP/audio worklet)
221+
add_executable(${PROJECT_NAME}-wam ${SOURCE_FILES})
222+
iplug_add_target(${PROJECT_NAME}-wam PUBLIC
223+
LINK iPlug2::WAM _${PROJECT_NAME}-base
224+
)
225+
iplug_configure_target(${PROJECT_NAME}-wam WAM ${PROJECT_NAME})
226+
227+
# Web Controller target (UI/graphics)
228+
add_executable(${PROJECT_NAME}-web ${SOURCE_FILES})
229+
iplug_add_target(${PROJECT_NAME}-web PUBLIC
230+
LINK iPlug2::Web _${PROJECT_NAME}-base
231+
)
232+
iplug_configure_target(${PROJECT_NAME}-web Web ${PROJECT_NAME})
233+
234+
# Combined WAM distribution target (bundles resources, templates, etc.)
235+
iplug_build_wam_dist(${PROJECT_NAME}
236+
WAM_TARGET ${PROJECT_NAME}-wam
237+
WEB_TARGET ${PROJECT_NAME}-web
238+
SITE_ORIGIN "/"
239+
)
240+
endif()

0 commit comments

Comments
 (0)