-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
213 lines (188 loc) · 7.68 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
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
cmake_minimum_required(VERSION 3.10)
project(csound-ac)
find_package(Doxygen REQUIRED)
message("CMAKE BUILD SYSTEM FOR CSOUND-AC")
message("For a fresh build, run 'bash fresh-build-linux.sh'")
include("Custom.cmake" OPTIONAL RESULT_VARIABLE CSOUND_AC_CUSTOM_CONFIGURATION)
message("CSOUND_AC_CUSTOM_CONFIGURATION: ${CSOUND_AC_CUSTOM_CONFIGURATION}")
# A certain amount of the following has been copied from the core Csound project,
# and hoisted up here to enable paths etc. to be set for all projects here.
# Top-level CMake configuration.
include(ExternalProject)
set(CMAKE_CXX_STANDARD 17)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
add_compile_options(/WX-)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-deprecated-declarations -Wno-sign-compare -Wno-unknown-pragmas -Wno-misleading-indentation -Wno-writable-strings")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
# add_compile_options(-Wno-c++11-narrowing)
endif()
# CMAKE_SYSTEM_NAME relevant here can be Darwin, Windows, Linux, or Android.
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(GENERATE_DOCUMENTS ON)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "csound-ac")
if(DARWIN)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_INSTALL_RPATH "/opt/homebrew/lib;/usr/local/lib;~/.local/lib;")
set(CMAKE_PREFIX_PATH "/opt/homebrew;")
else()
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/local-linux")
endif()
add_definitions(-Dlinux)
set(APIVERSION "7.1")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/dependencies/csound/cmake/Modules")
message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
set(ALLOW_DUPLICATE_CUSTOM_TARGETS "Yes")
add_definitions(-DUSE_DOUBLE)
set(USE_DOUBLE "Yes")
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BUILD_PLUGINS_DIR ${BUILD_DIR})
set(BUILD_BIN_DIR ${BUILD_DIR})
set(BUILD_LIB_DIR ${BUILD_DIR})
set(EXECUTABLE_INSTALL_DIR "bin")
option(USE_LIB64 "Set to on to set installation directory for libraries to lib64" OFF)
if(USE_LIB64)
set(LIBRARY_INSTALL_DIR "lib64")
add_definitions("-DLIB64")
else()
set(LIBRARY_INSTALL_DIR "lib")
endif()
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CPACK_PACKAGING_INSTALL_PREFIX: ${CPACK_PACKAGING_INSTALL_PREFIX}")
message(STATUS "BUILD_BIN_DIR: ${BUILD_BIN_DIR}")
message(STATUS "BUILD_LIB_DIR: ${BUILD_LIB_DIR}")
message(STATUS "LIBRARY INSTALL DIR: ${LIBRARY_INSTALL_DIR}")
message(STATUS "PLUGIN_INSTALL_DIR: ${PLUGIN_INSTALL_DIR}")
option(USE_LRINT "Use lrint/lrintf for converting floating point values to integers." ON)
option(USE_CURL "Use CURL library" ON)
# All dependencies are to be located from here.
# Local TARGETS are not PACKAGES!
# Locally installed packages must be searched locally first!
# Locally built packages must be searched locally first!
# First we locate all system packages, these are used to make the Ubuntu
# csound-ac package, even though local packages may be used for other
# targets.
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
set(CMAKE_PREFIX_PATH /usr/local)
find_package(Csound REQUIRED)
message("CSOUND_LIBRARIES: ${CSOUND_LIBRARIES}")
# SHOULD find: CsoundLib64.framework/Versions/6.0/Headers/
message("CSOUND_INCLUDE_DIRS: ${CSOUND_INCLUDE_DIRS}")
message("CSOUND_INCLUDE_PATH: ${CSOUND_INCLUDE_PATH}")
include_directories("/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers/")
find_library(LIBSNDFILE_LIBRARY sndfile REQUIRED)
set(EIGEN3_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/dependencies/eigen")
message("[DEBUG] EIGEN3_INCLUDE_DIRS: ${EIGEN3_INCLUDE_DIRS}")
find_package(OpenCV)
find_package(Boost REQUIRED)
message("[DEBUG] Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}")
message("[DEBUG] Boost_COMPONENTS: ${Boost_COMPONENTS}")
find_package(Python3 3.12 EXACT COMPONENTS Interpreter Development)
find_package(SWIG)
include(UseSWIG)
find_package(SWIG)
if(LIBSNDFILE_INCLUDE_DIR)
include_directories("${LIBSNDFILE_INCLUDE_DIR}")
endif()
# Boost conflicts with GitHub's Windows runner, which #defines
# both `WIN32` and `linux`.
if(UNISTD_WIN32_INCLUDE_DIR)
include_directories("${UNISTD_WIN32_INCLUDE_DIR}")
endif()
include_directories("${CSOUND_INCLUDE_DIR}")
include_directories("${CSOUND_INCLUDE_DIR}/csound")
include_directories("${CSOUND_SOURCE_HOME}/interfaces")
# Copied from dependencies/csound/CMakeLists.txt:
# Checks if dependencies for an enabled target are fulfilled.
# If FAIL_MISSING is true and the dependencies are not fulfilled,
# it will abort the cmake run.
# If FAIL_MISSING is false, it will set the option to OFF.
# If the target is not enabled, it will do nothing.
# example: check_deps(BUILD_NEW_PARSER FLEX_EXECUTABLE BISON_EXECUTABLE)
function(check_deps option)
if(${option})
set(i 1)
while( ${i} LESS ${ARGC} )
set(dep ${ARGV${i}})
if(NOT ${dep})
if(FAIL_MISSING)
message(FATAL_ERROR
"${option} is enabled, but ${dep}=\"${${dep}}\"")
else()
message(STATUS "${dep}=\"${${dep}}\", so disabling ${option}")
set(${option} OFF PARENT_SCOPE)
# Set it in the local scope too
set(${option} OFF)
endif()
endif()
math(EXPR i "${i}+1")
endwhile()
endif()
if(${option})
message(STATUS "${option} is enabled.")
else()
message(STATUS "${option} is disabled.")
endif()
endfunction(check_deps)
add_subdirectory(dependencies/libmusicxml/build)
add_subdirectory(CsoundAC)
if(${GENERATE_DOCUMENTS})
message("Generating documentation.")
add_custom_target(doxygen_reference
ALL
COMMAND ./latex.sh
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/doc")
else()
message("Not generating documentation.")
endif()
# These are the real targets: the packages.
set(CPACK_COMPONENTS_ALL csound-ac)
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE "OFF")
set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_CONTACT "Michael Gogins <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_NAME "csound-ac")
set(CPACK_PACKAGE_VERSION "0.5.0")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/copyright.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
install(FILES ${CMAKE_SOURCE_DIR}/copyright.txt
DESTINATION share/doc/${CPACK_PACKAGE_NAME}
RENAME copyright)
if(${GENERATE_DOCUMENTS})
install(FILES ${CMAKE_SOURCE_DIR}/doc/latex/csound-ac.pdf
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/html
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/patches
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/patches
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/playpen
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
# And all the README.md files, renamed to not conflict...
install(FILES "README.md"
DESTINATION .
RENAME "README-CSOUND-AC.md")
install(FILES "README.md"
DESTINATION share/doc/${CPACK_PACKAGE_NAME}
RENAME "README-CSOUND-AC.md")
install(FILES "LICENSE"
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(FILES "LICENSE"
DESTINATION .
RENAME "LICENSE-CSOUND-AC")
install(FILES "REALTIME-AUDIO.md"
DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(FILES "patches/README.md"
DESTINATION share/doc/${CPACK_PACKAGE_NAME}
RENAME "README-CSOUND-PATCHES.md")
install(FILES "silencio/README.md"
DESTINATION share/doc/${CPACK_PACKAGE_NAME}
RENAME "README-SILENCIO.md")
install(FILES "playpen/README.md"
DESTINATION share/doc/${CPACK_PACKAGE_NAME}
RENAME "README-PLAYPEN.md")
include (CPack)