-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
186 lines (166 loc) · 6.01 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
cmake_minimum_required(VERSION 3.26)
add_compile_definitions(JUCE_MODAL_LOOPS_PERMITTED=1)
# Read each line in the .env file
file(STRINGS .env ENV_LINES)
# Process each line
foreach(LINE ${ENV_LINES})
# Split the line into NAME and VALUE
string(REPLACE "=" ";" LINE_LIST ${LINE})
list(GET LINE_LIST 0 NAME)
list(GET LINE_LIST 1 VALUE)
# Process each name
if("${NAME}" STREQUAL "APP_NAME")
set(APP_NAME ${VALUE})
elseif("${NAME}" STREQUAL "APP_VERSION")
set(APP_VERSION ${VALUE})
elseif("${NAME}" STREQUAL "APP_BUNDLE")
set(APP_BUNDLE ${VALUE})
endif()
endforeach()
message(STATUS "APP_NAME: ${APP_NAME}")
message(STATUS "APP_VERSION: ${APP_VERSION}")
message(STATUS "APP_BUNDLE: ${APP_BUNDLE}")
set(ENV_FILE_PATH "${CMAKE_SOURCE_DIR}/.env")
if (UNIX AND NOT APPLE)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
add_compile_definitions(JUCE_USE_XRANDR=0)
add_definitions(-DJUCE_ENABLE_WIN32_FILETYPE_ASSOCIATION=1)
endif()
project(OctaSplit VERSION 1.0.1)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
file(GLOB_RECURSE ASSETS_FILES RELATIVE ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/Assets/*")
foreach(ASSETS_FILE ${ASSETS_FILES})
configure_file(${ASSETS_FILE} ${ASSETS_FILE} COPYONLY)
endforeach()
include(FetchContent)
FetchContent_Declare(
libsndfile
URL https://github.com/libsndfile/libsndfile/archive/refs/tags/1.2.2.tar.gz
)
FetchContent_Declare(
juce
URL https://github.com/juce-framework/JUCE/archive/refs/tags/7.0.6.tar.gz
)
FetchContent_MakeAvailable(libsndfile juce)
if (UNIX)
if (APPLE)
# Add these to your plist
set(MACOSX_BUNDLE_BUNDLE_NAME "${APP_NAME}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${APP_VERSION}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${APP_VERSION}")
set(MACOSX_BUNDLE_ICON_FILE MyIcon.icns)
set(APP_ICON_MACOSX ${CMAKE_SOURCE_DIR}/icon/MyIcon.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(MY_ICON_NAME "MyIcon")
set(MY_APP_NAME "${APP_NAME}")
set(MY_APP_VERSION "${APP_VERSION}")
set(MY_APP_BUNDLE "${APP_BUNDLE}")
configure_file(${CMAKE_SOURCE_DIR}/Info.plist.in ${CMAKE_BINARY_DIR}/Info.plist)
juce_add_gui_app(OctaSplit
PRODUCT_NAME "OctaSplit"
COMPANY_NAME "Stéphane Bressani - bressani.dev"
BUNDLE_ID "bressani.dev.octasplit"
ICON_BIG ${CMAKE_SOURCE_DIR}/icon/MyIcon.icns
INFOPLIST_FILE ${CMAKE_BINARY_DIR}/Info.plist
# Other options...
)
set_target_properties(OctaSplit PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/Info.plist)
else ()
juce_add_gui_app(OctaSplit
PRODUCT_NAME "OctaSplit"
COMPANY_NAME "Stéphane Bressani - bressani.dev"
BUNDLE_ID "bressani.dev.octasplit"
ICON_BIG ${CMAKE_SOURCE_DIR}/icon/MyIcon.icns
# Other options...
)
endif ()
else ()
set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_SOURCE_DIR}/icon/ap.rc")
juce_add_gui_app(OctaSplit
PRODUCT_NAME "OctaSplit"
COMPANY_NAME "Stéphane Bressani - bressani.dev"
BUNDLE_ID "bressani.dev.octasplit"
# Other options...
)
endif()
if (APPLE)
target_sources(OctaSplit PRIVATE
.env
Source/MyObjCWrapper.h
Source/MyObjCWrapper.mm
Source/Misc.h
Source/Misc.cpp
Source/MainComponent.h
Source/MainComponent.cpp
Source/Main.cpp
Source/AudioFileProperties.cpp
Source/AudioFileProperties.h
${APP_ICON_MACOSX}
)
else ()
target_sources(OctaSplit PRIVATE
.env
Source/MyObjCWrapper.h
Source/Misc.h
Source/Misc.cpp
Source/MainComponent.h
Source/MainComponent.cpp
Source/Main.cpp
Source/AudioFileProperties.cpp
Source/AudioFileProperties.h
icon/app.rc
#${APP_ICON_RESOURCE_WINDOWS}
)
endif ()
if (UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtk+-3.0)
pkg_check_modules(WEBKIT2GTK REQUIRED webkit2gtk-4.0)
pkg_check_modules(CURL REQUIRED libcurl)
include_directories(${GTK_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS} ${WEBKIT2GTK_LIBRARY_DIRS} ${CURL_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER} ${WEBKIT2GTK_CFLAGS_OTHER} ${CURL_CFLAGS_OTHER})
target_link_libraries(OctaSplit PRIVATE ${GTK_LIBRARIES} ${WEBKIT2GTK_LIBRARIES} ${CURL_LIBRARIES})
endif ()
if (APPLE)
find_library(COCOA_LIBRARY Cocoa)
endif ()
if (UNIX)
if (APPLE)
find_library(PORTAUDIO_LIBRARY portaudio)
find_path(PORTAUDIO_INCLUDE_DIR portaudio.h)
# Link the libraries to your target
target_link_libraries(OctaSplit PRIVATE
sndfile
juce::juce_audio_utils
${COCOA_LIBRARY}
# Other JUCE modules, third-party libraries...
)
else()
find_library(PORTAUDIO_LIBRARY portaudio)
find_path(PORTAUDIO_INCLUDE_DIR portaudio.h)
# Link the libraries to your target
target_link_libraries(OctaSplit PRIVATE
sndfile
juce::juce_audio_utils
# Other JUCE modules, third-party libraries...
)
endif()
else ()
# Link the libraries to your target
target_link_libraries(OctaSplit PRIVATE
sndfile
juce::juce_audio_utils
# Other JUCE modules, third-party libraries...
)
endif ()
add_custom_command(TARGET OctaSplit POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/Assets/ $<TARGET_FILE_DIR:OctaSplit>/Assets/)
add_custom_command(TARGET OctaSplit POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${ENV_FILE_PATH}
$<TARGET_FILE_DIR:OctaSplit>)