-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
159 lines (130 loc) · 3.74 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
cmake_minimum_required(VERSION 3.5)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
project(pineapple-chapter-tool LANGUAGES CXX)
include (GNUInstallDirs)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set (EXE_NAME pchaptool)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Mp4v2)
pkg_check_modules(TagLib REQUIRED taglib)
set (CMAKE_AUTORCC ON)
set (PCHAPTOOL_QRC_FILES
assets/resources.qrc
)
set (PCHAPTOOL_RC_FILES
# yeah, it's empty.
)
if (WIN32)
list(APPEND PCHAPTOOL_RC_FILES assets/pineapple-chapter-tool.rc)
endif ()
add_executable(${EXE_NAME}
filehandlerinterface.h
filehandlerinterface.cpp
mpegfilehandler.h
mpegfilehandler.cpp
taglibutils_p.h
taglibutils_p.cpp
vorbisfilehandler.h
vorbisfilehandler.cpp
opusfilehandler.h
opusfilehandler.cpp
mp4filehandler.h
mp4filehandler.cpp
cuefilehandler.h
cuefilehandler.cpp
ytdlfilehandler.h
ytdlfilehandler.cpp
filehandlermanager.h
filehandlermanager.cpp
main.cpp
chapteritem.cpp
chapteritem.h
chaptertreemodel.cpp
chaptertreemodel.h
chaptertreeview.cpp
chaptertreeview.h
mainwindow.cpp
mainwindow.h
mainwindow.ui
chapterinfowidget.cpp
chapterinfowidget.h
chapterinfowidget.ui
${PCHAPTOOL_QRC_FILES}
${PCHAPTOOL_RC_FILES}
)
if (NOT Mp4v2_FOUND)
message (WARNING "Mp4v2 not found!")
target_compile_definitions(${EXE_NAME} PRIVATE
NO_LIBMP4V2=1
)
endif ()
target_include_directories(${EXE_NAME}
PRIVATE
${TagLib_INCLUDE_DIRS}
)
target_link_libraries(${EXE_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
${TagLib_LINK_LIBRARIES}
)
if (Mp4v2_FOUND)
target_link_libraries(${EXE_NAME}
PRIVATE
Mp4v2::Mp4v2
)
endif()
# Extra build settings
if (WIN32)
set_property (
TARGET ${EXE_NAME}
PROPERTY WIN32_EXECUTABLE true
)
endif ()
# Helper macros for install settings
macro (pchaptool_convert_to_relative_path _var)
# Make sure _var is a relative path
if (IS_ABSOLUTE "${${_var}}")
file (RELATIVE_PATH ${_var} "${CMAKE_INSTALL_PREFIX}" "${${_var}}")
endif ()
endmacro ()
# Install settings
if (WIN32)
# FIXME: try to avoid install to a "bin" subfolder under windows...
# when fixed, don't forget to update the CI config file...
set (BIN_INSTALL_DIR "") # seems useless, don't know why...
elseif (UNIX)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
set (BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") # relative, usually "bin"
pchaptool_convert_to_relative_path(BIN_INSTALL_DIR)
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") # "lib" or "lib64"
pchaptool_convert_to_relative_path(LIB_INSTALL_DIR)
# install icon
install (
FILES assets/icons/app-icon.svg
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps"
RENAME pineapple-chapter-tool.svg
)
# install shortcut
install (
FILES dist/net.blumia.pineapple-chapter-tool.desktop
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
)
endif()
set (INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Devel
)
install (
TARGETS ${EXE_NAME}
${INSTALL_TARGETS_DEFAULT_ARGS}
)