author | Myhailo Danylenko <isbear@ukrpost.net> |
Sun, 03 Jul 2011 22:17:16 +0300 | |
changeset 38 | 34a2b880615c |
parent 34 | 6bfad7c963f4 |
child 40 | 33ea13cef185 |
permissions | -rw-r--r-- |
20 | 1 |
## Copyright 2009 Myhailo Danylenko |
2 |
# This file is part of lua-lm |
|
3 |
# |
|
4 |
# lua-lm is free software: you can redistribute it and/or modify |
|
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/>. |
|
2 | 16 |
|
17 |
cmake_minimum_required(VERSION 2.6) |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
18 |
project(lua-lm C) |
2 | 19 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
20 |
## User options |
24
1ad539cb8dc6
Turn off debugging, note on require'ing
Myhailo Danylenko <isbear@ukrpost.net>
parents:
23
diff
changeset
|
21 |
option(DEBUG "Enable debugging output" OFF) |
27
23393a00c2c1
Small typo and header fixes
Myhailo Danylenko <isbear@ukrpost.net>
parents:
26
diff
changeset
|
22 |
set(TEST_USER "test@jabber.org" CACHE STRING "Testing: Your jabber account name") |
23393a00c2c1
Small typo and header fixes
Myhailo Danylenko <isbear@ukrpost.net>
parents:
26
diff
changeset
|
23 |
set(TEST_PASSWORD "greatsecret" CACHE STRING "Testing: Password for your jabber account") |
23393a00c2c1
Small typo and header fixes
Myhailo Danylenko <isbear@ukrpost.net>
parents:
26
diff
changeset
|
24 |
set(TEST_TO "test@jabber.org/mcabber" CACHE STRING "Testing: Target jabber entity") |
23393a00c2c1
Small typo and header fixes
Myhailo Danylenko <isbear@ukrpost.net>
parents:
26
diff
changeset
|
25 |
set(TEST_FINGERPRINT "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff" CACHE STRING "Testing: Your jabber server SSL fingerprint") |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
26 |
|
32
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
27 |
## Gather information about system |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
28 |
find_package(Lua51 REQUIRED) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
29 |
find_program(LUA_EXECUTABLE lua lua5.1 luanoreadline) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
30 |
if(LUA_EXECUTABLE) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
31 |
execute_process(COMMAND ${LUA_EXECUTABLE} -e "print ( package.path )" OUTPUT_VARIABLE LUA_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
32 |
execute_process(COMMAND ${LUA_EXECUTABLE} -e "print ( package.cpath )" OUTPUT_VARIABLE LUA_CPATH OUTPUT_STRIP_TRAILING_WHITESPACE) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
33 |
endif() |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
34 |
find_package(PkgConfig REQUIRED) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
35 |
pkg_check_modules(GLIB REQUIRED glib-2.0) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
36 |
pkg_check_modules(LM REQUIRED loudmouth-1.0) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
37 |
include(CheckFunctionExists) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
38 |
set(CMAKE_REQUIRED_INCLUDES ${LM_INCLUDE_DIRS}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
39 |
set(CMAKE_REQUIRED_LIBRARIES ${LM_LIBRARIES}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
40 |
set(CMAKE_REQUIRED_FLAGS ${LM_LDFLAGS} ${LM_CFLAGS}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
41 |
check_function_exists(lm_connection_get_keep_alive_rate HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
42 |
check_function_exists(lm_connection_unregister_reply_handler HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
43 |
find_package(Perl) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
44 |
# (this should be before targets definitions) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
45 |
link_directories(${LUA_LIBRARY_DIRS} ${GLIB_LIBRARY_DIRS} ${LM_LIBRARY_DIRS}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
46 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
47 |
## Define targets |
2 | 48 |
add_library(loudmouth MODULE util.c lm_types.c lm_proxy.c lm_ssl.c lm_connection.c lm_message.c lm_message_node.c lm_message_handler.c lm.c) |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
49 |
get_target_property(lua-lm_SOURCES loudmouth SOURCES) |
2 | 50 |
|
32
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
51 |
## Set up compiler |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
52 |
configure_file(config.h.in config.h) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
53 |
include_directories(SYSTEM ${LUA_INCLUDE_DIR} ${GLIB_INCLUDE_DIRS} ${LM_INCLUDE_DIRS}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
54 |
target_link_libraries(loudmouth ${LUA_LIBRARIES} ${GLIB_LIBRARIES} ${LM_LIBRARIES}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
55 |
include_directories(${lua-lm_SOURCE_DIR} ${lua-lm_BINARY_DIR}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
56 |
set_target_properties(loudmouth PROPERTIES PREFIX "") |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
57 |
|
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
58 |
## Extra targets |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
59 |
if(PERL_FOUND) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
60 |
add_custom_command(OUTPUT ${lua-lm_BINARY_DIR}/loudmouth.html COMMAND ${PERL_EXECUTABLE} ${lua-lm_SOURCE_DIR}/docgen.pl ${lua-lm_SOURCES} > ${lua-lm_BINARY_DIR}/loudmouth.html DEPENDS ${lua-lm_SOURCE_DIR}/docgen.pl ${lua-lm_SOURCES} WORKING_DIRECTORY ${lua-lm_SOURCE_DIR}) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
61 |
add_custom_target(doc ALL DEPENDS ${lua-lm_BINARY_DIR}/loudmouth.html) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
62 |
endif() |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
63 |
if(LUA_EXECUTABLE) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
64 |
add_custom_target(test COMMAND env "LUA_PATH=${lua-lm_SOURCE_DIR}/?.lua;${LUA_PATH}" "LUA_CPATH=${lua-lm_SOURCE_DIR}/?.so;${lua-lm_BINARY_DIR}/?.so;${LUA_CPATH}" "${LUA_EXECUTABLE}" "${lua-lm_SOURCE_DIR}/test.lua" "${TEST_USER}" "${TEST_PASSWORD}" "${TEST_TO}" "${TEST_FINGERPRINT}" DEPENDS loudmouth VERBATIM) |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
65 |
endif() |
493d5d5198c8
Fix build system settings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
66 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
67 |
## Packaging information |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
68 |
set(CPACK_PACKAGE_NAME liblua5.1-loudmouth) |
28
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
69 |
set(CPACK_PACKAGE_VERSION "0.9.0") |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
70 |
set(CPACK_PACKAGE_VENDOR "IsBear") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
71 |
set(CPACK_PACKAGE_CONTACT "Myhailo Danylenko <isbear@ukrpost.net>") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
72 |
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Loudmouth XMPP client library lua interface") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
73 |
set(CPACK_PACKAGE_DESCRIPTION_FILE ${lua-lm_SOURCE_DIR}/README) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
74 |
set(CPACK_RESOURCE_FILE_LICENSE ${lua-lm_SOURCE_DIR}/COPYING) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
75 |
set(CPACK_RESOURCE_FILE_README ${lua-lm_SOURCE_DIR}/README) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
76 |
set(CPACK_RESOURCE_FILE_WELCOME ${lua-lm_SOURCE_DIR}/README) |
28
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
77 |
set(CPACK_SOURCE_GENERATOR TBZ2) |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
78 |
set(CPACK_GENERATOR DEB CACHE STRING "Binary package generator, eg DEB, RPM, TGZ, NSIS...") |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
79 |
set(CPACK_DEBIAN_PACKAGE_SECTION libs) |
20 | 80 |
# XXX: tmp=`tempfile`; obj=${lua-lm_BINARY_DIR}/loudmouth.so; ldd $obj > $tmp; objdump -p $obj | \grep NEEDED | sed -e 's/.*NEEDED *//' | xargs -I "{}" grep -F "{}" $tmp | sed -e 's/.*=> *\(\S*\).*/\1/' | xargs dpkg -S | cut -d : -f 1 | sort -u ; \rm $tmp |
81 |
# TODO: versions |
|
82 |
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libglib2.0-0, liblua5.1-0, libloudmouth1-0") |
|
28
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
83 |
find_program(DPKG_EXECUTABLE dpkg) |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
84 |
if(DPKG_EXECUTABLE) |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
85 |
execute_process(COMMAND ${DPKG_EXECUTABLE} --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
86 |
else() |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
87 |
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386 CACHE STRING "Architecture of package") |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
88 |
endif() |
2e4650583dd7
Debian-compliant package names
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
89 |
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
90 |
# XXX: Set package name directly to get rid of -Sources? |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
91 |
set(CPACK_SOURCE_IGNORE_FILES "/\\\\..*;\\\\.swp;~$;/build/;\\\\.tar\\\\.;\\\\.deb;\\\\.so") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
92 |
include(CPack) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
93 |
|
34
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
94 |
## Set up installer |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
95 |
install(TARGETS loudmouth DESTINATION lib/lua/5.1) |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
96 |
install(FILES lm.lua DESTINATION share/lua/5.1) |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
97 |
install(FILES test.lua DESTINATION share/doc/${CPACK_PACKAGE_NAME}/examples) |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
98 |
if(PERL_FOUND) |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
99 |
install(FILES ${lua-lm_BINARY_DIR}/loudmouth.html DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
100 |
endif() |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
101 |
install(FILES README TODO COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
6bfad7c963f4
Fix documentation installation path
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
102 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
103 |
## The End ## vim: se ts=4: ## |