-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
199 lines (170 loc) · 8.56 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
##############################################################################
# This file is part of Metronomek #
# Copyright (C) 2021-2022 by Tomasz Bojczuk ([email protected]) #
# on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) #
##############################################################################
cmake_minimum_required(VERSION 3.14)
set(METRONOMEK_VER "0.6.7-devel")
#WARNING Keep above line exactly as 9th line of this file.
# Needed for CD/CI to obtain version
if (WIN32)
# GitHub actions use this file to get version number
file(WRITE ${CMAKE_BINARY_DIR}/VERSION.txt "${METRONOMEK_VER}")
endif()
project(metronomek LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt5 COMPONENTS Core Gui Widgets Quick Network REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Widgets Quick Network REQUIRED)
if (Qt5Widgets_FOUND)
if (Qt5Widgets_VERSION VERSION_LESS 5.12.0)
message(FATAL_ERROR "Minimum supported Qt version is 5.12.0")
endif()
endif()
configure_file(${CMAKE_SOURCE_DIR}/src/metronomek_conf_cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/metronomek_conf.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
##############################################################################
# Compilation #
# (inside src directory) #
##############################################################################
add_subdirectory(src)
##############################################################################
# Installation #
# (ignored under Android) #
##############################################################################
if(WIN32)
install(TARGETS metronomek DESTINATION .)
set(INS_PREF ".")
option(COPY_GCC_LIBS "Copy compiler specific libraries during install target" ON)
else()
if (APPLE)
install(TARGETS metronomek DESTINATION "${CMAKE_INSTALL_PREFIX}/metronomek.app/Contents/MacOs")
set(INS_PREF "metronomek.app/Contents/Resources")
else()
install(TARGETS metronomek DESTINATION bin)
set(INS_PREF "share/metronomek")
endif()
endif()
# Sound samples
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sounds" DESTINATION "${INS_PREF}")
install(FILES LICENSE CHANGELOG.md DESTINATION "${INS_PREF}")
# translations (*.qm)
file(GLOB QM_STUFF "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.qm")
install(FILES ${QM_STUFF} DESTINATION "${INS_PREF}/translations")
# Icons & other stuff
if (WIN32)
install(FILES images/metronomek.ico images/pack.ico images/logo.bmp DESTINATION "${INS_PREF}/images")
# MINGW libraries and SSL
if (COPY_GCC_LIBS)
get_filename_component(MAKE_DIR "${CMAKE_RC_COMPILER}" DIRECTORY)
install(FILES "${MAKE_DIR}/libgcc_s_dw2-1.dll" "${MAKE_DIR}/libstdc++-6.dll" "${MAKE_DIR}/libwinpthread-1.dll" DESTINATION "${INS_PREF}")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/installs/Windows/definitions.nsh.in
${CMAKE_BINARY_DIR}/NSIS.definitions.nsh
)
install(FILES installs/Windows/metronomek.nsi ${CMAKE_BINARY_DIR}/NSIS.definitions.nsh DESTINATION ${INS_PREF})
else()
if(APPLE)
install(FILES "${CMAKE_SOURCE_DIR}/images/metronomek.icns" DESTINATION "${INS_PREF}")
else() # Linux
install(FILES installs/Linux/net.sf.metronomek.desktop DESTINATION share/applications)
install(FILES installs/Linux/net.sf.metronomek.appdata.xml DESTINATION share/metainfo)
install(FILES images/hicolor/16x16/apps/metronomek.png DESTINATION share/icons/hicolor/16x16/apps/)
install(FILES images/hicolor/24x24/apps/metronomek.png DESTINATION share/icons/hicolor/24x24/apps/)
install(FILES images/hicolor/32x32/apps/metronomek.png DESTINATION share/icons/hicolor/32x32/apps/)
install(FILES images/hicolor/48x48/apps/metronomek.png DESTINATION share/icons/hicolor/48x48/apps/)
install(FILES images/hicolor/64x64/apps/metronomek.png DESTINATION share/icons/hicolor/64x64/apps/)
install(FILES images/hicolor/128x128/apps/metronomek.png DESTINATION share/icons/hicolor/128x128/apps/)
install(FILES images/hicolor/256x256/apps/metronomek.png DESTINATION share/icons/hicolor/256x256/apps/)
install(FILES images/metronomek.png DESTINATION share/icons/hicolor/512x512/apps/)
endif()
endif()
##############################################################################
# src target #
# (Linux) #
##############################################################################
if(UNIX AND NOT APPLE)
message(STATUS "
To build source package, call:
make src
")
add_custom_target(src
COMMAND ${CMAKE_SOURCE_DIR}/installs/make-src.sh ${METRONOMEK_VER} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}
)
endif()
##############################################################################
# runinplace target #
# (Linux & Mac Os) #
##############################################################################
if (UNIX AND NOT ANDROID)
message(STATUS "
To enable launching MetronomeK without installing, call:
make runinplace
and launch it invoking: ./src/metronomek
"
)
if (APPLE)
set(LINK_PATH "${CMAKE_BINARY_DIR}/Resources")
else ()
set(LINK_PATH "${CMAKE_BINARY_DIR}")
endif()
add_custom_target(runinplace
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/installs/make-runinplace.sh ${CMAKE_SOURCE_DIR} ${LINK_PATH}
)
endif()
##############################################################################
# deploy target #
# (Mac Os & Windows) #
##############################################################################
get_target_property(QtCore_location_Release Qt5::Core LOCATION_Release)
get_filename_component(QT_BINARY_DIR "${QtCore_location_Release}" DIRECTORY)
if (APPLE)
add_custom_target(deploy
COMMAND echo "deploying..."
COMMAND ${QT_BINARY_DIR}/../../bin/macdeployqt ${CMAKE_INSTALL_PREFIX}/metronomek.app -qmldir=${CMAKE_SOURCE_DIR}/src/qml
)
endif()
if (WIN32)
add_custom_target(deploy
COMMAND echo "deploying..."
COMMAND ${QT_BINARY_DIR}/windeployqt.exe ${CMAKE_INSTALL_PREFIX}/metronomek.exe --no-translations --no-svg --qmldir "${CMAKE_SOURCE_DIR}/src/qml"
)
endif()
##############################################################################
# AppImage target #
# (Linux) #
##############################################################################
if (UNIX AND NOT APPLE)
# To correctly generate AppImage set install prefix to '/usr'
# and when using with older Linux system (i.e. Ubuntu Trusty 14.04)
# call
# cmake with -DQT_QMAKE_EXECUTABLE=/opt/qtXX/bin/qmake
add_custom_target(appimage
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/installs/Linux/make-appimage.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${QT_QMAKE_EXECUTABLE} ${METRONOMEK_VER}
)
endif()
##############################################################################
# dmg target #
# (Mac Os) #
##############################################################################
if (APPLE)
add_custom_target(dmg
COMMAND echo "creating dmg image..."
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/installs/Mac/create-dmg.sh ${METRONOMEK_VER} ${CMAKE_SOURCE_DIR} ${CMAKE_INSTALL_PREFIX}
)
endif()
##############################################################################
# uninstall target #
##############################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/installs/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)
#add_subdirectory(spare_parts/helpers/wavdirparser)