/
CMakeLists.txt
158 lines (132 loc) · 4.78 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
if (${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
message (FATAL_ERROR [[In source build are not allowed!
Run cmake this way: `cmake <source-dir> -B<build-dir>.']])
endif ()
cmake_minimum_required (VERSION 3.0)
project (tinto-panel VERSION 0.0.2.5 LANGUAGES C)
cmake_policy (SET CMP0058 NEW)
list (APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
"${CMAKE_BINARY_DIR}/cmake"
"${CMAKE_SOURCE_DIR}/vendor/cmake/cmake/modules")
include (Utils)
set (tinto_panel_EXECUTABLE tinto-panel)
set (USER_HOME_DIR "$ENV{HOME}")
set (tinto_panel_IN_SOURCE_RES_DIR "${CMAKE_HOME_DIRECTORY}/res")
set (tinto_panel_IN_SOURCE_BIN_DIR "${CMAKE_HOME_DIRECTORY}/bin")
set (tinto_panel_IN_SOURCE_DOC_DIR "${CMAKE_HOME_DIRECTORY}/doc")
set (MANDIR share/man CACHE PATH "Directory for man pages")
set (DATADIR share CACHE PATH "Directory for shared data")
set (SYSCONFDIR etc CACHE PATH "Directory for configuration files")
set (DOCDIR share/doc/tinto CACHE PATH "Directory for documentation"
" files")
option (ENABLE_BATTERY "Enable battery status plugin." ON)
option (ENABLE_TINT2CONF "Enable tint2conf build, a Gtk+2 theme \
configurator for `tinto`." OFF)
option (ENABLE_EXAMPLES "Install additional tin2rc examples" OFF)
option (ENABLE_RSVG "Enable `rsvg` support for launcher icons." ON)
option (ENABLE_SN "Enable `startup notification` support." ON)
add_executable (${tinto_panel_EXECUTABLE}
"${CMAKE_CURRENT_LIST_DIR}/src/main.c")
find_package (X11 COMPONENTS
Xdamage
Xrandr
Xrender
Xcomposite
Xinerama
RQUIRED)
if (NOT X11_FOUND)
message (FATAL_ERROR "tinto-panel: X11 library not found!")
endif ()
find_package (GTK2 2.8 REQUIRED COMPONENTS gtk)
if (NOT GTK2_FOUND)
message (FATAL_ERROR "tinto-panel: Gtk+2 library not found!")
endif ()
include (FindPkgConfig)
find_package (Imlib2 REQUIRED)
if (NOT Imlib2_FOUND)
message (FATAL_ERROR "tinto-panel: Imlib2 library not found!")
endif ()
if (ENABLE_RSVG)
pkg_check_modules (RSVG librsvg-2.0>=2.14.0)
if (RSVG_FOUND)
include_directories ("${RSVG_INCLUDE_DIRS}")
target_link_libraries (${tinto_panel_EXECUTABLE}
PUBLIC
"${RSVG_LIBRARIES}")
set (HAS_RSVG 1)
set (HAVE_RSVG 1) # NOTE: Update-me in `tint2conf'
else ()
message (FATAL_ERROR "tinto-panel: RSVG library not found!")
endif ()
endif ()
if (ENABLE_SN)
find_package (SN)
if (NOT SN_FOUND)
message (FATAL_ERROR "tinto-panel: Sartup Notification library not found!")
endif ()
target_include_directories (${tinto_panel_EXECUTABLE}
PUBLIC
"${SN_INCLUDE_DIRS}")
target_link_libraries (${tinto_panel_EXECUTABLE}
PUBLIC
${SN_LIBRARIES})
add_definitions (${SN_DEFINITIONS})
set (HAS_SN 1)
endif ()
if (ENABLE_TINT2CONF)
set (TINT2CONF 1)
set (TINTO_CONFIG_BIN tint2conf)
add_subdirectory (bin/tint2conf)
endif ()
target_include_directories (${tinto_panel_EXECUTABLE}
PUBLIC
"${GTK2_INCLUDE_DIRS}"
"${X11_X11_INCLUDE_PATH}"
${Imlib2_INCLUDE_DIRECTORIES}
)
target_link_libraries (${tinto_panel_EXECUTABLE}
PUBLIC
"${X11_X11_LIB}"
"${X11_Xcomposite_LIB}"
"${X11_Xdamage_LIB}"
"${X11_Xinerama_LIB}"
"${X11_Xrandr_LIB}"
"${X11_Xrender_LIB}"
"${GTK2_LIBRARIES}"
"${Imlib2_LIBRARIES}"
m
)
# if (DEBUG)
# set (tinto_panel_test_EXECUTABLE "tinto-panel-tests"
# CACHE
# INTERNAL
# "Name for the executable for tests.")
# add_executable (${tinto_panel_test_EXECUTABLE}
# "${CMAKE_CURRENT_LIST_DIR}/t/main.c")
# add_subdirectory (t)
# endif ()
add_subdirectory (src)
configure_file ("${CMAKE_SOURCE_DIR}/src/conf.h.in"
"${CMAKE_BINARY_DIR}/src/conf.h")
configure_file ("${CMAKE_SOURCE_DIR}/cmake/deinstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/deinstall.cmake")
install (TARGETS ${tinto_panel_EXECUTABLE} DESTINATION bin)
# Fix me: incorrect dest path.
install (FILES "${tinto_panel_IN_SOURCE_RES_DIR}/config-sample/tinto.conf"
DESTINATION xdg/${PROJECT_NAME})
install (FILES "${tinto_panel_IN_SOURCE_RES_DIR}/icon.png" DESTINATION
"${DATADIR}/${PROJECT_NAME}")
install (FILES ChangeLog readme.rst DESTINATION "${DOCDIR}")
install (FILES "${tinto_IN_SOURCE_DOC_DIR}/man/tinto.1"
DESTINATION "${MANDIR}/man1")
add_custom_target (deinstall COMMAND ${CMAKE_COMMAND} -P
"${CMAKE_BINARY_DIR}/cmake/deinstall.cmake")
if (ENABLE_EXAMPLES)
file (GLOB SAMPLEFILES
"${tinto_panel_IN_SOURCE_RES_DIR}/config-sample/*.conf")
install (FILES ${SAMPLEFILES} DESTINATION "${DOCDIR}/examples")
endif ()
mark_as_advanced (tinto_panel_IN_SOURCE_RES_DIR
tinto_panel_IN_SOURCE_BIN_DIR
tinto_panel_IN_SOURCE_DOC_DIR)