-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
116 lines (97 loc) · 3.94 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
PROJECT(gmpc-dynamic-playlist C)
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
SET(VERSION_MAJOR 0)
SET(VERSION_MINOR 19)
SET(VERSION_PATCH 96)
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
SET(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
SET(TEST_DIR "${PROJECT_SOURCE_DIR}/tests")
SET(PO_DIR "${PROJECT_SOURCE_DIR}/po")
FIND_PACKAGE(PkgConfig REQUIRED)
IF(NOT PKG_CONFIG_FOUND)
MESSAGE(FATAL_ERROR "You need 'pkg-config' to build this plugin!")
ENDIF()
FILE(GLOB C_FILES "${SRC_DIR}/*.c")
FILE(GLOB PO_FILES "${PO_DIR}/*.po")
FILE(GLOB UI_FILES "${SRC_DIR}/*.xml")
GET_FILENAME_COMPONENT(UI_OPTIONS ${UI_FILES} NAME)
ADD_LIBRARY(dynlist SHARED ${C_FILES})
FIND_PACKAGE(Gettext QUIET)
FIND_PROGRAM(GETTEXT_XGETTEXT_BIN xgettext)
IF(NOT GETTEXT_FOUND OR NOT GETTEXT_XGETTEXT_BIN)
MESSAGE(STATUS "Translations won't be build... gettext isn't available!")
ELSE()
SET(POT_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pot")
ADD_CUSTOM_COMMAND(
OUTPUT ${POT_FILE}
COMMAND ${GETTEXT_XGETTEXT_BIN} --omit-header --keyword=_ --keyword=N_ ${C_FILES} -o ${POT_FILE}
COMMAND ${GETTEXT_XGETTEXT_BIN} -L Glade ${UI_FILES} -j -o ${POT_FILE}
--package-name=${PROJECT_NAME} --package-version=${VERSION} [email protected]
)
IF(PO_FILES)
MESSAGE(STATUS "Translations will be build!")
GETTEXT_CREATE_TRANSLATIONS(${POT_FILE} ALL ${PO_FILES})
ELSE()
MESSAGE(STATUS "Translations not found!")
ENDIF()
ENDIF()
pkg_check_modules(GMPC REQUIRED gmpc>=11.8.90)
pkg_check_modules(LIBMPD REQUIRED libmpd>=11.8.90)
pkg_check_modules(DEPS REQUIRED
glib-2.0>=2.16
gtk+-3.0>=3.7
gobject-2.0>=2.4
)
INCLUDE_DIRECTORIES(${DEPS_INCLUDE_DIRS} ${GMPC_INCLUDE_DIRS} ${LIBMPD_INCLUDE_DIRS})
LINK_DIRECTORIES(${DEPS_LIBRARY_DIRS} ${GMPC_LIBRARY_DIRS} ${LIBMPD_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(dynlist PROPERTIES OUTPUT_NAME "dynlistplugin")
SET_TARGET_PROPERTIES(dynlist PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(dynlist ${DEPS_LIBRARIES} ${GMPC_LIBRARIES} ${LIBMPD_LIBRARIES})
IF(NOT DEFINED plugindir)
SET(plugindir "${GMPC_LIBDIR}/gmpc/plugins")
ENDIF()
INSTALL(TARGETS dynlist DESTINATION ${plugindir})
INSTALL(FILES ${UI_FILES} DESTINATION ${plugindir})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wfloat-equal -Wconversion")
ADD_DEFINITIONS(-D GETTEXT_PACKAGE="\\"${PROJECT_NAME}\\"")
ADD_DEFINITIONS(-D PACKAGE_LOCALE_DIR="\\"${CMAKE_INSTALL_PREFIX}/share/locale\\"")
ADD_DEFINITIONS(-D VERSION_MAJOR=${VERSION_MAJOR} -D VERSION_MINOR=${VERSION_MINOR} -D VERSION_PATCH=${VERSION_PATCH})
ADD_DEFINITIONS(-D UI_OPTIONS="\\"${plugindir}/${UI_OPTIONS}\\"")
SET_DIRECTORY_PROPERTIES(PROPERTIES COMPILE_DEFINITIONS G_LOG_DOMAIN="dynlist")
FIND_PROGRAM(MERCURIAL_BIN hg)
IF(MERCURIAL_BIN AND EXISTS "${PROJECT_SOURCE_DIR}/.hg")
EXECUTE_PROCESS(COMMAND ${MERCURIAL_BIN} id -i ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE HG_REV
RESULT_VARIABLE HG_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(${HG_RESULT} EQUAL 0)
ADD_DEFINITIONS(-D HG_REV="\\"${HG_REV}\\"")
MESSAGE(STATUS "Revision: ${HG_REV}")
ENDIF()
ENDIF()
MESSAGE(STATUS "Version: ${VERSION}")
MESSAGE(STATUS "Using CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS "Using plugindir: ${plugindir}")
IF(tests)
IF(${DEPS_glib-2.0_VERSION} VERSION_LESS 2.20 OR ${DEPS_gtk+-2.0_VERSION} VERSION_LESS 2.14)
MESSAGE(STATUS "Tests won't be build: glib2 or gtk2 is too old for testing!")
ELSE()
MESSAGE(STATUS "Tests will be build!")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -O0")
SET(debug on)
ENABLE_TESTING()
ADD_SUBDIRECTORY(${TEST_DIR})
ENDIF()
ENDIF()
IF(NOT DEFINED debug OR NOT debug)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D G_DISABLE_ASSERT")
MESSAGE(STATUS "G_ASSERTs are disabled!")
ELSE()
MESSAGE(STATUS "G_ASSERTs are enabled!")
ENDIF()
IF("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
MESSAGE(STATUS "Warning: in tree build is not recommended!")
ENDIF()
INCLUDE(Tools)
#vim:set ts=4 sw=4: