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