CMakeLists.txt
author Mikael Berthe <mikael@lilotux.net>
Sun, 27 Mar 2011 22:03:30 +0200
changeset 113 3d4f0415c8f8
parent 103 2cb96eae301a
child 115 47bed161e3b0
permissions -rw-r--r--
Sync with new dev API


## Copyright 2009 Myhailo Danylenko
# This file is part of lua.
#
# 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_package(Perl)
link_directories(${GLIB_LIBRARY_DIRS}
				 ${GMODULE_LIBRARY_DIRS}
				 ${MCABBER_LIBRARY_DIRS})

## Define targets
add_library(lua MODULE lua.c util.c)

## 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(PERL_FOUND)
	get_target_property(lua_SOURCES lua SOURCES)
	add_custom_command(OUTPUT ${lua_BINARY_DIR}/lua.html COMMAND ${PERL_EXECUTABLE} ${lua_SOURCE_DIR}/docgen.pl ${lua_SOURCES} > ${lua_BINARY_DIR}/lua.html DEPENDS ${lua_SOURCE_DIR}/docgen.pl ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR})
	add_custom_target(doc ALL DEPENDS ${lua_BINARY_DIR}/lua.html)
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)

## Set up installer
install(TARGETS lua DESTINATION lib/mcabber)
if(PERL_FOUND)
	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 README DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(FILES TODO DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(FILES COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME})

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