blob: f88e6a13dcf51d8c92a84f65b13975b86dd46c04 (
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
|
project("csound_sdl")
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(FindSDL2)
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 SDL2_FOUND)
message(FATAL_ERROR "SDL2 cannot be found")
endif()
set(CPPFILES src/opcodes.cpp)
include_directories(${CSOUND_INCLUDE_DIRS})
include_directories(include)
link_libraries(${SDL2_LIBRARY})
include_directories(${SDL2_INCLUDE_DIR})
add_library(sdl SHARED ${CPPFILES})
set_target_properties(sdl PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR}
LIBRARY_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR})
install(TARGETS sdl LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}" )
|