CMakeLists.txt
author Myhailo Danylenko <isbear@ukrpost.net>
Sun, 14 Oct 2012 03:38:27 +0300
changeset 139 067712fb29f6
parent 131 d1d2754bbdaf
child 142 7e8f523b66af
permissions -rw-r--r--
Cleanup hgignore

## Copyright 2009-2012 Myhailo Danylenko
# This file is part of mcabber-lua.
#
# mcabber-lua is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 2.6)
project(lua C)
set(PROJECT_VERSION "0.0.1")

## User options
option(DEBUG "Enable debugging output" ON)
option(LLM_CONNECTION_ENABLE "Enable exposing of mcabber loudmouth connection to lua" ON)
option(LLM_LOG_HANDLER "Enable registration of log messages handler for lua-loudmouth library's messages" ON)
set(ML_SOURCE_PRIORITY G_PRIORITY_HIGH_IDLE CACHE STRING "Glib event source priority for timeout and bgread")
set(ML_BGREAD_BUFFER 4096 CACHE STRING "Background pipe reading buffer size")

## Gather information about system
find_package(Lua51 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
pkg_check_modules(MCABBER REQUIRED mcabber)
find_program(DOCGEN_EXECUTABLE NAMES docgen.pl docgen DOC "Docgen documentation generator script (optional)")
link_directories(${GLIB_LIBRARY_DIRS}
				 ${GMODULE_LIBRARY_DIRS}
				 ${MCABBER_LIBRARY_DIRS})

## Define targets
add_library(lua MODULE lua.c util.c)
get_target_property(lua_SOURCES lua SOURCES)

## Set up compiler
configure_file(config.h.in config.h ESCAPE_QUOTES)
include_directories(SYSTEM ${LUA_INCLUDE_DIR}
					${GLIB_INCLUDE_DIRS}
					${GMODULE_INCLUDE_DIRS}
					${MCABBER_INCLUDE_DIRS})
target_link_libraries(lua ${LUA_LIBRARIES}
					  ${GLIB_LIBRARIES}
					  ${GMODULE_LIBRARIES}
					  ${MCABBER_LIBRARRIES})
include_directories(${lua_SOURCE_DIR}
					${lua_BINARY_DIR})
set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wall")

## Extra targets
if(DOCGEN_EXECUTABLE)
	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})
	add_custom_target(doc ALL DEPENDS ${lua_BINARY_DIR}/lua.html)
	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})
	add_custom_target(update_api DEPENDS ${lua_SOURCE_DIR}/docs/api.mdwn)
endif()

## Packaging information
set(CPACK_PACKAGE_NAME libmcabber-lua)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "IsBear")
set(CPACK_PACKAGE_CONTACT "Myhailo Danylenko <isbear@ukrpost.net>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mcabber lua module")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${lua_SOURCE_DIR}/README)
set(CPACK_RESOURCE_FILE_LICENSE ${lua_SOURCE_DIR}/COPYING)
set(CPACK_RESOURCE_FILE_README ${lua_SOURCE_DIR}/README)
set(CPACK_RESOURCE_FILE_WELCOME ${lua_SOURCE_DIR}/README)
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_GENERATOR DEB CACHE STRING "Binary package generator, eg DEB, RPM, TGZ, NSIS...")
# XXX
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, liblua5.1-0, libglib2.0-0")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "mcabber-lm | mcabber")
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "liblua5.1-posix1, liblua5.1-base64-0, liblua5.1-sha1-0")
set(CPACK_DEBIAN_PACKAGE_SECTION libs)
find_program(DPKG_EXECUTABLE dpkg)
if(DPKG_EXECUTABLE)
	execute_process(COMMAND ${DPKG_EXECUTABLE} --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
	set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386 CACHE STRING "Architecture of package")
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
# XXX: Set package name directly to get rid of -Sources?
set(CPACK_SOURCE_IGNORE_FILES "/\\\\..*;\\\\.swp;~$;/build/;\\\\.tar\\\\.;\\\\.deb;\\\\.so")
include(CPack)

configure_file(lua.avv.in lua.avv)

## Set up installer
install(TARGETS lua DESTINATION lib/mcabber)
if(DOCGEN_EXECUTABLE)
	install(FILES ${lua_BINARY_DIR}/lua.html DESTINATION share/doc/${CPACK_PACKAGE_NAME})
endif()
install(DIRECTORY examples DESTINATION share/doc/${CPACK_PACKAGE_NAME} PATTERN "*~" EXCLUDE)
install(FILES docs/readme.mdwn docs/todo.mdwn COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(DIRECTORY help DESTINATION share/mcabber)
install(FILES ${PROJECT_BINARY_DIR}/lua.avv DESTINATION share/mcabber/avv/modules RENAME lua)

## The End ## vim: se ts=4: ##