forked from chjj/compton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_CMakeLists.txt
188 lines (153 loc) · 5.27 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
project(compton)
cmake_minimum_required(VERSION 2.8)
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
add_subdirectory(man)
set(compton_SRCS src/compton.c)
set(CMAKE_C_FLAGS_DEBUG "-ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O2 -march=native")
set(CMAKE_C_FLAGS_RELWITHDBGINFO "-O2 -march=native -ggdb")
add_definitions("-Wall" "-std=c99")
# == Version ==
execute_process(COMMAND sh -c "echo -n \\\"git-$(git describe --always --dirty)-$(git log -1 --date=short --pretty=format:%cd)\\\""
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE COMPTON_VERSION)
add_definitions("-DCOMPTON_VERSION=${COMPTON_VERSION}")
# == Options ==
option(CONFIG_REGEX_PCRE "Enable PCRE regular expression support for blacklist entries (requires libpcre)" ON)
if (CONFIG_REGEX_PCRE)
add_definitions("-DCONFIG_REGEX_PCRE")
endif ()
option(CONFIG_REGEX_PCRE_JIT "Use JIT support of libpcre)" ON)
if (CONFIG_REGEX_PCRE_JIT)
add_definitions("-DCONFIG_REGEX_PCRE_JIT")
endif ()
option(CONFIG_LIBCONFIG "Enable configuration file parsing using libconfig" ON)
if (CONFIG_LIBCONFIG)
add_definitions("-DCONFIG_LIBCONFIG")
endif ()
option(CONFIG_VSYNC_DRM "Enable DRM VSync support" ON)
if (CONFIG_VSYNC_DRM)
add_definitions("-DCONFIG_VSYNC_DRM")
endif ()
option(CONFIG_VSYNC_OPENGL "Enable OpenGL support" ON)
if (CONFIG_VSYNC_OPENGL)
add_definitions("-DCONFIG_VSYNC_OPENGL")
list(APPEND compton_SRCS src/opengl.c)
endif ()
option(CONFIG_XINERAMA "Enable additional Xinerama features" ON)
if (CONFIG_XINERAMA)
add_definitions("-DCONFIG_XINERAMA")
endif ()
option(CONFIG_C2 "Enable matching system" ON)
if (CONFIG_C2)
add_definitions("-DCONFIG_C2")
list(APPEND compton_SRCS src/c2.c)
endif ()
add_executable(compton ${compton_SRCS})
# == Find libraries ==
target_link_libraries(compton "-lm" "-lrt")
if (CONFIG_VSYNC_OPENGL)
target_link_libraries(compton "-lGL")
endif ()
include(FindPkgConfig)
# --- Find X11 libs ---
set(X11_FIND_REQUIRED 1)
include(FindX11)
macro(X11LIB_CHK lib)
if (NOT X11_${lib}_FOUND)
message(FATAL_ERROR "Could not find lib${lib}.")
endif ()
target_link_libraries(compton "${X11_${lib}_LIB}")
endmacro ()
target_link_libraries(compton "${X11_X11_LIB}")
X11LIB_CHK(Xcomposite)
X11LIB_CHK(Xdamage)
X11LIB_CHK(Xext)
X11LIB_CHK(Xfixes)
X11LIB_CHK(Xrender)
X11LIB_CHK(Xrandr)
if (CONFIG_XINERAMA)
X11LIB_CHK(Xinerama)
endif ()
# --- Find libpcre ---
if (CONFIG_REGEX_PCRE)
pkg_check_modules(LIBPCRE REQUIRED libpcre>=8.12)
add_definitions("${LIBPCRE_CFLAGS}")
target_link_libraries(compton "${LIBPCRE_LDFLAGS}")
endif ()
# --- Find libconfig ---
if (CONFIG_LIBCONFIG)
pkg_check_modules(LIBCONFIG REQUIRED libconfig>=1.3.2)
add_definitions("${LIBCONFIG_CFLAGS}")
target_link_libraries(compton "${LIBCONFIG_LDFLAGS}")
if (LIBCONFIG_VERSION VERSION_LESS 1.4)
add_definitions("-DCONFIG_LIBCONFIG_LEGACY")
message(STATUS "libconfig-1.3* detected. Enable legacy mode.")
endif ()
endif ()
# --- Find libdrm ---
if (CONFIG_VSYNC_DRM)
pkg_check_modules(LIBDRM REQUIRED libdrm)
# We only use its header file
add_definitions("${LIBDRM_CFLAGS}")
endif ()
# == Install ==
include(GNUInstallDirs)
install(TARGETS compton
DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog)
install(FILES "${PROJECT_SOURCE_DIR}/bin/compton-trans"
DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog)
install(FILES
"${PROJECT_SOURCE_DIR}/README.md"
"${PROJECT_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT doc)
# == CPack ==
if (NOT CPACK_SYSTEM_NAME)
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_PROCESSOR}")
endif ()
set(CPACK_PACKAGE_DESCRIPTION "A lightweight X compositing window manager, fork of xcompmgr-dana.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A lightweight X compositing window manager")
set(CPACK_PACKAGE_CONTACT "nobody <devnull@example.com>")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/release")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/desc.txt")
# --- Package config ---
set(CPACK_GENERATOR "TBZ2" "DEB" "RPM")
set(CPACK_MONOLITHIC_INSTALL 1)
set(CPACK_STRIP_FILES 1)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
# --- Source package config ---
set(CPACK_SOURCE_GENERATOR "TBZ2" "DEB" "RPM")
set(CPACK_SOURCE_IGNORE_FILES
"/\\\\."
"\\\\.bak$"
"\\\\.o$"
"\\\\~$"
"\\\\.plist$"
"/compton$"
# Generated package files
"\\\\.tar\\\\.gz$"
"\\\\.tar\\\\.bz2$"
"\\\\.deb$"
"\\\\.rpm$"
"compton-.*\\\\.sh$"
# CMake files
"/Makefile$"
"/CMakeFiles/"
"\\\\.cmake$"
"CMakeCache\\\\.txt$"
"/build/"
"/release/"
"\\\\.diff$"
"/oprofile_data/"
"/install_manifest\\\\.txt$"
)
# --- DEB package config ---
set(CPACK_DEBIAN_PACKAGE_SECTION "x11")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.15), libconfig9, libdbus-1-3 (>= 1.1.1), libgl1-mesa-glx | libgl1 | libgl1-nvidia-glx | libgl1-fglrx-glx, libpcre3 (>= 8.10), libx11-6, libxcomposite1 (>= 1:0.3-1), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxrandr2 (>= 4.3), libxrender1, libxinerama1")
# --- RPM package config ---
set(CPACK_RPM_PACKAGE_LICENSE "unknown")
set(CPACK_RPM_PACKAGE_REQUIRES "/bin/sh,libGL.so.1,libX11.so.6,libXcomposite.so.1,libXdamage.so.1,libXext.so.6,libXfixes.so.3,libXrandr.so.2,libXrender.so.1,libc.so.6,libconfig.so.9,libdbus-1.so.3,libm.so.6,libpcre.so.1")
include(CPack)