Add add-cmake
authorMyhailo Danylenko <isbear@ukrpost.net>
Thu, 23 Jun 2011 23:49:22 +0300
changeset 22 18ec7aaefc9f
parent 21 98afc2f0a092
child 23 cd3518eab042
Add add-cmake * Removed some no more necessary checks in configure.ac * Added CMakeLists.txt (this is just to try it, not a serious attempt to migrate there)
add-cmake
series
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/add-cmake	Thu Jun 23 23:49:22 2011 +0300
@@ -0,0 +1,231 @@
+# HG changeset patch
+# Parent 94a0c8396f959cdf99264b4c4d4007150e872b9f
+
+diff -r 94a0c8396f95 mcabber/CMakeLists.txt
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/mcabber/CMakeLists.txt	Thu Jun 23 23:45:20 2011 +0300
+@@ -0,0 +1,196 @@
++## Copyright 2010 Myhailo Danylenko
++# This file is part of mcabber.
++#
++# mcabber 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(mcabber C)
++set(PROJECT_VERSION "0.10.2-dev")
++
++## User settable options
++option(DEBUG "Enable debugging output" OFF)
++option(USE_SIGWINCH "Compile with SIGWINCH handler" OFF)
++option(XEP0022 "Enable obsolete Message Events (XEP-0022)" OFF)
++option(ENABLE_MODULES "Enable dynamic module loading" ON)
++option(WANT_LIBIDN "Compile with libidn support" ON)
++option(WANT_GPGME "Compile with PGP support (libgpgme required)" ON)
++option(WANT_OTR "Compile with OTR support" OFF)
++option(WANT_ENCHANT "Use enchant for spell-checking" OFF)
++option(WANT_ASPELL "Use aspell for spell-checking" OFF)
++
++set(MCABBER_BRANCH "experimental")
++set(MCABBER_VERSION ${PROJECT_VERSION})
++
++## Check for build dependencies
++find_package(PkgConfig REQUIRED)
++
++## Glib
++pkg_check_modules(GLIB REQUIRED glib-2.0>=2.14.0)
++if (ENABLE_MODULES)
++	pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
++endif()
++
++## Loudmouth
++pkg_check_modules(LM REQUIRED loudmouth-1.0>=1.4.2)
++include(CheckSymbolExists)
++set(CMAKE_REQUIRED_INCLUDES ${LM_INCLUDE_DIRS})
++set(CMAKE_REQUIRED_LIBRARIES ${LM_LIBRARIES})
++set(CMAKE_REQUIRESD_FLAGS ${LM_LDFLAGS} ${LM_CFLAGS})
++check_symbol_exists(lm_connection_unregister_reply_handler loudmouth/loudmouth.h HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER)
++
++## Libidn
++if(WANT_LIBIDN)
++	pkg_check_modules(LIBIDN libidn)
++	if(LIBIDN_FOUND)
++		set(HAVE_LIBIDN TRUE)
++	endif()
++endif()
++
++## Ncursesw / Ncurses / Curses
++pkg_check_modules(NCURSESW ncursesw)
++if(NCURSESW_FOUND)
++	pkg_check_modules(PANELW REQUIRED panelw)
++	set(HAVE_UNICODE TRUE)
++else()
++	pkg_check_modules(NCURSES ncurses)
++	if(NCURSES_FOUND)
++		pkg_check_modules(PANEL REQUIRED panel)
++		set(HAVE_UNICODE FALSE)
++	else()
++		find_package(Curses)
++		# FIXME
++	endif()
++endif()
++# we do not use curses, and we check for waddnwstr in both libs to determine HAVE_UNICODE
++# check for ESCDELAY by just linking HAVE_ESCDELAY
++
++if(WANT_GPGME)
++#  provides own gpgme-config O_o
++	set(HAVE_GPGME TRUE)
++endif()
++
++if(WANT_OTR)
++#  gcrypt provides own libgcrypt-config O_o
++#  libotr have nothing :(
++	set(OTR TRUE)
++endif()
++
++if(WANT_ENCHANT)
++	pkg_check_modules(ENCHANT enchant)
++	if(ENCHANT_FOUND)
++		set(WITH_ENCHANT TRUE)
++	endif()
++elseif(WANT_ASPELL)
++	find_package(ASPELL)
++	if(ASPELL_FOUND)
++		set(WITH_ASPELL TRUE)
++	endif()
++# aspell_{include_dir,libraries,definitions}
++endif()
++
++#include(CheckIncludeFile)
++#set(CMAKE_REQUIRED_INCLUDES ${MCABBER_INCLUDE_DIRS})
++#check_include_file(mcabber/disco.h HAVE_MCABBER_DISCO_H)
++#	message(SEND_ERROR "Disco module headers not found")
++
++link_directories(${GLIB_LIBRARY_DIRS}
++                 ${GMODULE_LIBRARY_DIRS}
++                 ${LM_LIBRARY_DIRS}
++				 ${LIBIDN_LIBRARY_DIRS}
++				 ${ENCHANT_LIBRARY_DIRS}
++				 ${NCURSESW_LIBRARY_DIRS}
++				 ${NCURSES_LIBRARY_DIRS})
++
++## Define targets
++add_executable(mcabber mcabber/main.c ) # FIXME
++if(ENABLE_MODULES)
++# Put these into per-project dirs?
++	add_library(beep MODULE modules/beep/beep.c)
++	add_library(eventcmd MODULE modules/beep/eventcmd.c mcabber/extcmd.c)
++	add_library(fifo MODULE modules/fifo/fifo_module.c mcabber/fifo.c)
++	add_library(urlregex MODULE modules/urlregex/urlregex.c)
++	add_library(xttitle MODULE modules/xttitle/xttitle.c)
++endif()
++
++## Compiler setup
++configure_file(config.h.in config.h)
++include_directories(SYSTEM ${GLIB_INCLUDE_DIRS}
++                    ${GMODULE_INCLUDE_DIRS}
++                    ${LM_INCLUDE_DIRS}
++					${LIBIDN_INCLUDE_DIRS}
++					${ENCHANT_INCLUDE_DIRS}
++					${NCURSESW_INCLUDE_DIRS}
++					${NCURSES_INCLUDE_DIRS})
++target_link_libraries(mcabber ${LUA_LIBRARIES} ${GLIB_LIBRARIES})
++target_link_libraries(mcabber ${GLIB_LIBRARIES}
++                      ${GMODULE_LIBRARIES}
++                      ${LM_LIBRARIES}
++					  ${LIBIDN_LIBRARIES}
++					  ${ENCHANT_LIBRARIES}
++					  ${NCURSESW_LIBRARIES}
++					  ${NCURSES_LIBRARIES})
++include_directories(${mcabber_SOURCE_DIR} ${mcabber_BINARY_DIR})
++#                      PREFIX "" # for module libraries
++set_target_properties(mcabber PROPERTIES
++					  COMPILE_FLAGS "-Wall")
++
++## Extra targets
++#	add_custom_command(OUTPUT ${mcabber_BINARY_DIR}/mcabber.html COMMAND ${mcabber_SOURCE_DIR}/docgen.pl ${mcabber_SOURCES} > ${mcabber_BINARY_DIR}/mcabber.html DEPENDS ${mcabber_SOURCE_DIR}/docgen.pl ${mcabber_SOURCES} WORKING_DIRECTORY ${mcabber_SOURCE_DIR})
++#	add_custom_target(doc ALL DEPENDS ${mcabber_BINARY_DIR}/mcabber.html)
++#	add_custom_target(test COMMAND env "LUA_PATH=${mcabber_SOURCE_DIR}/?.lua;${LUA_PATH}" "LUA_CPATH=${mcabber_SOURCE_DIR}/?.so;${mcabber_BINARY_DIR}/?.so;${LUA_CPATH}" lua ${mcabber_SOURCE_DIR}/test.lua DEPENDS mcabber VERBATIM)
++
++## Packaging information
++set(CPACK_PACKAGE_NAME liblua5.1-mcabber) # XXX
++set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
++set(CPACK_PACKAGE_VENDOR "McKael")
++set(CPACK_PACKAGE_CONTACT "Mikael BERTHE <mikael@lilotux.net>")
++set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "small Jabber (XMPP) console client")
++set(CPACK_PACKAGE_DESCRIPTION_FILE ${mcabber_SOURCE_DIR}/README)
++set(CPACK_RESOURCE_FILE_LICENSE ${mcabber_SOURCE_DIR}/COPYING)
++set(CPACK_RESOURCE_FILE_README ${mcabber_SOURCE_DIR}/README)
++set(CPACK_RESOURCE_FILE_WELCOME ${mcabber_SOURCE_DIR}/README)
++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)
++# XXX: tmp=`tempfile`; obj=${mcabber_BINARY_DIR}/mcabber.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
++set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
++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}")
++# 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 mcabber DESTINATION bin)
++if(ENABLE_MODULES)
++	install(FILES mcabber/*.h DESTINATION include/mcabber) # FIXME
++	install(TARGETS beep eventcmd fifo urlregex xttitle DESTINATION lib/mcabber)
++	install(FILES mcabber.pc DESTINATION lib/pkgconfig) # XXX should we install it into share?
++endif()
++install(DIRECTORY doc/help/cs doc/help/de doc/help/en doc/help/fr doc/help/it doc/help/nl doc/help/pl doc/help/ru doc/help/uk DESTINATION share/mcabber/help)
++install(FILES mcabberrc.example DESTINATION share/doc/${CPACK_PACKAGE_NAME}/examples)
++install(FILES AUTHORS README TODO ChangeLog.api doc/HOWTO_modules.txt doc/README_PGP.txt DESTINATION share/doc/${CPACK_PACKAGE_NAME})
++install(FILES doc/mcabber.1.html doc/manpage.css DESTINATION share/doc/${CPACK_PACKAGE_NAME}/html)
++# guide
++install(FILES ChangeLog DESTINATION share/doc/${CPACK_PACKAGE_NAME} RENAME changelog)
++install(FILES COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME} RENAME copyright)
++install(FILES doc/mcabber.1 DESTINATION share/man/man1)
++
++## The End ## vim: se ts=4 sw=4: ##
++
+diff -r 94a0c8396f95 mcabber/configure.ac
+--- a/mcabber/configure.ac	Wed Jun 08 02:47:31 2011 +0000
++++ b/mcabber/configure.ac	Thu Jun 23 23:45:20 2011 +0300
+@@ -36,9 +36,8 @@
+ 
+ # Checks for header files.
+ AC_HEADER_STDC
+-AC_CHECK_HEADERS([arpa/inet.h fcntl.h locale.h netdb.h netinet/in.h stddef.h \
+-                  stdlib.h string.h strings.h sys/socket.h sys/time.h \
+-                  syslog.h termios.h wchar.h wctype.h localcharset.h])
++AC_CHECK_HEADERS([fcntl.h locale.h stdlib.h string.h sys/time.h \
++                  termios.h wchar.h wctype.h localcharset.h])
+ AC_CHECK_HEADERS([unistd.h], , AC_MSG_ERROR([Missing header file]))
+ AC_VAR_TIMEZONE_EXTERNALS
+ 
+@@ -59,10 +58,8 @@
+ AC_TYPE_SIGNAL
+ AC_FUNC_STRFTIME
+ AC_FUNC_VPRINTF
+-AC_CHECK_FUNCS([alarm arc4random bzero gethostbyname gethostname inet_ntoa \
+-                isascii memmove memset modf select setlocale socket strcasecmp \
+-                strchr strdup strncasecmp strrchr strstr strcasestr vsnprintf \
+-                iswblank])
++AC_CHECK_FUNCS([arc4random memset setlocale strcasecmp strchr strncasecmp \
++                strrchr strstr strcasestr iswblank])
+ 
+ 
+ AC_CHECK_DECLS([strptime],,,
--- a/series	Wed Apr 27 12:42:38 2011 +0300
+++ b/series	Thu Jun 23 23:49:22 2011 +0300
@@ -4,3 +4,4 @@
 guard-xmpp-password
 roster-state-colors
 extend-caps
+add-cmake