-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
157 lines (127 loc) · 4.25 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
cmake_minimum_required(VERSION 3.9.5)
project(pineapple-midi-player
VERSION 1.3.2
HOMEPAGE_URL "https://github.com/BLumia/pineapple-midi-player"
)
# This is optional. Arch Linux's portaudio package doesn't have CMake support (for now).
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(GNUInstallDirs)
option(USE_KIO "Use KIO-based open-with action" ON)
option(CONAN2_STATIC_QT_BUG "Workaround conan 2 static Qt issue, see conan-io/conan-center-index#23045" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt6 "6.4" REQUIRED COMPONENTS Widgets LinguistTools)
find_package(PortAudio REQUIRED)
if(USE_KIO)
find_package(ECM 6.0.0 NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(KF6KIO 6.0.0 COMPONENTS KIOWidgets)
endif()
if(NOT TARGET PortAudio::PortAudio AND TARGET portaudio)
# the current latest released tag (19.7.0) doesn't provide the PortAudio::portaudio target
add_library(PortAudio::PortAudio ALIAS portaudio)
endif()
set(EXE_NAME pmidi)
add_executable(${EXE_NAME} WIN32)
qt_add_resources(${EXE_NAME} resources.qrc
PREFIX "/icons"
FILES ./assets/icons/app-icon.svg
)
target_sources(${EXE_NAME}
PRIVATE
app/main.cpp
app/player.h
app/player.cpp
app/mainwindow.cpp
app/mainwindow.h
app/mainwindow.ui
app/seekableslider.cpp
app/seekableslider.h
app/settings.cpp
app/settings.h
app/playlistmanager.cpp
app/playlistmanager.h
# vendored libs
libs/tsf.h
libs/tml.h
libs/opl.h
libs/dr_wav.h
libs/stb_vorbis.c
libs/implements.c
)
target_include_directories(${EXE_NAME} PRIVATE app)
qt_add_translations(${EXE_NAME}
TS_FILES
translations/pineapple-midi-player.ts
translations/pineapple-midi-player.de.ts
translations/pineapple-midi-player.zh_CN.ts
)
target_compile_definitions(${EXE_NAME} PRIVATE
PMIDI_VERSION_STRING="${CMAKE_PROJECT_VERSION}"
)
if (WIN32)
target_sources(${EXE_NAME} PRIVATE assets/pineapple-midi-player.rc)
# Extra build settings
target_compile_definitions(${EXE_NAME} PRIVATE
FLAG_PORTABLE_MODE_SUPPORT=1
)
endif ()
target_include_directories(${EXE_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/libs)
target_link_libraries(${EXE_NAME} PRIVATE Qt6::Widgets PortAudio::PortAudio)
if (TARGET KF6::KIOWidgets)
target_link_libraries(${EXE_NAME} PRIVATE KF6::KIOWidgets)
target_compile_definitions(${EXE_NAME} PRIVATE HAVE_KIO)
endif ()
if (CONAN2_STATIC_QT_BUG)
target_link_libraries(${EXE_NAME} PRIVATE Qt6::QWindowsIntegrationPlugin)
target_compile_definitions(${EXE_NAME} PRIVATE CONAN2_STATIC_QT_BUG)
endif ()
# Install -------------------------------------
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Devel
)
install(
TARGETS ${EXE_NAME}
${INSTALL_TARGETS_DEFAULT_ARGS}
)
if (UNIX)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
# install icon
install(
FILES assets/icons/app-icon.svg
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps"
RENAME net.blumia.pineapple-midi-player.svg
)
# install shortcut
install(
FILES dist/net.blumia.pineapple-midi-player.desktop
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
)
# install app metadata file for appstream (and some other stuff using this metadata like snapcraft)
install(
FILES dist/appstream/net.blumia.pineapple-midi-player.metainfo.xml
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
)
endif ()
set(CPACK_GENERATOR "TBZ2")
set(CPACK_PACKAGE_NAME "pineapple-midi-player")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A simple SoundFont MIDI Player")
set(CPACK_PACKAGE_VENDOR "Gary Wang")
set(CPACK_PACKAGE_CONTACT "https://github.com/BLumia/pineapple-midi-player/issues/")
if(WIN32)
# ...
elseif (APPLE)
# ...
elseif (UNIX)
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "timgm6mb-soundfont")
endif()
include(CPack)