-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (146 loc) · 5.25 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
cmake_minimum_required(VERSION "3.7")
project(WaveTableTools)
set(CMAKE_CXX_STANDARD 11)
option(WAVE_TABLE_TOOLS_ENABLE_UI "Enable UI" ON)
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
string(APPEND CMAKE_CXX_FLAGS " -Wall")
endif()
if(MINGW)
string(APPEND CMAKE_C_FLAGS " -municode")
string(APPEND CMAKE_CXX_FLAGS " -municode")
endif()
if(WIN32)
add_definitions("-D_CRT_SECURE_NO_WARNINGS=1")
endif()
add_subdirectory("thirdparty/kiss_fft" EXCLUDE_FROM_ALL)
add_subdirectory("thirdparty/span-lite" EXCLUDE_FROM_ALL)
add_library(dr_wav INTERFACE)
target_include_directories(dr_wav INTERFACE "thirdparty/dr_libs")
#
find_package(PkgConfig)
#
include(GNUInstallDirs)
#
add_library(WLib STATIC
"sources/Random.h"
"sources/Wavetable.h"
"sources/Wavetable.cpp"
"sources/WaveFormula.h"
"sources/WaveFormula.cpp"
"sources/series/SeriesExpr.h"
"sources/series/SeriesExpr.cpp"
"sources/series/SeriesExprGrammar.tab.cpp"
"sources/series/SeriesExprGrammar.tab.h"
"sources/series/SeriesExprGrammar.yy.cpp"
"sources/series/SeriesExprGrammar.yy.h"
"sources/series/SeriesExprGrammarExtra.h"
"sources/utility/Locale.h")
#if(TRUE)
# target_compile_definitions(WLib PRIVATE "YYDEBUG=1")
#endif()
target_include_directories(WLib PUBLIC
"sources")
target_link_libraries(WLib PRIVATE
sfizz-kissfft)
#
add_executable(WCreate
"sources/WCreate.cpp"
"sources/utility/unicodefile.h"
"sources/utility/unicodefile.c")
target_link_libraries(WCreate PRIVATE WLib)
#
add_executable(WMorph
"sources/WMorph.cpp"
"sources/utility/unicodefile.h"
"sources/utility/unicodefile.c")
target_link_libraries(WMorph PRIVATE WLib dr_wav)
#
find_program(FLEX_PROGRAM "flex")
find_program(BISON_PROGRAM "bison")
if(FLEX_PROGRAM AND BISON_PROGRAM)
add_custom_command(
OUTPUT "${PROJECT_SOURCE_DIR}/sources/series/SeriesExprGrammar.tab.cpp"
COMMAND "${BISON_PROGRAM}" "--output=SeriesExprGrammar.tab.cpp" "--defines=SeriesExprGrammar.tab.h" "SeriesExprGrammar.y"
DEPENDS "${PROJECT_SOURCE_DIR}/sources/series/SeriesExprGrammar.y"
BYPRODUCTS "${PROJECT_SOURCE_DIR}/sources/series/SeriesExprGrammar.tab.h"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/sources/series")
add_custom_command(
OUTPUT "${PROJECT_SOURCE_DIR}/sources/series/SeriesExprGrammar.yy.cpp"
COMMAND "${FLEX_PROGRAM}" "--outfile=SeriesExprGrammar.yy.cpp" "--header-file=SeriesExprGrammar.yy.h" "SeriesExprGrammar.l"
DEPENDS "${PROJECT_SOURCE_DIR}/sources/series/SeriesExprGrammar.l"
BYPRODUCTS "${PROJECT_SOURCE_DIR}/sources/series/SeriesExprGrammar.yy.h"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/sources/series")
endif()
#
if(WAVE_TABLE_TOOLS_ENABLE_UI)
find_package(SDL2 REQUIRED)
set(OpenGL_GL_PREFERENCE "GLVND")
find_package(OpenGL REQUIRED)
if(WIN32)
elseif(APPLE)
find_library(APPKIT_FRAMEWORK "AppKit")
else()
pkg_check_modules(Gtk3 "gtk+-3.0" REQUIRED IMPORTED_TARGET)
endif()
#
add_library(imgui STATIC
"thirdparty/imgui/imgui.cpp"
"thirdparty/imgui/imgui_draw.cpp"
"thirdparty/imgui/imgui_widgets.cpp"
"thirdparty/imgui/misc/cpp/imgui_stdlib.cpp")
target_include_directories(imgui PUBLIC
"thirdparty/imgui"
"thirdparty/imgui/misc/cpp")
#
add_library(implot STATIC
"thirdparty/implot/implot.cpp"
"thirdparty/implot/implot_items.cpp")
target_include_directories(implot PUBLIC "thirdparty/implot")
target_link_libraries(implot PUBLIC imgui)
#
add_library(imgui-backend STATIC
"thirdparty/imgui/backends/imgui_impl_sdl.cpp"
"thirdparty/imgui/backends/imgui_impl_opengl2.cpp")
target_include_directories(imgui-backend PUBLIC
"thirdparty/imgui"
"thirdparty/imgui/backends")
if(MSVC AND TARGET SDL2::SDL2-static)
target_link_libraries(imgui-backend PUBLIC SDL2::SDL2-static)
elseif(TARGET SDL2::SDL2)
target_link_libraries(imgui-backend PUBLIC SDL2::SDL2)
else()
target_include_directories(imgui-backend PUBLIC ${SDL2_INCLUDE_DIRS})
target_link_libraries(imgui-backend PUBLIC ${SDL2_LIBRARIES})
endif()
target_link_libraries(imgui-backend PUBLIC OpenGL::GL)
#
add_library(osdialog STATIC "thirdparty/osdialog/osdialog.c")
target_include_directories(osdialog PUBLIC "thirdparty/osdialog")
if(WIN32)
target_sources(osdialog PRIVATE "thirdparty/osdialog/osdialog_win.c")
target_link_libraries(osdialog PRIVATE "comdlg32")
elseif(APPLE)
target_sources(osdialog PRIVATE "thirdparty/osdialog/osdialog_mac.m")
target_link_libraries(osdialog PRIVATE "${APPKIT_FRAMEWORK}")
else()
target_sources(osdialog PRIVATE "thirdparty/osdialog/osdialog_gtk3.c")
target_link_libraries(osdialog PRIVATE PkgConfig::Gtk3)
endif()
#
add_executable(WEdit WIN32
"sources/interactive/WEdit.cpp"
"sources/interactive/dsp/Wavetables.cpp"
"sources/interactive/dsp/Wavetables.h"
"sources/utility/unicodefile.h"
"sources/utility/unicodefile.c"
"sources/utility/utf8main.c")
target_link_libraries(WEdit PRIVATE WLib implot imgui imgui-backend osdialog sfizz-kissfft nonstd::span-lite)
if(NOT (WIN32 OR APPLE))
target_link_libraries(WEdit PRIVATE PkgConfig::Gtk3)
endif()
endif()
#
install(TARGETS WCreate WMorph RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(WAVE_TABLE_TOOLS_ENABLE_UI)
install(TARGETS WEdit RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()