-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
123 lines (102 loc) · 3.86 KB
/
CMakeLists.txt
File metadata and controls
123 lines (102 loc) · 3.86 KB
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
set(CMAKE_VERBOSE_MAKEFILE ON)
cmake_minimum_required(VERSION 3.15)
project(SimdSynth VERSION 1.0.0 LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# By default we don't want Xcode schemes to be made for modules, etc
#set(CMAKE_XCODE_GENERATE_SCHEME OFF)
# set(CMAKE_OSX_ARCHITECTURES arm64 x86_64)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Support macOS down to High Sierra")
include(FetchContent)
# Fetch JUCE
FetchContent_Declare(
juce
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
GIT_TAG 8.0.9 # Replace with the desired JUCE version
)
FetchContent_MakeAvailable(juce)
# Define plugin
juce_add_plugin(SimdSynth
VERSION "1.0.0"
COMPANY_NAME "seclorum"
PLUGIN_MANUFACTURER_CODE "SCLR"
PLUGIN_CODE "SmSy"
FORMATS AU VST3 Standalone
PRODUCT_NAME "SimdSynth"
IS_SYNTH TRUE
NEEDS_MIDI_INPUT TRUE
NEEDS_MIDI_OUTPUT FALSE
IS_MIDI_EFFECT FALSE
)
# Add the generated header path (e.g., JuceHeader.h)
juce_generate_juce_header(SimdSynth)
target_include_directories(SimdSynth PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(SimdSynth INTERFACE ${juce_generated_headers_directory})
# Source files
target_sources(SimdSynth
PRIVATE
Source/PluginProcessor.cpp
Source/PluginProcessor.h
Source/PluginEditor.cpp
Source/PluginEditor.h
Source/PluginEntry.cpp
Source/PresetManager.cpp
Source/PresetManager.h
)
# Link JUCE modules
target_link_libraries(SimdSynth
PRIVATE
juce::juce_audio_utils
juce::juce_dsp
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
)
# Define compile definitions
target_compile_definitions(SimdSynth
PUBLIC
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0
)
# Copy plugin to standard plugin directories after build
juce_enable_copy_plugin_step(SimdSynth)
message("Processor: ${CMAKE_SYSTEM_PROCESSOR}")
# SIMD compiler flags
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
target_compile_options(SimdSynth PRIVATE -msse -msse2 -msse4.1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
if(APPLE)
# For Apple Silicon (M1, M2, etc.), NEON is enabled by default, but we can ensure it
target_compile_options(SimdSynth PRIVATE -mcpu=apple-m1)
else()
# For Linux on aarch64 (e.g., Raspberry Pi 4 with Cortex-A72), enable NEON SIMD
target_compile_options(SimdSynth PRIVATE -march=armv8-a+simd -mtune=cortex-a72)
endif()
endif()
# Linux-specific section
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Custom compile options for Linux (CFLAGS equivalents in CMake)
target_compile_options(SimdSynth PRIVATE -O3 -g)
# Use CMake's FindFreetype module to locate freetype2-dev automatically
find_package(Freetype REQUIRED)
target_include_directories(SimdSynth PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(SimdSynth PRIVATE ${FREETYPE_LIBRARIES})
# Ensure NEON is utilized for aarch64 on Linux
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# Define JUCE_USE_SIMD to enable JUCE's SIMD optimizations
target_compile_definitions(SimdSynth PRIVATE JUCE_USE_SIMD=1)
endif()
endif()
# Alternative - TODO: Check on other arm targets, etc.
## SIMD compiler flags
#if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
# target_compile_options(SimdSynth PRIVATE -msse -msse2 -msse4.1)
#elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
# # NEON is typically enabled by default on ARM64, but we can ensure compatibility
# target_compile_options(SimdSynth PRIVATE -march=armv8-a)
#endif()
# Enable strict warnings
target_compile_options(SimdSynth PRIVATE -Wall -Wextra -Wpedantic)