1+ cmake_minimum_required (VERSION 3.14 )
2+ project (TemplateProject VERSION 1.0.0)
3+
4+ # Set up iPlug2 paths
5+ set (IPLUG2_DIR ${CMAKE_CURRENT_SOURCE_DIR} /../iPlug2 CACHE PATH "iPlug2 root directory" )
6+ include (${IPLUG2_DIR} /iPlug2.cmake )
7+ find_package (iPlug2 REQUIRED )
8+
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} " )
47+
48+ set (PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
49+ set (PLUG_RESOURCES_DIR ${PROJECT_DIR} /resources)
50+
51+ set (SOURCE_FILES
52+ TemplateProject.cpp
53+ TemplateProject.h
54+ resources/resource.h
55+ )
56+
57+ # create a private library target called "__${PROJECT_NAME}-base" for shared code
58+ add_library (_${PROJECT_NAME}-base INTERFACE )
59+ iplug_add_target (_${PROJECT_NAME}-base INTERFACE
60+ INCLUDE ${PROJECT_DIR} ${PROJECT_DIR} /resources
61+ LINK iPlug2::IPlug
62+ )
63+
64+ # Font resources for bundles
65+ set (FONT_FILES ${PLUG_RESOURCES_DIR} /fonts/Roboto-Regular.ttf)
66+
67+ # Helper function to add resources to plugin bundles
68+ function (iplug_add_plugin_resources target )
69+ target_sources (${target} PRIVATE ${FONT_FILES} )
70+ set_source_files_properties (${FONT_FILES} PROPERTIES
71+ MACOSX_PACKAGE_LOCATION Resources
72+ )
73+ endfunction ()
74+
75+ # ============================================================================
76+ # macOS/Windows targets (not iOS, not Emscripten)
77+ # ============================================================================
78+ if (NOT IOS AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" )
79+ # ============================================================================
80+ # APP Target (Standalone Application) - with IGraphics UI
81+ # ============================================================================
82+ set (APP_SOURCES ${SOURCE_FILES} )
83+
84+ # Add Windows resource file for dialog/menu resources
85+ if (WIN32 )
86+ list (APPEND APP_SOURCES ${PLUG_RESOURCES_DIR} /main.rc)
87+ # Resource compiler needs to find font files referenced in main.rc
88+ set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /I\" ${PLUG_RESOURCES_DIR} /fonts\" " )
89+ endif ()
90+
91+ add_executable (${PROJECT_NAME} -app ${APP_SOURCES} )
92+ iplug_add_target (${PROJECT_NAME} -app PUBLIC
93+ LINK iPlug2::APP ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
94+ RESOURCE ${RESOURCES}
95+ )
96+ iplug_configure_target (${PROJECT_NAME} -app APP ${PROJECT_NAME} )
97+
98+ # Add font resources to APP bundle
99+ target_sources (${PROJECT_NAME} -app PRIVATE ${FONT_FILES} )
100+ set_source_files_properties (${FONT_FILES} PROPERTIES
101+ MACOSX_PACKAGE_LOCATION Resources
102+ )
103+
104+ # ============================================================================
105+ # VST3 Target - with IGraphics UI
106+ # ============================================================================
107+ add_library (${PROJECT_NAME} -vst3 MODULE ${SOURCE_FILES} )
108+ iplug_add_target (${PROJECT_NAME} -vst3 PUBLIC
109+ LINK iPlug2::VST3 ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
110+ )
111+ iplug_configure_target (${PROJECT_NAME} -vst3 VST3 ${PROJECT_NAME} )
112+ iplug_add_plugin_resources (${PROJECT_NAME} -vst3 )
113+
114+ # ============================================================================
115+ # CLAP Target - with IGraphics UI
116+ # ============================================================================
117+ add_library (${PROJECT_NAME} -clap MODULE ${SOURCE_FILES} )
118+ iplug_add_target (${PROJECT_NAME} -clap PUBLIC
119+ LINK iPlug2::CLAP ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
120+ )
121+ iplug_configure_target (${PROJECT_NAME} -clap CLAP ${PROJECT_NAME} )
122+ iplug_add_plugin_resources (${PROJECT_NAME} -clap )
123+
124+ # ============================================================================
125+ # AAX Target - with IGraphics UI
126+ # ============================================================================
127+ add_library (${PROJECT_NAME} -aax MODULE ${SOURCE_FILES} )
128+ iplug_add_target (${PROJECT_NAME} -aax PUBLIC
129+ LINK iPlug2::AAX ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
130+ )
131+ iplug_configure_target (${PROJECT_NAME} -aax AAX ${PROJECT_NAME} )
132+ iplug_add_plugin_resources (${PROJECT_NAME} -aax )
133+
134+ # ============================================================================
135+ # CLI Target (Command Line Interface) - NO IGraphics, for offline processing
136+ # ============================================================================
137+ add_executable (${PROJECT_NAME} -cli
138+ TemplateProject.cpp
139+ TemplateProject.h
140+ resources/resource.h
141+ )
142+ iplug_add_target (${PROJECT_NAME} -cli PUBLIC
143+ INCLUDE ${PROJECT_DIR} ${PROJECT_DIR} /resources
144+ LINK iPlug2::CLI
145+ )
146+ iplug_configure_cli (${PROJECT_NAME} -cli ${PROJECT_NAME} )
147+ endif ()
148+
149+ # ============================================================================
150+ # AUv2 Target (macOS only) - with IGraphics UI
151+ # ============================================================================
152+ if (APPLE AND NOT IOS )
153+ add_library (${PROJECT_NAME} -au MODULE ${SOURCE_FILES} )
154+ iplug_add_target (${PROJECT_NAME} -au PUBLIC
155+ LINK iPlug2::AUv2 ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
156+ )
157+ iplug_configure_target (${PROJECT_NAME} -au AUv2 ${PROJECT_NAME} )
158+ iplug_add_plugin_resources (${PROJECT_NAME} -au )
159+ endif ()
160+
161+ # ============================================================================
162+ # AUv3 Targets (macOS only) - Framework + Appex embedded in APP
163+ # ============================================================================
164+ if (APPLE AND NOT IOS )
165+ # Framework containing AUv3 plugin code
166+ add_library (${PROJECT_NAME} AU-framework SHARED ${SOURCE_FILES} )
167+ iplug_add_target (${PROJECT_NAME} AU-framework PUBLIC
168+ LINK iPlug2::AUv3 ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
169+ )
170+ iplug_configure_target (${PROJECT_NAME} AU-framework AUv3Framework ${PROJECT_NAME} )
171+ iplug_add_plugin_resources (${PROJECT_NAME} AU-framework )
172+
173+ # App Extension (appex) - executable using NSExtensionMain entry point
174+ add_executable (${PROJECT_NAME} AUv3-appex
175+ ${PLUG_RESOURCES_DIR} /${PROJECT_NAME}AUv3Appex.m
176+ )
177+ iplug_configure_target (${PROJECT_NAME} AUv3-appex AUv3Appex ${PROJECT_NAME} )
178+
179+ # Embed AUv3 appex in the existing APP target
180+ iplug_embed_auv3_in_app (${PROJECT_NAME} -app ${PROJECT_NAME} )
181+ endif ()
182+
183+ # ============================================================================
184+ # iOS Targets - AUv3 Framework + Appex + Standalone App
185+ # ============================================================================
186+ if (IOS )
187+ # iOS AUv3 Framework containing plugin code
188+ add_library (${PROJECT_NAME} AU-ios-framework SHARED ${SOURCE_FILES} )
189+ iplug_add_target (${PROJECT_NAME} AU-ios-framework PUBLIC
190+ LINK iPlug2::AUv3iOS ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
191+ )
192+ iplug_configure_target (${PROJECT_NAME} AU-ios-framework AUv3iOSFramework ${PROJECT_NAME} )
193+ iplug_add_plugin_resources (${PROJECT_NAME} AU-ios-framework )
194+
195+ # iOS AUv3 App Extension (appex)
196+ add_executable (${PROJECT_NAME} AUv3-ios-appex
197+ ${PLUG_RESOURCES_DIR} /${PROJECT_NAME}AUv3Appex.m
198+ )
199+ iplug_configure_target (${PROJECT_NAME} AUv3-ios-appex AUv3iOSAppex ${PROJECT_NAME} )
200+
201+ # iOS Standalone App that hosts the AUv3 for testing
202+ add_executable (${PROJECT_NAME} -ios-app ${SOURCE_FILES} )
203+ iplug_add_target (${PROJECT_NAME} -ios-app PUBLIC
204+ LINK iPlug2::AUv3iOS ${IGRAPHICS_LIB} _${PROJECT_NAME}-base
205+ )
206+ iplug_configure_target (${PROJECT_NAME} -ios-app IOSApp ${PROJECT_NAME} )
207+ iplug_add_plugin_resources (${PROJECT_NAME} -ios-app )
208+
209+ # Embed AUv3 appex and framework in the iOS app
210+ iplug_embed_auv3ios_in_app (${PROJECT_NAME} -ios-app ${PROJECT_NAME} )
211+ endif ()
212+
213+ # ============================================================================
214+ # WAM/Web Targets (Emscripten only)
215+ # ============================================================================
216+ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" )
217+ # WAM Processor target (DSP/audio worklet)
218+ add_executable (${PROJECT_NAME} -wam ${SOURCE_FILES} )
219+ iplug_add_target (${PROJECT_NAME} -wam PUBLIC
220+ LINK iPlug2::WAM _${PROJECT_NAME}-base
221+ )
222+ iplug_configure_target (${PROJECT_NAME} -wam WAM ${PROJECT_NAME} )
223+
224+ # Web Controller target (UI/graphics)
225+ add_executable (${PROJECT_NAME} -web ${SOURCE_FILES} )
226+ iplug_add_target (${PROJECT_NAME} -web PUBLIC
227+ LINK iPlug2::Web _${PROJECT_NAME}-base
228+ )
229+ iplug_configure_target (${PROJECT_NAME} -web Web ${PROJECT_NAME} )
230+
231+ # Combined WAM distribution target (bundles resources, templates, etc.)
232+ iplug_build_wam_dist (${PROJECT_NAME}
233+ WAM_TARGET ${PROJECT_NAME} -wam
234+ WEB_TARGET ${PROJECT_NAME} -web
235+ SITE_ORIGIN "/"
236+ )
237+ endif ()
0 commit comments