blob: fb38a90f75c8e741322ff9eec18f3d6f20dc61f9 (
plain)
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
project("csound_sqldb")
cmake_minimum_required(VERSION 3.8)
set(APIVERSION "6.0")
# Release or Debug
set(CMAKE_BUILD_TYPE "Release")
# force make to print the command lines
set(CMAKE_VERBOSE_MAKEFILE on)
# path to Csound cmake module
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# set compilation flags
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11 -fpermissive -fPIC -w -DUSE_DOUBLE -DB64BIT")
# options
option(USE_LIB64 "Set to on to set installation dir for libs to lib64" OFF)
option(USE_DOUBLE "Use doubles for audio calculations" ON)
option(CPP11 "c++11" ON)
set(BUILDING_CSOUND_PLUGINS ON)
# ----------------------------------------------
include(FindCsound)
include(FindPostgreSQL)
include(FindSqlite3)
include(FindMySQL)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
# -----------------------------------------------
function(addflag flag flagname)
check_c_compiler_flag(${flag} ${flagname})
if (${flagname})
# message(STATUS "Setting C flag ${flag}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
endif()
check_cxx_compiler_flag(${flag} CXX_${flagname})
if (CXX_${flagname})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
endfunction(addflag)
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
message(STATUS "looking at ${child}")
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
MACRO(ADD_ALL_SUBDIRECTORIES directory)
subdirlist(SUBDIRS ${directory})
message(STATUS "Found subdirs: ${SUBDIRS}")
foreach(SUBDIR ${SUBDIRS})
set(thissubdir "${directory}/${SUBDIR}")
if(EXISTS "${directory}/${SUBDIR}/CMakeLists.txt")
message(STATUS "Adding subdir: ${thissubdir}")
add_subdirectory(${directory}/${SUBDIR})
else()
message(WARNING "Skipping ${directory}/${SUBDIR} because no CMakeLists.txt file was found")
endif()
endforeach()
ENDMACRO()
# set optimization flags
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
add_definitions(-fvisibility=hidden)
if(NATIVE)
add_definitions(-march=native)
endif()
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
addflag(-msse HAS_SSE)
addflag(-msse2 HAS_SSE2)
addflag(-mfgpath=sse HAS_FPMATH_SSE)
endif()
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mstackrealign")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
endif()
addflag(-ftree-vectorize HAS_TREE_VECTORIZE)
addflag(-ffast-math HAS_FAST_MATH)
addflag(-fomit-frame-pointer HAS_OMIT_FRAME_POINTER)
# -------------------------------------------------------------------
set(CS_FRAMEWORK_DEST "~/Library/Frameworks")
if(USE_LIB64)
set(LIBRARY_INSTALL_DIR "lib64")
add_definitions("-DLIB64")
else()
set(LIBRARY_INSTALL_DIR "lib")
endif()
message(STATUS "LIBRARY INSTALL DIR: ${LIBRARY_INSTALL_DIR}")
# -------------------------------------------------------------------
if(USE_DOUBLE)
message(STATUS ">>> using doubles")
if(APPLE)
set(CSOUNDLIB "CsoundLib64")
set(PLUGIN_INSTALL_DIR "${CS_FRAMEWORK_DEST}/${CSOUNDLIB}.framework/Versions/${APIVERSION}/Resources/Opcodes64")
else()
set(CSOUNDLIB "csound64")
set(PLUGIN_INSTALL_DIR "${LIBRARY_INSTALL_DIR}/csound/plugins64-${APIVERSION}")
endif()
else()
message(STATUS ">>> not using doubles")
if(APPLE)
set(CSOUNDLIB "CsoundLib")
set(PLUGIN_INSTALL_DIR "${CS_FRAMEWORK_DEST}/${CSOUNDLIB}.framework/Versions/${APIVERSION}/Resources/Opcodes")
else()
set(CSOUNDLIB "csound")
set(PLUGIN_INSTALL_DIR "${LIBRARY_INSTALL_DIR}/csound/plugins-${APIVERSION}")
endif()
endif()
# -------------------------------------------------------------------
# Csound opcode build
find_package(Csound)
set(BUILD_PLUGINS_DIR ${CMAKE_CURRENT_BINARY_DIR})
if(NOT CSOUND_FOUND)
message(FATAL_ERROR "Csound installation not found")
endif()
if(NOT PostgreSQL_FOUND AND NOT SQLITE3_FOUND AND NOT MYSQLCONNECTORCPP_FOUND)
message(FATAL_ERROR "No database libraries could be found")
endif()
#
#if(APPLE)
# add_library(sqldb SHARED ${srcs})
#else()
# add_library(sqldb MODULE ${srcs})
#endif()
set(CPPFILES src/opcodes.cpp src/connection.cpp)
if (PostgreSQL_FOUND)
message(STATUS "Using PostgreSQL")
list(APPEND CPPFILES "src/postgresql.cpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_POSTGRES")
endif()
if (SQLITE3_FOUND)
message(STATUS "Using SQLite3")
list(APPEND CPPFILES "src/sqlite3.cpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_SQLITE")
endif()
if (MYSQLCONNECTORCPP_FOUND)
message(STATUS "Using MySQL")
list(APPEND CPPFILES "src/mysql.cpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_MYSQL")
endif()
#include_directories(/usr/include)
include_directories(${CSOUND_INCLUDE_DIRS})
include_directories(include)
if (PostgreSQL_FOUND)
link_libraries(${PostgreSQL_LIBRARIES})
include_directories(${PostgreSQL_INCLUDE_DIRS})
endif()
if (SQLITE3_FOUND)
link_libraries(${SQLITE3_LIBRARIES})
include_directories(${SQLITE3_INCLUDE_DIRS})
endif()
if (MYSQLCONNECTORCPP_FOUND)
link_libraries(${MYSQLCONNECTORCPP_LIBRARIES})
include_directories(${MYSQLCONNECTORCPP_INCLUDE_DIRS})
endif()
add_library(sqldb SHARED ${CPPFILES})
set_target_properties(sqldb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR}
LIBRARY_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR})
install(TARGETS sqldb LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}" )
|