forked from mathslinux/lwqq
-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
178 lines (155 loc) · 5.65 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
# vim: ts=3 sts=3 sw=3 noet
project(liblwqq)
cmake_minimum_required(VERSION 2.8)
set(VERSION_MAJOR "0")
set(VERSION_MINOR "6")
set(VERSION_PATCH "1")
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
add_definitions(-Wall)
option(WITHOUT_ASYNC "Fully Disable Async Ability, Only Sync mode" Off)
set(QUICK_QUIT False CACHE BOOL "Hide Option: Detatch thread to quickly quit")
option(USE_MSG_THREAD "Use a single thread to run msg poll" Off)
find_package(Sphinx)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(PkgConfig REQUIRED)
#recommand libcurl>=7.22.0
pkg_check_modules(CURL REQUIRED libcurl)
pkg_check_modules(SQLITE REQUIRED sqlite3)
pkg_check_modules(ZLIB REQUIRED zlib)
pkg_check_modules(MOZJS mozjs-17.0)
set(MOZJS_17 ${MOZJS_FOUND} CACHE BOOL "use mozjs-17.0 version")
if(NOT MOZJS_FOUND)
pkg_check_modules(MOZJS mozjs185)
set(MOZJS_185 ${MOZJS_FOUND} CACHE BOOL "use mozjs185 version")
endif()
find_package(EV)
find_package(Libuv)
endif()
if(CYGWIN)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CURL REQUIRED libcurl)
pkg_check_modules(SQLITE REQUIRED sqlite3)
pkg_check_modules(ZLIB REQUIRED zlib)
pkg_check_modules(MOZJS mozjs-17.0)
set(MOZJS_17 ${MOZJS_FOUND} CACHE BOOL "use mozjs-17.0 version")
if(NOT MOZJS_FOUND)
pkg_check_modules(MOZJS mozjs185)
set(MOZJS_185 ${MOZJS_FOUND} CACHE BOOL "use mozjs185 version")
endif()
find_package(EV)
#recommand libcurl>=7.22.0
if(WITH_LIBUV)
find_package(Libuv REQUIRED)
endif()
endif()
if(APPLE)
find_package(PkgConfig REQUIRED)
find_package(CURL REQUIRED)
find_package(Sqlite3 REQUIRED)
find_package(ZLIB REQUIRED)
pkg_check_modules(MOZJS mozjs-17.0)
set(MOZJS_17 ${MOZJS_FOUND} CACHE BOOL "use mozjs-17.0 version")
if(NOT MOZJS_FOUND)
pkg_check_modules(MOZJS mozjs185)
set(MOZJS_185 ${MOZJS_FOUND} CACHE BOOL "use mozjs185 version")
endif()
find_package(EV)
find_package(Libuv)
endif()
if(WIN32)
set(CMAKE_PREFIX_PATH
"${WIN32_LIBS_DIR}/libcurl"
"${WIN32_LIBS_DIR}/libcurl/include"
"${WIN32_LIBS_DIR}/libcurl/lib"
)
find_package(CURL REQUIRED)
set(CMAKE_PREFIX_PATH "${WIN32_LIBS_DIR}/sqlite3")
find_package(Sqlite3 REQUIRED)
set(CMAKE_PREFIX_PATH
"${WIN32_LIBS_DIR}/zlib/include"
"${WIN32_LIBS_DIR}/zlib/lib"
)
find_package(ZLIB REQUIRED)
set(CMAKE_PREFIX_PATH
"${WIN32_LIBS_DIR}/libuv/include"
"${WIN32_LIBS_DIR}/libuv/Release"
"${WIN32_LIBS_DIR}/libuv/Debug")
find_package(Libuv)
set(CMAKE_PREFIX_PATH
"${WIN32_LIBS_DIR}/js-1.8.5-mingw32/include/js"
"${WIN32_LIBS_DIR}/js-1.8.5-mingw32/lib"
)
find_package(MozJS REQUIRED)
set(MOZJS_185 ${MOZJS_FOUND})
find_package(EV)
include(GenerateExportHeader)
endif(WIN32)
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(strtok_r HAVE_STRTOK_R)
#CHECK_FUNCTION_EXISTS(open_memstream HAVE_OPEN_MEMSTREAM)
option(HAVE_OPEN_MEMSTREAM "using open_memstream in http.c" OFF)
option(WITH_LIBEV "Use Libev To Provide Async " ${EV_FOUND})
if(WITH_LIBEV AND NOT EV_FOUND)
message(FATAL_ERROR "Required package libev not found")
endif()
if(WIN32)
#only windows open libuv by default
option(WITH_LIBUV "Use Libuv To Provide Async " ${UV_FOUND})
else()
option(WITH_LIBUV "Use Libuv To Provide Async " OFF)
endif()
if(WITH_LIBUV AND NOT UV_FOUND)
message(FATAL_ERROR "Required package libuv not found")
endif()
if(WITH_LIBEV AND WITH_LIBUV)
message(FATAL_ERROR "Libuv and Libev shouldn't used together; Turn off one")
endif()
#option(WITH_MOZJS "Use Mozjs To Provide hash.js support" ${MOZJS_FOUND})
set(WITH_MOZJS On) # Force Require MOZJS
if(WITH_MOZJS AND NOT MOZJS_FOUND)
message(FATAL_ERROR "Reuired mozjs185 or mozjs-17.0 package not found")
endif()
option(ENABLE_DOCS "Build Documentation" OFF)
if(ENABLE_DOCS AND NOT SPHINX_FOUND)
message(FATAL_ERROR "Reuired python-sphinx package not found")
endif()
set(RES_DIR "${CMAKE_INSTALL_PREFIX}/share/lwqq" CACHE STRING "A resource dir")
#always true because we force enable sqlite
set(WITH_SQLITE True)
set(LIB_INSTALL_DIR "lib" CACHE STRING "the directory to install library")
message( "================lwqq flags=====================")
if(WIN32)
message(STATUS "With Libuv (Option) : ${WITH_LIBUV}")
else()
message(STATUS "With Libev (Option) : ${WITH_LIBEV}")
endif()
message(STATUS "With Mozjs (Option) : ${WITH_MOZJS}")
message(STATUS "Build Document (Option) : ${ENABLE_DOCS}")
message( "===============================================")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
configure_file(config.h.in ${PROJECT_BINARY_DIR}/lwqq-config.h)
configure_file(lwqq.pc.in ${PROJECT_BINARY_DIR}/lwqq.pc @ONLY)
install(FILES "${PROJECT_BINARY_DIR}/lwqq-config.h" DESTINATION include/lwqq)
install(FILES "${PROJECT_BINARY_DIR}/lwqq.pc" DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
install(FILES encrypt.js DESTINATION "${RES_DIR}")
add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(python)
if(ENABLE_DOCS)
add_subdirectory(doc)
endif()
# package settings
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "lwqq provide a lightweight interconnection library to connect to the QQ network threw WebQQ")
set(CPACK_PACKAGE_VENDOR "xiehuc")
set(CPACK_PACKAGE_DESCRIPTION "WebQQ protocol interconnection protocol (library)")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}")
set(ACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jaussoin Timothée") #required
set(PACK "DEB" CACHE STRING "Generate a Package")
set(CPACK_GENERATOR ${PACK})
include(CPack)