-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
104 lines (86 loc) · 3.17 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
cmake_minimum_required(VERSION 3.16)
project(spotify-qt-quick LANGUAGES CXX VERSION 1.90)
# C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find Qt
find_package(Qt6 6.5 COMPONENTS Core Gui Quick QuickControls2 REQUIRED)
qt_standard_project_setup(REQUIRES 6.5)
# Create main executable
qt_add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE MANUAL_FINALIZATION)
# Collect source files
add_subdirectory(src)
# Resources
include(QmlModule.cmake)
# Headers are in src/
target_include_directories(${PROJECT_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
# QML requires headers in root
"${CMAKE_CURRENT_SOURCE_DIR}/src/element"
"${CMAKE_CURRENT_SOURCE_DIR}/src/page"
"${CMAKE_CURRENT_SOURCE_DIR}/src/qml")
# Get version from Git
find_package(Git QUIET)
if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
target_compile_definitions(${PROJECT_NAME} PRIVATE GIT_COMMIT="${GIT_COMMIT}")
endif ()
# App related definitions
target_compile_definitions(${PROJECT_NAME} PRIVATE APP_VERSION="v${PROJECT_VERSION}")
target_compile_definitions(${PROJECT_NAME} PRIVATE APP_NAME="${PROJECT_NAME}")
target_compile_definitions(${PROJECT_NAME} PRIVATE APP_ICON="${PROJECT_NAME}")
target_compile_definitions(${PROJECT_NAME} PRIVATE ORG_NAME="kraxarn")
target_compile_definitions(${PROJECT_NAME} PRIVATE PKG_NAME="com.kraxarn")
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_TYPE="${CMAKE_BUILD_TYPE}")
# Enable QML debugging in debug
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(${PROJECT_NAME} PRIVATE QT_QML_DEBUG)
endif ()
# Install icons and desktop shortcut on unix-like
# Currently, it uses the same icon as spotify-qt
if (UNIX)
install(FILES core/res/logo/spotify-qt.svg DESTINATION share/icons/hicolor/scalable/apps)
install(FILES res/app/spotify-qt-quick.desktop DESTINATION share/applications)
endif ()
# Don't show console window under windows
if (WIN32)
target_link_options(${PROJECT_NAME} PRIVATE -mwindows)
endif ()
# Generate Android version code
include(cmake/AndroidVersionCode.cmake)
android_version_code(ANDROID_VERSION_CODE)
set_target_properties(${PROJECT_NAME} PROPERTIES
# macOS
MACOSX_BUNDLE_GUI_IDENTIFIER com.kraxarn.spotify_qt_quick
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
MACOSX_BUNDLE TRUE
# Android
QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res/app/android"
QT_ANDROID_VERSION_NAME ${PROJECT_VERSION}
QT_ANDROID_VERSION_CODE ${ANDROID_VERSION_CODE}
# Windows
WIN32_EXECUTABLE TRUE
)
# Link Qt
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Quick
Qt6::QuickControls2
)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# spotify-qt-lib
set(QT_VERSION_MAJOR 6)
set(LIB_QT_IMPL ON)
add_subdirectory(core/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE spotify-qt-lib)
qt_finalize_target(${PROJECT_NAME})