-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
143 lines (127 loc) · 3.48 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
cmake_minimum_required(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# ======
# Project information
project(ibus-qt)
set(AUTHORS "Peng Huang")
set(MAINTAINER "Peng Huang <shawn.p.huang at gmail dot com>")
set(VERSION_MAJOR "1")
set(VERSION_MINOR "3")
set(VERSION_PATCH "1")
set(VERSION_SNAPDATE "")
set(LIB_VERSION "1.3.0")
set(LIB_SOVERSION "1")
# ======
# CPack configure
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
if(NOT VERSION_SNAPDATE)
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
else(NOT VERSION_SNAPDATE)
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}.${VERSION_SNAPDATE})
endif(NOT VERSION_SNAPDATE)
set(CPACK_SET_DESTDIR "ON")
set(CPACK_INSTALL_PREFIX "/usr")
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
set(CPACK_SOURCE_IGNORE_FILES
"/\\\\.git/"
"\\\\.gitignore$"
"/CMakeFiles/"
"/_CPack_Packages/"
"cmake_install.cmake"
"CMakeCache.txt$"
"install_manifest.txt$"
"Makefile$"
"Source\\\\.tar\\\\.gz$"
"Linux\\\\.tar\\\\.gz$"
"moc_.*\\\\.cxx$"
"\\\\.so$"
"\\\\.so\\\\.*"
"ibus-test$"
"/rpm/"
"ibus-qt\\\\.spec$"
"CPackSourceConfig\\\\.cmake$"
"CPackConfig\\\\.cmake$"
"docs/Doxyfile$"
"docs/man"
"docs/html"
"build/"
)
include(CPack)
configure_file(ibus-qt.spec.in ibus-qt.spec)
configure_file(docs/Doxyfile.in docs/Doxyfile)
# ======
# Requires
# check X11
find_package(X11 REQUIRED)
# check qt
find_package(Qt4 4.5 COMPONENTS QtCore QtGui QtDBus QtXml REQUIRED)
include(${QT_USE_FILE})
# check dbus
find_package(PkgConfig REQUIRED)
find_package(ICU REQUIRED)
pkg_check_modules(DBUS REQUIRED dbus-1)
pkg_check_modules(IBUS REQUIRED ibus-1.0>=1.3.7)
# check doxygen
find_package(Doxygen REQUIRED)
# =====
# Define variables
if(NOT LIBDIR)
if( $ENV{MACHTYPE} MATCHES "64")
set(LIBDIR lib64)
else()
set(LIBDIR lib)
endif()
endif(NOT LIBDIR)
if(NOT DOCDIR)
set(DOCDIR "share/doc/ibus-qt-${CPACK_PACKAGE_VERSION}")
endif(NOT DOCDIR)
if(NOT MANDIR)
set(MANDIR "share/man")
endif(NOT MANDIR)
# =====
# install
set(MAIN_DOCS
AUTHORS
README
INSTALL)
install(FILES ${MAIN_DOCS}
DESTINATION ${DOCDIR})
# ======
# sub dirs
add_subdirectory(src)
add_subdirectory(qtim)
add_subdirectory(test)
add_subdirectory(docs)
# ======
# targets
add_custom_target(version echo ${CPACK_PACKAGE_VERSION})
add_custom_target(gitclean git clean -f -d -X)
add_custom_target(rpm
COMMAND make package_source
COMMAND rpmbuild -bb
--define "_sourcedir ${CMAKE_CURRENT_BINARY_DIR}"
--define "_builddir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
--define "_srcrpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
--define "_rpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
--define "_specdir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
ibus-qt.spec
SOURCES ibus-qt.spec
)
add_custom_target(srpm
COMMAND make package_source
COMMAND rpmbuild -bs
--define "_sourcedir ${CMAKE_CURRENT_BINARY_DIR}"
--define "_builddir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
--define "_srcrpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
--define "_rpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
--define "_specdir ${CMAKE_CURRENT_BINARY_DIR}/rpm"
ibus-qt.spec
SOURCES ibus-qt.spec
)