-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
134 lines (111 loc) · 3.71 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
cmake_minimum_required(VERSION 3.27)
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(DEBUG true)
string(TIMESTAMP VERSION "%Y.%m.%d")
else ()
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
set(DEBUG false)
file(READ "${CMAKE_SOURCE_DIR}/src/Version.hpp" VERSION_FILE_CONTENT)
string(REGEX MATCH "define VERSION \"([^\"]+)" VERSION_MATCH "${VERSION_FILE_CONTENT}")
set(VERSION ${CMAKE_MATCH_1})
endif ()
set(PRG_NAME QCine)
project(${PRG_NAME} VERSION ${VERSION})
set(QT_VERSION 6)
math(EXPR PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
configure_file("${CMAKE_SOURCE_DIR}/src/Version.hpp.in" "${CMAKE_SOURCE_DIR}/src/Version.hpp" @ONLY)
message(STATUS "project source dir: " ${PROJECT_SOURCE_DIR})
message(STATUS "cmake module path: " ${CMAKE_MODULE_PATH})
message(STATUS "cmake install prefix: " ${CMAKE_INSTALL_PREFIX})
message(STATUS "current date: " ${VERSION})
message(STATUS "debug mode: " ${DEBUG})
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(Qt${QT_VERSION} COMPONENTS
Concurrent
Core
DBus
Gui
LinguistTools
Multimedia
MultimediaWidgets
Widgets
REQUIRED
)
option(USE_VLC_QT "Enable vlc-qt" ON)
if (USE_VLC_QT)
include(FindVLCQT)
add_definitions(-DUSE_VLC_QT)
endif ()
include(FindFFmpeg)
include(FindScreenSaver)
file(GLOB DIRECTORIES CONFIGURE_DEPENDS LIST_DIRECTORIES true utils utils/*/ src_extra/*/ src src/*/)
foreach (DIR ${DIRECTORIES})
if (IS_DIRECTORY ${DIR})
list(APPEND SRC_DIRS ${DIR})
message(STATUS ${DIR})
endif ()
endforeach ()
include_directories(
${SRC_DIRS}
${Qt${QT_VERSION}Multimedia_PRIVATE_INCLUDE_DIRS}
${FFMPEG_INCLUDE_DIRS}
${LIBVLC_INCLUDE_DIR}
${VLC_COMMON_INCLUDE_DIR}
)
add_subdirectory(utils/SingleApplication)
file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS src/*)
if (USE_VLC_QT)
set(SRC_FILES
${SRC_FILES}
src_extra/player/VlcQtObject.cpp
src_extra/player/VlcQtObject.hpp
src_extra/player/VlcVideo.cpp
src_extra/player/VlcVideo.hpp
)
endif ()
add_executable(${PRG_NAME}
${SRC_FILES}
${VLCQT_CORE_SRCS}
${VLCQT_CORE_HEADERS}
${VLCQT_WIDGETS}
${SCREENSAVER_SOURCES}
)
set_property(TARGET ${PRG_NAME} PROPERTY OUTPUT_NAME "qcine")
set_property(TARGET ${PRG_NAME} PROPERTY LINK_FLAGS "-Wl,-s")
set_property(TARGET ${PRG_NAME} PROPERTY COMPILE_FLAGS "-03")
set_property(TARGET ${PRG_NAME} PROPERTY COMPILE_FLAGS "-finline-functions")
set_property(TARGET ${PRG_NAME} PROPERTY COMPILE_FLAGS "-ftree-vectorize")
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
message(STATUS "IPO / LTO enabled")
set_property(TARGET ${PRG_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else ()
message(STATUS "IPO / LTO not supported: <${error}>")
endif ()
target_link_libraries(${PRG_NAME}
Qt${QT_VERSION}::Concurrent
Qt${QT_VERSION}::Core
Qt${QT_VERSION}::DBus
Qt${QT_VERSION}::Gui
Qt${QT_VERSION}::Multimedia
Qt${QT_VERSION}::MultimediaWidgets
Qt${QT_VERSION}::Widgets
SingleApplication::SingleApplication
Threads::Threads
${LIBVLC_LIBRARY}
${LIBVLCCORE_LIBRARY}
${FFMPEG_LIBRARIES}
)