-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
226 lines (192 loc) · 6.97 KB
/
CMakeLists.txt
File metadata and controls
226 lines (192 loc) · 6.97 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
cmake_minimum_required(VERSION 3.16)
# Allow version override from command line
if (NOT DEFINED GAV_VERSION)
set(GAV_VERSION "0.0.0-dev")
endif ()
# Extract numeric version for CMake project()
string(REGEX MATCH "^([0-9]+\\.[0-9]+\\.[0-9]+)" GAV_NUMERIC_VERSION "${GAV_VERSION}")
if (NOT GAV_NUMERIC_VERSION)
set(GAV_NUMERIC_VERSION "0.0.0")
endif ()
# Set the full version string for use in the app
set(GAV_FULL_VERSION "${GAV_VERSION}")
project(gav VERSION ${GAV_NUMERIC_VERSION} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Option to build tests
option(BUILD_TESTS "Build tests" ON)
# Check if in CLion
if ($ENV{CLION_IDE})
set(QT_VERSION "6.10.*")
message(STATUS "CLion IDE detected. Setting Qt version to ${QT_VERSION}")
if (WIN32)
set(USER_HOME_DIR "C:")
set(COMPILER "msvc2022_64")
else ()
set(USER_HOME_DIR $ENV{HOME})
set(COMPILER "gcc_64")
endif ()
file(GLOB QT_DIRS "${USER_HOME_DIR}/Qt/${QT_VERSION}")
message(STATUS "Searching for Qt directories in ${USER_HOME_DIR}/Qt/ with pattern ${QT_VERSION}: ${QT_DIRS}")
list(LENGTH QT_DIRS QT_DIRS_COUNT)
if (QT_DIRS_COUNT GREATER 0)
message(STATUS "Found ${QT_DIRS_COUNT} Qt directories starting with ${QT_VERSION}")
list(GET QT_DIRS 0 QT_DIR)
message(STATUS "Using Qt directory: ${QT_DIR}")
list(APPEND CMAKE_PREFIX_PATH ${QT_DIR} ${QT_DIR}/${COMPILER})
# List all dirs in QT_DIRS/${COMPILER}/lib/cmake
file(GLOB QT_CMAKE_DIRS "${QT_DIR}/${COMPILER}/lib/cmake/*")
message(STATUS "CMake directories in ${QT_DIR}/${COMPILER}/lib/cmake:")
foreach (dir ${QT_CMAKE_DIRS})
message(STATUS " - ${dir}")
# Get the last part of the path
get_filename_component(dir_name ${dir} NAME)
message(STATUS " - Directory name: ${dir_name}")
set(${dir_name}_DIR ${dir})
endforeach ()
else ()
message(FATAL_ERROR "No Qt directory starting with ${QT_VERSION} found in /home/akshay/Qt/")
endif ()
endif ()
# Enable VCPKG app-local deployment of dependencies
set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON)
# Use external fmt library for spdlog (must be set before find_package)
set(SPDLOG_FMT_EXTERNAL ON)
# Find fmt first, then spdlog
find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Multimedia Widgets Concurrent)
qt_standard_project_setup(REQUIRES 6.9)
if (WIN32)
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/assets/resource.rc")
qt_add_executable(appgav main.cpp ${app_icon_resource_windows})
elseif (APPLE)
# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
# generated by CMake. This variable contains the .icns file name,
# without the path.
set(MACOSX_BUNDLE_ICON_FILE icon.icns)
# And the following tells CMake where to find and install the file itself.
set(app_icon_macos "${CMAKE_CURRENT_SOURCE_DIR}/assets/images/icon.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
qt_add_executable(appgav MACOSX_BUNDLE main.cpp ${app_icon_macos})
else ()
qt_add_executable(appgav
main.cpp
)
endif ()
target_compile_definitions(appgav PRIVATE
APP_VERSION="${GAV_FULL_VERSION}"
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING # For https://github.com/fmtlib/fmt/issues/3183
)
qt_add_resources(appgav "assets"
PREFIX "/"
FILES
qtquickcontrols2.conf
assets/fonts/MaterialSymbolsOutlined.ttf
assets/images/logo.png
assets/images/logo-bw.png
assets/images/icon.png
assets/images/icon-bw.png
assets/images/logo.ico
assets/images/icon.icns
assets/resource.rc
assets/images/logo.bmp
)
set_source_files_properties(AppConstants.qml PROPERTIES
QT_QML_SINGLETON_TYPE TRUE
)
qt_add_qml_module(appgav
URI gavqml
VERSION 1.0
QML_FILES
Main.qml
MediaComponent.qml
Debug.qml
MediaControlsComponent.qml
PlayListComponent.qml
CustomSnackbar.qml
AppConstants.qml
SettingsDialog.qml
MiniPlayerWindow.qml
SOURCES
custommediaplayer.h custommediaplayer.cpp
collage.h collage.cpp
previewimageprovider.h previewimageprovider.cpp
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appgav PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER com.gollahalli.gav
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
MACOSX_BUNDLE TRUE
# WIN32_EXECUTABLE TRUE
)
set_target_properties(appgav PROPERTIES OUTPUT_NAME "gav")
target_link_libraries(appgav
PRIVATE Qt6::Core Qt6::Gui Qt6::Quick Qt6::Qml Qt6::Multimedia Qt6::Widgets spdlog::spdlog fmt::fmt Qt6::Concurrent
)
if (WIN32 AND DEFINED ENV{CLION_IDE})
# Deploy Qt dependencies after build for CLion
add_custom_command(TARGET appgav POST_BUILD
COMMAND "${QT_DIR}/${COMPILER}/bin/windeployqt.exe"
--qmldir "${CMAKE_SOURCE_DIR}"
"$<TARGET_FILE:appgav>"
COMMENT "Running windeployqt to deploy Qt DLLs..."
)
endif ()
include(InstallRequiredSystemLibraries)
include(GNUInstallDirs)
install(TARGETS appgav
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT GAV
)
if (UNIX AND NOT APPLE)
# For DEB package
install(FILES assets/images/icon.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps
RENAME gav.png
COMPONENT GAV)
install(FILES support/gav.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
COMPONENT GAV)
endif ()
# Testing
if (BUILD_TESTS)
enable_testing()
find_package(GTest CONFIG REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Test)
# Create test executable
add_executable(gav_tests
tests/test_main.cpp
tests/test_path_conversion.cpp
tests/test_collage.cpp
collage.cpp
collage.h
)
target_link_libraries(gav_tests
PRIVATE
GTest::gtest
GTest::gtest_main
Qt6::Core
Qt6::Quick
Qt6::Multimedia
Qt6::Concurrent
spdlog::spdlog
fmt::fmt
Qt6::Test
)
target_compile_definitions(gav_tests PRIVATE
APP_VERSION="${GAV_FULL_VERSION}"
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
)
# Discover tests
include(GoogleTest)
gtest_discover_tests(gav_tests)
message(STATUS "Tests enabled. Run with: ctest or ./gav_tests")
endif ()
include(support/cpack.cmake)