author | Myhailo Danylenko <isbear@ukrpost.net> |
Wed, 28 Nov 2012 20:17:53 +0200 | |
changeset 146 | 04d19c9c1196 |
parent 145 | 9f7bbb768ba8 |
child 147 | 66a63c9609de |
permissions | -rw-r--r-- |
131
d1d2754bbdaf
Update copyright header in cmakelists
Myhailo Danylenko <isbear@ukrpost.net>
parents:
129
diff
changeset
|
1 |
## Copyright 2009-2012 Myhailo Danylenko |
d1d2754bbdaf
Update copyright header in cmakelists
Myhailo Danylenko <isbear@ukrpost.net>
parents:
129
diff
changeset
|
2 |
# This file is part of mcabber-lua. |
72 | 3 |
# |
131
d1d2754bbdaf
Update copyright header in cmakelists
Myhailo Danylenko <isbear@ukrpost.net>
parents:
129
diff
changeset
|
4 |
# mcabber-lua is free software: you can redistribute it and/or modify |
72 | 5 |
# it under the terms of the GNU General Public License as published by |
6 |
# the Free Software Foundation, either version 2 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
0 | 16 |
|
17 |
cmake_minimum_required(VERSION 2.6) |
|
83
794e54ea1022
Package/module name change
Myhailo Danylenko <isbear@ukrpost.net>
parents:
79
diff
changeset
|
18 |
project(lua C) |
144
690b5524b895
v0.0.3 Module and command names include lua version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
143
diff
changeset
|
19 |
set(PROJECT_VERSION "0.0.3") |
0 | 20 |
|
21 |
## User options |
|
143 | 22 |
option(DEBUG "Enable debugging output" ON) |
23 |
option(WANT_LUA52 "Use lua 5.2 instead of 5.1" OFF) |
|
144
690b5524b895
v0.0.3 Module and command names include lua version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
143
diff
changeset
|
24 |
option(ENABLE_LUA_ALIAS "Enable aliasing command '/lua' to corresponding '/lua5.x' at module loading time" ON) |
143 | 25 |
option(LLM_CONNECTION_ENABLE "Enable exposing of mcabber loudmouth connection to lua" ON) |
26 |
option(LLM_LOG_HANDLER "Enable registration of log messages handler for lua-loudmouth library's messages" ON) |
|
30
2cf24aced294
Definitions moved to cmake options
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
27 |
set(ML_SOURCE_PRIORITY G_PRIORITY_HIGH_IDLE CACHE STRING "Glib event source priority for timeout and bgread") |
143 | 28 |
set(ML_BGREAD_BUFFER 4096 CACHE STRING "Background pipe reading buffer size") |
144
690b5524b895
v0.0.3 Module and command names include lua version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
143
diff
changeset
|
29 |
set(OPT_MLUA_RC "lua_init_filename" CACHE STRING "Mcabber option name to specify lua initialization file") |
690b5524b895
v0.0.3 Module and command names include lua version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
143
diff
changeset
|
30 |
set(OPT_MLUA_LM_DEBUG "lua_lm_debug" CACHE STRING "Mcabber option name to enable/disable lua logging of LM messages") |
0 | 31 |
|
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
32 |
## Gather information about system |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
33 |
find_package(PkgConfig REQUIRED) |
143 | 34 |
if(NOT WANT_LUA52) |
35 |
find_package(Lua51) |
|
36 |
endif() |
|
37 |
if(WANT_LUA52 OR NOT LUA51_FOUND) |
|
38 |
pkg_check_modules(LUA REQUIRED lua5.2) |
|
39 |
set(LUA_VERSION "5.2") |
|
40 |
set(HAVE_LUA52 "1") |
|
41 |
else() |
|
42 |
set(LUA_VERSION "5.1") |
|
43 |
set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIR}) |
|
44 |
endif() |
|
145
9f7bbb768ba8
Remove dot in module/command names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
144
diff
changeset
|
45 |
string(REPLACE "." "" LUA_MODULENAME "lua${LUA_VERSION}") |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
46 |
pkg_check_modules(GLIB REQUIRED glib-2.0) |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
47 |
pkg_check_modules(GMODULE REQUIRED gmodule-2.0) |
93
0a10228296c1
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
91
diff
changeset
|
48 |
pkg_check_modules(MCABBER REQUIRED mcabber) |
119
2e5d5571a4ba
Drop in-project docgen
Myhailo Danylenko <isbear@ukrpost.net>
parents:
115
diff
changeset
|
49 |
find_program(DOCGEN_EXECUTABLE NAMES docgen.pl docgen DOC "Docgen documentation generator script (optional)") |
142
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
50 |
include(CheckCSourceCompiles) |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
51 |
set(CMAKE_REQUIRED_INCLUDES ${MCABBER_INCLUDE_DIRS}) |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
52 |
set(CMAKE_REQUIRED_LIBRARIES ${MCABBER_LIBRARIES}) |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
53 |
set(CMAKE_REQUIRED_FLAGS ${MCABBER_LDFLAGS} ${MCABBER_CFLAGS}) |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
54 |
check_c_source_compiles(" |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
55 |
#include <glib.h> |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
56 |
#include <mcabber/api.h> |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
57 |
#ifdef MCABBER_API_HAVE_COMPL_FLAGS |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
58 |
int main (void) { return 0; } |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
59 |
#endif |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
60 |
" HAVE_MCABBER_COMPLETION_FLAGS) |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
61 |
link_directories(${GLIB_LIBRARY_DIRS} |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
62 |
${GMODULE_LIBRARY_DIRS} |
93
0a10228296c1
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
91
diff
changeset
|
63 |
${MCABBER_LIBRARY_DIRS}) |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
64 |
|
0 | 65 |
## Define targets |
103 | 66 |
add_library(lua MODULE lua.c util.c) |
119
2e5d5571a4ba
Drop in-project docgen
Myhailo Danylenko <isbear@ukrpost.net>
parents:
115
diff
changeset
|
67 |
get_target_property(lua_SOURCES lua SOURCES) |
0 | 68 |
|
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
69 |
## Set up compiler |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
70 |
configure_file(config.h.in config.h ESCAPE_QUOTES) |
143 | 71 |
include_directories(SYSTEM ${LUA_INCLUDE_DIRS} |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
72 |
${GLIB_INCLUDE_DIRS} |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
73 |
${GMODULE_INCLUDE_DIRS} |
93
0a10228296c1
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
91
diff
changeset
|
74 |
${MCABBER_INCLUDE_DIRS}) |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
75 |
target_link_libraries(lua ${LUA_LIBRARIES} |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
76 |
${GLIB_LIBRARIES} |
93
0a10228296c1
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
91
diff
changeset
|
77 |
${GMODULE_LIBRARIES} |
0a10228296c1
New module loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
91
diff
changeset
|
78 |
${MCABBER_LIBRARRIES}) |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
79 |
include_directories(${lua_SOURCE_DIR} |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
80 |
${lua_BINARY_DIR}) |
145
9f7bbb768ba8
Remove dot in module/command names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
144
diff
changeset
|
81 |
set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wall" OUTPUT_NAME "${LUA_MODULENAME}") |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
82 |
|
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
83 |
## Extra targets |
119
2e5d5571a4ba
Drop in-project docgen
Myhailo Danylenko <isbear@ukrpost.net>
parents:
115
diff
changeset
|
84 |
if(DOCGEN_EXECUTABLE) |
143 | 85 |
add_custom_command(OUTPUT ${lua_BINARY_DIR}/lua.html COMMAND ${DOCGEN_EXECUTABLE} -f html -t "Documentation for Lua module for MCabber" -o ${lua_BINARY_DIR}/lua.html -- ${lua_SOURCES} DEPENDS ${DOCGEN_EXECUTABLE} ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR}) |
86 |
add_custom_target(doc ALL DEPENDS ${lua_BINARY_DIR}/lua.html) |
|
129
ea30cf6c5bea
Rearrange documentation
Myhailo Danylenko <isbear@ukrpost.net>
parents:
121
diff
changeset
|
87 |
add_custom_command(OUTPUT ${lua_SOURCE_DIR}/docs/api.mdwn COMMAND ${DOCGEN_EXECUTABLE} -f mdwn -t "Documentation for Lua module for MCabber" -o ${lua_SOURCE_DIR}/docs/api.mdwn -- ${lua_SOURCES} DEPENDS ${DOCGEN_EXECUTABLE} ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR}) |
ea30cf6c5bea
Rearrange documentation
Myhailo Danylenko <isbear@ukrpost.net>
parents:
121
diff
changeset
|
88 |
add_custom_target(update_api DEPENDS ${lua_SOURCE_DIR}/docs/api.mdwn) |
90
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
89 |
endif() |
3102f7def87b
Fix linker library search path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
88
diff
changeset
|
90 |
|
0 | 91 |
## Packaging information |
145
9f7bbb768ba8
Remove dot in module/command names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
144
diff
changeset
|
92 |
set(CPACK_PACKAGE_NAME mcabber-mod-${LUA_MODULENAME}) |
143 | 93 |
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) |
94 |
set(CPACK_PACKAGE_VENDOR "IsBear") |
|
95 |
set(CPACK_PACKAGE_CONTACT "Myhailo Danylenko <isbear@ukrpost.net>") |
|
144
690b5524b895
v0.0.3 Module and command names include lua version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
143
diff
changeset
|
96 |
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mcabber module for lua ${LUA_VERSION} scripting") |
143 | 97 |
set(CPACK_PACKAGE_DESCRIPTION_FILE ${lua_SOURCE_DIR}/README) |
98 |
set(CPACK_RESOURCE_FILE_LICENSE ${lua_SOURCE_DIR}/COPYING) |
|
99 |
set(CPACK_RESOURCE_FILE_README ${lua_SOURCE_DIR}/README) |
|
100 |
set(CPACK_RESOURCE_FILE_WELCOME ${lua_SOURCE_DIR}/README) |
|
78 | 101 |
set(CPACK_SOURCE_GENERATOR TBZ2) |
143 | 102 |
set(CPACK_GENERATOR DEB CACHE STRING "Binary package generator, eg DEB, RPM, TGZ, NSIS...") |
78 | 103 |
# XXX |
143 | 104 |
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, liblua${LUA_VERSION}-0, libglib2.0-0") |
105 |
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "mcabber") |
|
106 |
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "lua${LUA_VERSION}-posix, lua${LUA_VERSION}-base64, lua${LUA_VERSION}-sha1") |
|
107 |
set(CPACK_DEBIAN_PACKAGE_SECTION libs) |
|
108 |
find_program(DPKG_EXECUTABLE dpkg DOC "Path to dpkg (optional, to detect architecture)") |
|
78 | 109 |
if(DPKG_EXECUTABLE) |
110 |
execute_process(COMMAND ${DPKG_EXECUTABLE} --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) |
|
111 |
else() |
|
112 |
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386 CACHE STRING "Architecture of package") |
|
113 |
endif() |
|
143 | 114 |
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") |
0 | 115 |
# XXX: Set package name directly to get rid of -Sources? |
143 | 116 |
set(CPACK_SOURCE_IGNORE_FILES "/\\\\..*;\\\\.swp;~$;/build/;\\\\.tar\\\\.;\\\\.deb;\\\\.so") |
0 | 117 |
include(CPack) |
118 |
||
142
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
119 |
if(HAVE_MCABBER_COMPLETION_FLAGS) |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
120 |
set(AVV_COMPL_VERSION "compl:4") |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
121 |
else() |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
122 |
set(AVV_COMPL_VERSION "compl:3") |
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
123 |
endif() |
145
9f7bbb768ba8
Remove dot in module/command names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
144
diff
changeset
|
124 |
configure_file(lua.avv.in ${LUA_MODULENAME}.avv) |
115
47bed161e3b0
Add AVV description file
Myhailo Danylenko <isbear@ukrpost.net>
parents:
103
diff
changeset
|
125 |
|
91
37968123db86
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
90
diff
changeset
|
126 |
## Set up installer |
143 | 127 |
install(TARGETS lua DESTINATION lib/mcabber) |
119
2e5d5571a4ba
Drop in-project docgen
Myhailo Danylenko <isbear@ukrpost.net>
parents:
115
diff
changeset
|
128 |
if(DOCGEN_EXECUTABLE) |
143 | 129 |
install(FILES ${lua_BINARY_DIR}/lua.html DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
91
37968123db86
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
90
diff
changeset
|
130 |
endif() |
143 | 131 |
install(DIRECTORY examples DESTINATION share/doc/${CPACK_PACKAGE_NAME} PATTERN "*~" EXCLUDE) |
132 |
install(FILES docs/readme.mdwn docs/todo.mdwn COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
|
144
690b5524b895
v0.0.3 Module and command names include lua version
Myhailo Danylenko <isbear@ukrpost.net>
parents:
143
diff
changeset
|
133 |
install(FILES help/en/hlp_lua.txt DESTINATION share/mcabber RENAME hlp_lua${LUA_VERSION}.txt) # XXX localizations/other help |
145
9f7bbb768ba8
Remove dot in module/command names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
144
diff
changeset
|
134 |
install(FILES ${PROJECT_BINARY_DIR}/${LUA_MODULENAME}.avv DESTINATION share/mcabber/avv/modules RENAME ${LUA_MODULENAME}) |
91
37968123db86
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
90
diff
changeset
|
135 |
|
142
7e8f523b66af
Add completion sorting.
Myhailo Danylenko <isbear@ukrpost.net>
parents:
131
diff
changeset
|
136 |
## The End ## vim: se ts=4 sw=4: ## |