CMakeLists.txt
author Myhailo Danylenko <isbear@ukrpost.net>
Sun, 17 Feb 2013 06:00:16 +0200
changeset 61 b0b6e8307e38
parent 59 50173578fddc
child 63 d644c08bbc27
permissions -rw-r--r--
v0.0.2, change deb naming scheme

## Copyright 2009-2012 Myhailo Danylenko
# This file is part of mcabber-disco
#
# mcabber-disco is a 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(disco C) 
set(PROJECT_VERSION "0.0.2")

## User settable options
 
## Check for build dependencies
find_package(PkgConfig REQUIRED) 
pkg_check_modules(GLIB REQUIRED glib-2.0) 
pkg_check_modules(LM REQUIRED loudmouth-1.0)
pkg_check_modules(MCABBER REQUIRED mcabber)
include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${LM_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${LM_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS ${LM_LDFLAGS} ${LM_CFLAGS})
check_symbol_exists(lm_connection_unregister_reply_handler loudmouth/loudmouth.h HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER)
include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${MCABBER_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${MCABBER_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS ${MCABBER_LDFLAGS} ${MCABBER_CFLAGS})
check_c_source_compiles("
	#include <glib.h>
	#include <mcabber/api.h>
	#ifdef MCABBER_API_HAVE_COMPL_FLAGS
	int main (void) { return 0; }
	#endif
	" HAVE_MCABBER_COMPLETION_FLAGS)
link_directories(${GLIB_LIBRARY_DIRS}
				 ${LM_LIBRARY_DIRS}
				 ${MCABBER_LIBRARY_DIRS})

## Target definitions
add_library(disco MODULE disco.c)

## Compiler setup
configure_file(config.h.in config.h)
include_directories(SYSTEM ${GLIB_INCLUDE_DIRS} 
                    ${LM_INCLUDE_DIRS}
					${MCABBER_INCLUDE_DIRS}) 
target_link_libraries(disco ${GLIB_LIBRARIES} 
					  ${LM_LIBRARIES}
					  ${MCABBER_LIBRARIES})
include_directories(${disco_SOURCE_DIR} 
                    ${disco_BINARY_DIR}) 
set_target_properties(disco PROPERTIES COMPILE_FLAGS "-Wall")

## Packaging information
set(CPACK_PACKAGE_NAME mcabber-mod-disco)
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 module for service discovery requests")
set(CPACK_RESOURCE_FILE_LICENSE ${disco_SOURCE_DIR}/COPYING)
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_GENERATOR DEB CACHE TEXT "Binary package generator, eg DEB, RPM, TGZ, NSIS...")
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 TEXT "Architecture of package")
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
set(CPACK_SOURCE_IGNORE_FILES "/\\\\..*;\\\\.swp;~$;/build/;\\\\.tar\\\\.;\\\\.deb;\\\\.so")
include(CPack)

if(HAVE_MCABBER_COMPLETION_FLAGS)
		set(AVV_COMPL_VERSION "compl:4")
else()
		set(AVV_COMPL_VERSION "compl:2 | compl:3")
endif()
configure_file(disco.avv.in disco.avv)

## Installation
install(TARGETS disco DESTINATION lib/mcabber) 
install(FILES docs/disco.rc COPYING docs/todo.mdwn docs/readme.mdwn DESTINATION share/doc/${CPACK_PACKAGE_NAME})
install(FILES disco.h DESTINATION include/mcabber)
install(DIRECTORY help DESTINATION share/mcabber)
install(FILES ${PROJECT_BINARY_DIR}/disco.avv DESTINATION share/mcabber/avv/modules RENAME disco)

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