-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
142 lines (117 loc) · 5.58 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
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "arm64") # Prioritize ARM
option(BUILD_PY_MODULE "Build Python Module" OFF)
option(BUILD_PD_OBJECT "Build PureData Object" OFF)
option(BUILD_MAX_OBJECT "Build Max Object" OFF)
option(BUILD_ALL "Build Python Module and PureData Object" OFF)
# check if it is EMSCRIPTEN
if(EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_BOOST_HEADERS=1")
endif()
if(BUILD_ALL)
set(BUILD_PY_MODULE ON)
set(BUILD_PD_OBJECT ON)
# set(BUILD_MAX_OBJECT ON)
endif()
message(STATUS "BUILD_PY_MODULE: ${BUILD_PY_MODULE}")
message(STATUS "BUILD_PD_OBJECT: ${BUILD_PD_OBJECT}")
message(STATUS "BUILD_MAX_OBJECT: ${BUILD_MAX_OBJECT}")
# IF MAC, USE APPLE CLANG
if(APPLE)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
set(CMAKE_C_COMPILER "/usr/bin/clang")
endif()
project(OScofo LANGUAGES C CXX)
set(PDCMAKE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/Resources/pd.cmake/"
CACHE PATH "Path to pd.cmake")
include(${PDCMAKE_DIR}/pd.cmake)
# ╭──────────────────────────────────────╮
# │ FFTW3 │
# ╰──────────────────────────────────────╯
cmake_policy(SET CMP0135 NEW)
option(BUILD_SHARED_LIBS OFF)
option(BUILD_TESTS OFF)
set(FFTW3_FILE ${CMAKE_BINARY_DIR}/fftw-3.3.10.tar.gz)
if(NOT EXISTS ${FFTW3_FILE})
message(STATUS "Downloading FFTW3")
file(DOWNLOAD https://www.fftw.org/fftw-3.3.10.tar.gz ${FFTW3_FILE})
endif()
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/fftw-3.3.10.tar.gz DESTINATION
${CMAKE_CURRENT_SOURCE_DIR}/Libraries/)
add_subdirectory(Libraries/fftw-3.3.10 EXCLUDE_FROM_ALL)
set_target_properties(fftw3 PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${CMAKE_SOURCE_DIR})
set_target_properties(fftw3 PROPERTIES POSITION_INDEPENDENT_CODE ON)
# ╭──────────────────────────────────────╮
# │ Tree-Sitter │
# ╰──────────────────────────────────────╯
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(Libraries/tree-sitter/lib/ EXCLUDE_FROM_ALL)
find_program(TREE_SITTER_EXECUTABLE tree-sitter)
if(TREE_SITTER_EXECUTABLE)
message(STATUS "Tree-sitter executable found at ${TREE_SITTER_EXECUTABLE}")
execute_process(
COMMAND ${TREE_SITTER_EXECUTABLE} generate --no-bindings
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/Sources/OScofo/tree-sitter-score/
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error_output)
else()
message(
WARNING
"We will not generate the parser because the tree-sitter executable was not found. Please install tree-sitter-cli."
)
endif()
add_library(score_parser STATIC Sources/OScofo/tree-sitter-score/src/parser.c)
if(EMSCRIPTEN)
target_compile_options(score_parser PUBLIC -matomics -mbulk-memory)
target_compile_options(tree-sitter PUBLIC -matomics -mbulk-memory)
endif()
target_include_directories(score_parser
PUBLIC Libraries/tree-sitter/lib/include)
# ╭──────────────────────────────────────╮
# │ OScofo │
# ╰──────────────────────────────────────╯
list(APPEND SCofoSrc Sources/OScofo/mdp.cpp)
list(APPEND SCofoSrc Sources/OScofo/mir.cpp)
list(APPEND SCofoSrc Sources/OScofo/score.cpp)
list(APPEND SCofoSrc Sources/OScofo/OScofo.cpp)
add_library(OScofo STATIC ${SCofoSrc})
target_include_directories(OScofo PUBLIC Sources/OScofo/tree-sitter-score/src)
include_directories(OScofo PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/Libraries/fftw-3.3.10/api")
target_link_libraries(OScofo PUBLIC fftw3)
set_target_properties(OScofo PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(OScofo PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Sources/")
target_link_libraries(OScofo PUBLIC tree-sitter score_parser)
# Boost Libraries
if(NOT EMSCRIPTEN)
target_link_libraries(OScofo PUBLIC ${Boost_LIBRARIES})
cmake_policy(SET CMP0167 NEW)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
endif()
target_compile_options(OScofo PRIVATE $<$<CONFIG:DEBUG>:-g -O0>)
# ╭──────────────────────────────────────╮
# │ Python Module │
# ╰──────────────────────────────────────╯
if(BUILD_PY_MODULE)
add_subdirectory(Sources/Python)
endif()
# ╭──────────────────────────────────────╮
# │ PureData Object │
# ╰──────────────────────────────────────╯
if(BUILD_PD_OBJECT)
add_subdirectory(Sources/PureData)
target_compile_options(o.scofo_tilde PRIVATE $<$<CONFIG:DEBUG>:-g -O0>)
endif()
# ╭──────────────────────────────────────╮
# │ Max Obj │
# ╰──────────────────────────────────────╯
if(BUILD_MAX_OBJECT)
add_subdirectory(Sources/Max)
endif()