author | Myhailo Danylenko <isbear@ukrpost.net> |
Tue, 19 May 2009 00:44:52 +0300 | |
changeset 21 | a9b92b65961e |
parent 20 | 0ce7093df25f |
child 22 | 1a1bc121fe90 |
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 |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
21 |
option(DEBUG "Enable debugging output" ON) |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
22 |
|
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
23 |
## Define targets |
2 | 24 |
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
|
25 |
get_target_property(lua-lm_SOURCES loudmouth SOURCES) |
2 | 26 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
27 |
## Packaging information |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
28 |
set(CPACK_PACKAGE_NAME liblua5.1-loudmouth) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
29 |
set(CPACK_PACKAGE_VERSION_MAJOR 0) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
30 |
set(CPACK_PACKAGE_VERSION_MINOR 0) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
31 |
set(CPACK_PACKAGE_VERSION_PATCH 0) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
32 |
set(CPACK_PACKAGE_VENDOR "IsBear") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
33 |
set(CPACK_PACKAGE_CONTACT "Myhailo Danylenko <isbear@ukrpost.net>") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
34 |
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
|
35 |
set(CPACK_PACKAGE_DESCRIPTION_FILE ${lua-lm_SOURCE_DIR}/README) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
36 |
set(CPACK_RESOURCE_FILE_LICENSE ${lua-lm_SOURCE_DIR}/COPYING) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
37 |
set(CPACK_RESOURCE_FILE_README ${lua-lm_SOURCE_DIR}/README) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
38 |
set(CPACK_RESOURCE_FILE_WELCOME ${lua-lm_SOURCE_DIR}/README) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
39 |
set(CPACK_DEBIAN_PACKAGE_SECTION libs) |
20 | 40 |
# 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 |
41 |
# TODO: versions |
|
42 |
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libglib2.0-0, liblua5.1-0, libloudmouth1-0") |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
43 |
set(CPACK_SOURCE_GENERATOR TBZ2) |
20 | 44 |
set(CPACK_GENERATOR DEB CACHE TEXT "Binary package generator, eg DEB, RPM, TGZ, NSIS...") |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
45 |
# FIXME: Detect architecture. How? Though, it anyway produces nonconformant deb names... |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
46 |
set(CPACK_SYSTEM_NAME i386) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
47 |
# XXX: Set package name directly to get rid of -Sources? |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
48 |
set(CPACK_SOURCE_IGNORE_FILES "/\\\\..*;\\\\.swp;~$;/build/;\\\\.tar\\\\.;\\\\.deb;\\\\.so") |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
49 |
include(CPack) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
50 |
|
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
51 |
## Gather information about system |
2 | 52 |
find_package(Lua51 REQUIRED) |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
53 |
execute_process(COMMAND lua -e "print ( package.path )" OUTPUT_VARIABLE LUA_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
54 |
execute_process(COMMAND lua -e "print ( package.cpath )" OUTPUT_VARIABLE LUA_CPATH OUTPUT_STRIP_TRAILING_WHITESPACE) |
2 | 55 |
find_package(PkgConfig REQUIRED) |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
56 |
pkg_check_modules(GLIB REQUIRED glib-2.0) |
2 | 57 |
pkg_check_modules(LM REQUIRED loudmouth-1.0) |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
58 |
include(CheckFunctionExists) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
59 |
set(CMAKE_REQUIRED_INCLUDES ${LM_INCLUDE_DIRS}) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
60 |
set(CMAKE_REQUIRED_LIBRARIES ${LM_LIBRARIES}) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
61 |
check_function_exists(lm_connection_get_keep_alive_rate HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
62 |
find_package(Perl) |
2 | 63 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
64 |
## Set up compiler |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
65 |
configure_file(config.h.in config.h) |
2 | 66 |
include_directories(SYSTEM ${LUA_INCLUDE_DIR} ${GLIB_INCLUDE_DIRS} ${LM_INCLUDE_DIRS}) |
67 |
target_link_libraries(loudmouth ${LUA_LIBRARIES} ${GLIB_LIBRARIES} ${LM_LIBRARIES}) |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
68 |
include_directories(${lua-lm_SOURCE_DIR} ${lua-lm_BINARY_DIR}) |
3 | 69 |
set_target_properties(loudmouth PROPERTIES PREFIX "") |
2 | 70 |
|
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
71 |
## Extra targets |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
72 |
if(PERL_FOUND) |
7
5db1448eb857
Message have node methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
73 |
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}) |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
74 |
add_custom_target(doc ALL DEPENDS ${lua-lm_BINARY_DIR}/loudmouth.html) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
75 |
endif() |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
76 |
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 ${lua-lm_SOURCE_DIR}/test.lua DEPENDS loudmouth VERBATIM) |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
77 |
add_custom_target(test1 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 ${lua-lm_BINARY_DIR}/test.lua DEPENDS loudmouth VERBATIM) |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
78 |
|
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
79 |
## Set up installer |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
80 |
install(TARGETS loudmouth DESTINATION lib/lua/5.1) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
81 |
install(FILES lm.lua DESTINATION share/lua/5.1) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
82 |
install(FILES test.lua DESTINATION share/doc/${CPACK_PACKAGE_NAME}/examples) |
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
83 |
if(PERL_FOUND) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
84 |
install(FILES ${lua-lm_BINARY_DIR}/loudmouth.html DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
5
diff
changeset
|
85 |
endif() |
5
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
86 |
install(FILES README DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
87 |
install(FILES TODO DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
88 |
install(FILES COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME}) |
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
89 |
|
e617c9cf6dd3
Updates to build system
Myhailo Danylenko <isbear@ukrpost.net>
parents:
3
diff
changeset
|
90 |
## The End ## vim: se ts=4: ## |