forked from kraxarn/spotify-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
103 lines (84 loc) · 2.64 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
cmake_minimum_required(VERSION 3.5)
project(spotify-qt LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Optional D-Bus support
if (NOT DEFINED USE_DBUS)
set(USE_DBUS 1)
endif ()
# Optional Qy 6 support
if (DEFINED USE_QT6)
set(QT_VERSION_MAJOR 6)
else()
set(QT_VERSION_MAJOR 5)
endif()
# Prefer new OpenGL
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
# Find Qt
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets Network Gui Svg REQUIRED)
if (USE_DBUS)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS DBus QUIET)
endif ()
message(STATUS "Using Qt ${QT_VERSION_MAJOR}")
# Glob source files
file(GLOB MAIN_SRC "src/*.[hc]pp")
file(GLOB SUB_SRC "src/*/*.[hc]pp")
if (USE_QT_QUICK)
set(QML_RES qml/res.qrc)
endif ()
# Add all source files to main executable
if (ANDROID)
add_library(spotify-qt SHARED ${MAIN_SRC} ${SUB_SRC} ${QML_RES} res.qrc)
else ()
add_executable(spotify-qt ${MAIN_SRC} ${SUB_SRC} ${QML_RES} ${LIB_SRC} res.qrc)
endif ()
# Include headers from spotify-qt-lib
target_include_directories(spotify-qt PRIVATE "lib")
# 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(spotify-qt PRIVATE GIT_COMMIT="${GIT_COMMIT}")
endif ()
# Set install targets for 'make install'
install(TARGETS spotify-qt RUNTIME DESTINATION bin)
if (UNIX)
# Install icons and desktop shortcut on unix-like
install(FILES res/logo/spotify-qt.svg DESTINATION share/icons/hicolor/scalable/apps)
install(FILES res/app/spotify-qt.desktop DESTINATION share/applications)
endif ()
# Don't show console window under windows
if (WIN32)
target_link_options(spotify-qt PRIVATE -mwindows)
endif ()
# Link Qt
target_link_libraries(spotify-qt PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Svg)
# spotify-qt-lib
add_subdirectory(lib)
target_link_libraries(spotify-qt PRIVATE spotify-qt-lib)
# Check if we should include Qt Quick
if (USE_QT_QUICK)
add_subdirectory(qml)
target_compile_definitions(spotify-qt PRIVATE USE_QT_QUICK)
target_link_libraries(spotify-qt PRIVATE spotify-qt-quick)
endif ()
# D-Bus support is optional
if (Qt5DBus_FOUND)
target_compile_definitions(spotify-qt PRIVATE USE_DBUS)
target_link_libraries(spotify-qt PRIVATE Qt5::DBus)
endif ()