-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
168 lines (149 loc) · 6.28 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
cmake_minimum_required(VERSION 3.22)
project(MUSE_GPT VERSION 0.0.1)
add_subdirectory(JUCE)
# Setup JUCE build settings, source code and compile definitions
juce_add_plugin(musegpt
NEEDS_WEB_BROWSER TRUE
PLUGIN_MANUFACTURER_CODE Grey
PLUGIN_CODE Muse
FORMATS AAX AU AUv3 VST3 Standalone
PRODUCT_NAME "musegpt"
COPY_PLUGIN_AFTER_BUILD TRUE
NEEDS_WEBVIEW2 TRUE)
juce_generate_juce_header(musegpt)
target_sources(musegpt
PRIVATE
src/main.cpp
src/LlamaServer.cpp)
target_compile_definitions(musegpt
PUBLIC
JUCE_DEBUG=1 # Enable debug mode
JUCE_LOGGING=1 # Enable logging
JUCE_STRICT_REFCOUNTEDPOINTER=1
JUCE_WEB_BROWSER=1
JUCE_USE_WIN_WEBVIEW2_WITH_STATIC_LINKING=1
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0)
target_link_libraries(musegpt
PRIVATE
juce::juce_audio_basics
juce::juce_audio_devices
juce::juce_audio_formats
juce::juce_audio_plugin_client
juce::juce_audio_processors
juce::juce_dsp
juce::juce_audio_utils
juce::juce_core
juce::juce_data_structures
juce::juce_events
juce::juce_graphics
juce::juce_gui_basics
juce::juce_gui_extra
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
# Debug-specific settings
target_compile_definitions(musegpt
PRIVATE
$<$<CONFIG:Debug>:DEBUG=1>
$<$<CONFIG:Debug>:_DEBUG=1>
)
# Release-specific settings
target_compile_definitions(musegpt
PRIVATE
$<$<CONFIG:Release>:NDEBUG=1>
$<$<CONFIG:Release>:JUCE_DISABLE_ASSERTIONS=1>
)
# Set optimization flags
target_compile_options(musegpt
PRIVATE
$<$<CONFIG:Debug>:-O0 -g>
$<$<CONFIG:Release>:-O3>
)
# Add llama-server as a binary resource and copy files
if(WIN32)
# Windows-specific commands
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/build/llama.cpp/bin/$<CONFIG>/llama-server.exe
${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe
DEPENDS ${CMAKE_SOURCE_DIR}/build/llama.cpp/bin/$<CONFIG>/llama-server.exe
)
add_custom_target(copy_llama_server ALL DEPENDS ${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe)
set_source_files_properties(${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
target_sources(musegpt PRIVATE ${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe)
# Copy llama-server to VST plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe
$<TARGET_FILE_DIR:musegpt>/VST3/musegpt.vst3/Contents/Resources/llama-server.exe
)
# Copy llama-server to Standalone plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/$<CONFIG>/llama-server.exe
$<TARGET_FILE_DIR:musegpt>/musegpt.exe/llama-server.exe
)
# Copy model weights to VST plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/models/gemma-2b-it.fp16.gguf
$<TARGET_FILE_DIR:musegpt>/VST3/musegpt.vst3/Contents/Resources/gemma-2b-it.fp16.gguf
)
# Copy model weights to Standalone plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/models/gemma-2b-it.fp16.gguf
$<TARGET_FILE_DIR:musegpt>/musegpt.exe/gemma-2b-it.fp16.gguf
)
else()
# Non-Windows commands
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/llama-server
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/build/llama.cpp/bin/llama-server
${CMAKE_BINARY_DIR}/llama-server
DEPENDS ${CMAKE_SOURCE_DIR}/build/llama.cpp/bin/llama-server
)
add_custom_target(copy_llama_server ALL DEPENDS ${CMAKE_BINARY_DIR}/llama-server)
set_source_files_properties(${CMAKE_BINARY_DIR}/llama-server PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
target_sources(musegpt PRIVATE ${CMAKE_BINARY_DIR}/llama-server)
# Copy llama-server to VST plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/llama-server
$<TARGET_FILE_DIR:musegpt>/VST3/musegpt.vst3/Contents/Resources/llama-server
)
# Copy llama-server to Standalone plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/llama-server
$<TARGET_FILE_DIR:musegpt>/Standalone/musegpt.app/Contents/Resources/llama-server
)
# Copy model weights to VST plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/models/gemma-2b-it.fp16.gguf
$<TARGET_FILE_DIR:musegpt>/VST3/musegpt.vst3/Contents/Resources/gemma-2b-it.fp16.gguf
)
# Copy model weights to Standalone plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/models/gemma-2b-it.fp16.gguf
$<TARGET_FILE_DIR:musegpt>/Standalone/musegpt.app/Contents/Resources/gemma-2b-it.fp16.gguf
)
# Copy model weights to AAX plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/models/gemma-2b-it.fp16.gguf
$<TARGET_FILE_DIR:musegpt>/AAX/musegpt.aaxplugin/Contents/Resources/gemma-2b-it.fp16.gguf
)
# Copy model weights to AU plugin format's output directory
add_custom_command(TARGET musegpt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/models/gemma-2b-it.fp16.gguf
$<TARGET_FILE_DIR:musegpt>/AU/musegp.component/Contents/Resources/gemma-2b-it.fp16.gguf
)
endif()