-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
126 lines (100 loc) · 3.86 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
PROJECT (deedbeef-statusnotifier-plugin)
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.8)
SET (PROJECT_NAME "StatusNotifier Plugin")
SET (VERSION "1.6.0")
SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
IF (LIB_INSTALL_DIR)
SET (LIBDIR ${LIB_INSTALL_DIR})
ENDIF (LIB_INSTALL_DIR)
IF (NOT LIBDIR)
IF ({CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64)
SET (LIBDIR "lib64")
ELSE ({CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64)
SET (LIBDIR "lib")
ENDIF ({CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64)
ENDIF (NOT LIBDIR)
INCLUDE (CheckIncludeFile)
INCLUDE (FindPkgConfig)
FIND_PACKAGE (PkgConfig)
FIND_PACKAGE (Threads)
FIND_PACKAGE (Gettext)
OPTION (USE_GTK "GTK+ 2.x interface" ON)
OPTION (USE_GTK3 "GTK+ 3.x interface" ON)
OPTION (USE_CUSTOM "Custom glib-mkenums tool" ON)
IF (USE_CUSTOM)
SET(MKENUMS_EXECUTABLE ${PROJECT_SOURCE_DIR}/tools/glib-mkenums)
ELSE (USE_CUSTOM)
FIND_PROGRAM(MKENUMS_EXECUTABLE NAMES glib-mkenums)
ENDIF (USE_CUSTOM)
SET (SNI_SOURCE_DIR ${PROJECT_SOURCE_DIR}/extras/statusnotifier/src)
AUX_SOURCE_DIRECTORY (${SNI_SOURCE_DIR} SNI_SRCS)
SET (PLUGIN_SRCS ${PROJECT_SOURCE_DIR}/src/menu.c
${PROJECT_SOURCE_DIR}/src/sni.c)
PKG_CHECK_MODULES (DBUSMENU_GLIB REQUIRED dbusmenu-glib-0.4)
PKG_CHECK_MODULES (X11 x11)
FIND_PATH(HAVE_DEADBEEF_HEADER "deadbeef/deadbeef.h")
IF (HAVE_DEADBEEF_HEADER)
MESSAGE(STATUS "deadbeef/deadbeef.h - found")
ELSE (HAVE_DEADBEEF_HEADER)
MESSAGE(FATAL_ERROR "Can't find folder containing deadbeef/deadbeef.h")
ENDIF (HAVE_DEADBEEF_HEADER)
FIND_PATH(HAVE_GTKUI_HEADER "deadbeef/gtkui_api.h")
IF (HAVE_GTKUI_HEADER)
MESSAGE(STATUS "deadbeef/gtkui_api.h - found")
ELSE (HAVE_GTKUI_HEADER)
MESSAGE(FATAL_ERROR "Can't find folder containing deadbeef/gtkui_api.h")
ENDIF (HAVE_GTKUI_HEADER)
ADD_CUSTOM_COMMAND (PRE_BUILD
OUTPUT ${PROJECT_BINARY_DIR}/enums.c
COMMAND ${MKENUMS_EXECUTABLE}
ARGS
--template ${SNI_SOURCE_DIR}/enums.c.template
${SNI_SOURCE_DIR}/statusnotifier.h > ${PROJECT_BINARY_DIR}/enums.c
WORKING_DIRECTORY ${SNI_SOURCE_DIR}
DEPENDS ${SNI_SOURCE_DIR}/enums.c.template
)
ADD_CUSTOM_COMMAND (PRE_BUILD
OUTPUT ${PROJECT_BINARY_DIR}/enums.h
COMMAND ${MKENUMS_EXECUTABLE}
ARGS
--template ${SNI_SOURCE_DIR}/enums.h.template
${SNI_SOURCE_DIR}/statusnotifier.h > ${PROJECT_BINARY_DIR}/enums.h
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${SNI_SOURCE_DIR}/enums.h.template
)
LIST (APPEND SNI_SRCS
${PROJECT_BINARY_DIR}/enums.c
${PROJECT_BINARY_DIR}/enums.h
)
ADD_DEFINITIONS(-DUSE_DBUSMENU)
ADD_DEFINITIONS(-DENABLE_NLS)
ADD_DEFINITIONS(-DG_LOG_DOMAIN="plugin-sni")
SET (CMAKE_C_VISIBILITY_PRESET hidden)
IF (USE_GTK)
PKG_CHECK_MODULES (GTK2 REQUIRED gtk+-2.0)
ADD_LIBRARY (sni_gtk2 MODULE ${PLUGIN_SRCS} ${SNI_SRCS})
SET_TARGET_PROPERTIES (sni_gtk2 PROPERTIES
COMPILE_FLAGS "${GTK2_CFALFS}"
INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR};${PROJECT_SOURCE_DIR};${SNI_SOURCE_DIR};${GTK2_INCLUDE_DIRS};${DBUSMENU_GLIB_INCLUDE_DIRS}"
PREFIX ""
)
TARGET_LINK_LIBRARIES (sni_gtk2 ${GTK2_LIBRARIES} ${DBUSMENU_GLIB_LIBRARIES} ${X11_LIBRARIES})
INSTALL (TARGETS sni_gtk2 LIBRARY DESTINATION ${LIBDIR}/deadbeef NAMELINK_SKIP)
ENDIF (USE_GTK)
IF (USE_GTK3)
PKG_CHECK_MODULES (GTK3 REQUIRED gtk+-3.0)
ADD_LIBRARY (sni_gtk3 MODULE ${PLUGIN_SRCS} ${SNI_SRCS})
SET_TARGET_PROPERTIES (sni_gtk3 PROPERTIES
COMPILE_FLAGS "${GTK3_CFALFS}"
INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR};${PROJECT_SOURCE_DIR};${SNI_SOURCE_DIR};${GTK3_INCLUDE_DIRS};${DBUSMENU_GLIB_INCLUDE_DIRS}"
PREFIX ""
)
TARGET_LINK_LIBRARIES (sni_gtk3 ${GTK3_LIBRARIES} ${DBUSMENU_GLIB_LIBRARIES} ${X11_LIBRARIES})
INSTALL (TARGETS sni_gtk3 LIBRARY DESTINATION ${LIBDIR}/deadbeef NAMELINK_SKIP)
ENDIF (USE_GTK3)
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${PROJECT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_uninstall.cmake")