forked from hluk/CopyQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
133 lines (112 loc) · 5.03 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
cmake_minimum_required(VERSION 2.8.6)
project(copyq)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(COPYQ_DEBUG ON)
add_definitions( -DCOPYQ_DEBUG )
endif()
# Options (cmake -LH)
OPTION(WITH_QT5 "Qt5 support" OFF)
OPTION(WITH_TESTS "Run test cases from command line" ${COPYQ_DEBUG})
OPTION(WITH_PLUGINS "Compile plugins" ON)
# Linux-specific options
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PLUGIN_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_MODULE_PREFIX}/copyq/plugins" CACHE PATH "Install path for plugins")
set(ICON_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps" CACHE PATH "Install path for icons")
set(ICON_INSTALL_PREFIX_TEMPLATE "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/%SIZE%/apps" CACHE PATH "Install path for icons (%SIZE% is icon size)")
set(THEME_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share/copyq/themes" CACHE PATH "Install path for themes")
set(DESKTOP_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share/applications" CACHE PATH "Install path for \"copyq.desktop\"")
set(APPDATA_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share/appdata" CACHE PATH "Install path for \"copyq.appdata.xml\"")
set(TRANSLATION_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share/copyq/translations" CACHE PATH "Install path for translations")
endif()
set(CMAKE_AUTOMOC ON)
# If Qt4 unavailable use Qt5.
if (NOT WITH_QT5)
find_package(Qt4)
if (NOT QT4_FOUND)
# Try different executable name.
set(QT_QMAKE_EXECUTABLE "qmake-qt4")
find_package(Qt4)
if (NOT QT4_FOUND)
message(FATAL_ERROR
"Qt 4 is unavailable. To compile with Qt 5 use -DWITH_QT5=TRUE.\n"
"Note: Qt version 5.0.2 and earlier can be unstable on some systems.")
endif()
endif()
endif()
if (WITH_QT5)
cmake_minimum_required(VERSION 2.8.8)
find_package(Qt5Widgets REQUIRED)
message(STATUS "Building with Qt 5.")
else()
message(STATUS "Building with Qt 4.")
endif()
set(copyq_ICON_PREFIX src/images/icon)
set(copyq_ICON_NORMAL src/images/icon.svg)
set(copyq_ICON_BUSY src/images/icon-running.svg)
set(copyq_DESKTOP shared/copyq.desktop)
set(copyq_APPDATA shared/copyq.appdata.xml)
# Be more strict while compiling debugging version
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -Wextra -Wall -pedantic -Wfloat-equal -Woverloaded-virtual -Wundef")
endif()
if(WITH_TESTS)
message(STATUS "Building with tests.")
add_definitions( -DHAS_TESTS )
if (WITH_QT5)
list(APPEND copyq_Qt5_Modules Test)
else()
set(QT_USE_QTTEST TRUE)
endif()
endif()
# Get application version.
if (EXISTS "version.txt")
file(STRINGS "version.txt" copyq_version)
endif()
if (NOT copyq_version)
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND
"${GIT_EXECUTABLE}" describe
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE copyq_git_describe_result
OUTPUT_VARIABLE copyq_git_describe_output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(copyq_git_describe_result EQUAL 0)
set(copyq_version "${copyq_git_describe_output}")
endif()
endif()
endif()
if (copyq_version)
message(STATUS "Building CopyQ version ${copyq_version}.")
add_definitions( -DCOPYQ_VERSION="${copyq_version}" )
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(FILES ${copyq_ICON_NORMAL} DESTINATION ${ICON_INSTALL_PREFIX} RENAME copyq-normal.svg)
install(FILES ${copyq_ICON_BUSY} DESTINATION ${ICON_INSTALL_PREFIX} RENAME copyq-busy.svg)
install(FILES ${copyq_DESKTOP} DESTINATION ${DESKTOP_INSTALL_PREFIX})
install(FILES ${copyq_APPDATA} DESTINATION ${APPDATA_INSTALL_PREFIX})
foreach (copyq_ICON_EXTENT 16 22 24 32 48 64 128)
set(copyq_ICON_SIZE "${copyq_ICON_EXTENT}x${copyq_ICON_EXTENT}")
string(REPLACE "%SIZE%" "${copyq_ICON_SIZE}" copyq_ICON_TARGET_PREFIX "${ICON_INSTALL_PREFIX_TEMPLATE}")
foreach (copyq_ICON_TYPE "" "-normal" "-busy")
install(FILES "${copyq_ICON_PREFIX}${copyq_ICON_TYPE}_${copyq_ICON_SIZE}.png" DESTINATION "${copyq_ICON_TARGET_PREFIX}" RENAME "copyq${copyq_ICON_TYPE}.png")
endforeach()
endforeach()
set(copyq_THEME_INSTALL_PREFIX ${THEME_INSTALL_PREFIX})
file(GLOB copyq_THEMES shared/themes/*.ini)
install(FILES ${copyq_THEMES} DESTINATION ${THEME_INSTALL_PREFIX})
add_definitions( -DCOPYQ_ICON_PREFIX="${ICON_INSTALL_PREFIX}/copyq" )
add_definitions( -DCOPYQ_THEME_PREFIX="${THEME_INSTALL_PREFIX}" )
add_definitions( -DCOPYQ_PLUGIN_PREFIX="${PLUGIN_INSTALL_PREFIX}" )
add_definitions( -DCOPYQ_DESKTOP_PREFIX="${DESKTOP_INSTALL_PREFIX}" )
add_definitions( -DCOPYQ_TRANSLATION_PREFIX="${TRANSLATION_INSTALL_PREFIX}" )
endif()
add_definitions( -DQT_NO_CAST_TO_ASCII )
add_subdirectory(src)
if (WITH_PLUGINS)
add_subdirectory(plugins)
endif()