-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
176 lines (139 loc) · 3.9 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
169
170
171
172
173
174
cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0077 NEW) # overrides cmake options with predefined variables
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
project(
vae
VERSION 0.0.1
DESCRIPTION "Virtual Audio Engine"
LANGUAGES CXX
)
option(VAE_BUILD_SHARED_LIBS "Build shared lib" OFF) # if this is on vae_dev doesn't compile :/
option(VAE_PROFILER "Use profiler" OFF)
option(VAE_BACKEND_PORTAUDIO "Compile with port audio" OFF)
option(VAE_BACKEND_RTAUDIO "Compile with RtAudio" ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # needed for clang
# find_package will look for custom scripts in the cmake folder
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
################# add main lib #################
file(GLOB SRC_PIMPL_API "src/api/vae_pimpl.cpp")
file(GLOB SRC_C_API "src/api/vae_c_api.cpp")
file(GLOB SRC_CORE "src/core/*.hpp")
file(GLOB SRC_WRAPPED "src/wrapped/*.cpp")
file(GLOB SRC_DEVICE "src/core/device/*.hpp")
set(VAE_DEPS tklb) # Things to link against
set(VAE_DEFINES) # Preprocessor info about stuff being built
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND VAE_DEFINES "VAE_RELEASE")
if (NOT MSVC)
# add_compile_options(-march=native -mtune=native -Ofast)
endif()
endif()
function(VAE_ADD_SHARED)
message("VAE: shared build")
add_library(vae
SHARED
${SRC_CORE}
${SRC_WRAPPED}
${SRC_DEVICE}
)
list(APPEND VAE_DEFINES "VAE_DLL_EXPORT")
endfunction()
function(VAE_ADD_STATIC)
message("VAE: static build")
add_library(vae
STATIC
${SRC_CORE}
${SRC_WRAPPED}
${SRC_DEVICE}
)
endfunction()
if(DEFINED VAE_BUILD_SHARED_LIBS)
if (VAE_BUILD_SHARED_LIBS)
VAE_ADD_SHARED()
else()
VAE_ADD_STATIC()
endif()
else()
# standart cmake behavior
if (BUILD_SHARED_LIBS)
VAE_ADD_SHARED()
else()
VAE_ADD_STATIC()
endif()
endif()
source_group("core" FILES ${SRC_CORE})
# TODO there are a lot of warnings to take care of
# if (MSVC)
# # warning level 4 and all warnings as errors
# add_compile_options(/W4 /WX)
# else()
# # lots of warnings and all warnings as errors
# add_compile_options(-Wall -Wextra -pedantic -Werror)
# endif()
#Add an alias so that library can be used inside the build tree, e.g. when testing
# add_library(VAE::vae ALIAS vae)
################# find third party libs #################
find_package(tklb REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
list(APPEND VAE_DEPS Threads::Threads)
if(VAE_BACKEND_RTAUDIO)
find_package(RtAudio REQUIRED)
list(APPEND VAE_DEFINES "_VAE_HAS_RT_AUDIO")
message("VAE: Build with RtAudio")
list(APPEND VAE_DEPS rtaudio) # lower case smh
endif()
if(VAE_BACKEND_PORTAUDIO)
list(APPEND VAE_DEFINES "_VAE_HAS_PORT_AUDIO")
message("VAE: Build with portaudio")
find_package(PortAudio REQUIRED)
list(APPEND VAE_DEPS PortAudio)
endif()
# Goal is to have no public dependencies
target_include_directories(vae
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # the pimpl API
PRIVATE
${VAE_DEPS}
)
# optional profiler
if(VAE_PROFILER)
list(APPEND VAE_DEPS ${CMAKE_DL_LIBS})
list(APPEND VAE_DEFINES "VAE_USE_PROFILER")
message("VAE: Build with profiler")
endif()
# if (NOT MSVC)
# if (VAE_PROFILER)
# add_compile_options(-finstrument-functions)
# message("VAE: instrument functions")
# endif()
# endif()
target_compile_definitions(
vae
PUBLIC
${VAE_DEFINES}
)
target_link_libraries(vae PRIVATE ${VAE_DEPS})
# for developing
add_subdirectory(dev)
add_library(vae_pimpl
SHARED
${SRC_CORE}
${SRC_WRAPPED}
${SRC_DEVICE}
${SRC_PIMPL_API}
)
target_include_directories(vae_pimpl PRIVATE vae)
target_link_libraries(vae_pimpl PRIVATE vae)
add_library(vae_c_api
SHARED
${SRC_CORE}
${SRC_WRAPPED}
${SRC_DEVICE}
${SRC_C_API}
)
target_include_directories(vae_c_api PRIVATE vae)
target_link_libraries(vae_c_api PRIVATE vae)