Project: KMess
Code Location: git://gitorious.org/kmess/kmess.gitkmess-2.0.x
Browse
/
Download File
CMakeLists.txt
PROJECT( kmess )


#### System checks ####

# To add checks, see in one or more of these paths
# /usr/share/cmake/Modules
# /usr/share/kde4/apps/cmake/modules
# /usr/share/apps/cmake

# Check for cmake, same as minimum for KDE 4.0.0
CMAKE_MINIMUM_REQUIRED( VERSION 2.4.5 )

# Check for KDE 4
FIND_PACKAGE( KDE4 REQUIRED )
INCLUDE( KDE4Defaults )

# Make sure the rest still works
IF( NOT KDE4_FOUND )
  # The macro's MACRO_LOG_FEATURE, MACRO_OPTIONAL_FIND_PACKAGE, MACRO_BOOL_TO_01
  # are part of the KDE cmake modules, so these can't be used now.

  MESSAGE( FATAL_ERROR "\n"
  "  The KDE Development Platform was not found.\n"
  "  \n"
  "  You will need this package and the matching development package.\n"
  "  Usually the package names for this library are:\n"
  "    on Debian and Ubuntu:   'kdebase-runtime' and 'kdelibs5-dev'\n"
  "    on openSUSE: 'kdebase4-runtime' and 'libkde4-devel'\n"
  "  \n"
  "  Please refer to the KMess board for more info,\n"
  "  and specially to this guide: http://trac.kmess.org/wiki/Compiling%20KMess" )
ENDIF( NOT KDE4_FOUND )

# Check for libxml2
FIND_PACKAGE( LibXml2 )
MACRO_LOG_FEATURE( LIBXML2_FOUND "LibXML2" "Libraries used to develop XML-aware applications" "http://www.xmlsoft.org/" TRUE ""
    "Required for the chat styles system.
      * You will need this package and the matching development package: for example, 'libxml2' and 'libxml2-dev' or 'libxml2-devel'.
      * Usually the package names for this library are:
        on Debian and Ubuntu: 'libxml2' and 'libxml2-dev'
        on openSUSE:          'libxml2' and 'libxml2-devel'
      * Please refer to the KMess board for more info,
        and specially to this guide: http://trac.kmess.org/wiki/Compiling%20KMess" )

# Check for libxslt
FIND_PACKAGE( LibXslt )
MACRO_LOG_FEATURE( LIBXSLT_FOUND "LibXSLT" "A library to transform XML into other formats" "http://www.xmlsoft.org/XSLT" TRUE ""
    "Required for the chat styles system.
      * Usually the package names for this library are:
        on Debian and Ubuntu: 'libxslt' and 'libxslt1-dev'
        on openSUSE:         'libxslt' and 'libxslt-devel'
      * Please refer to the KMess board for more info,
        and specially to this guide: http://trac.kmess.org/wiki/Compiling%20KMess" )

# Add cmake directory to the MODULE_PATH, so cmake can find GCrypt
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )

# Check for GCrypt
FIND_PACKAGE( GCrypt )
IF( NOT GCRYPT_FOUND )
  MACRO_LOG_FEATURE( GCRYPT_FOUND "GCrypt" "A library to encrypt messages with various cyphers" "http://www.gnupg.org/" TRUE ""
    "It is required for the Live Messenger login process.
      * Usually the package names for this library are:
        on Debian and Ubuntu: 'libgcrypt' and 'libgcrypt11-dev'
        on openSUSE:          'libgcrypt' and 'libgcrypt-devel'
        on Fedora:            'gcrypt' and 'gcrypt-devel'
      * Please refer to the KMess board for more info,
        and specially to this guide: http://trac.kmess.org/wiki/Compiling%20KMess" )
ELSE()
  MESSAGE( STATUS "Looking for GCrypt - found" )
ENDIF()

# Check for XScreenSaver extension
OPTION( WANT_XSCREENSAVER "Build with X11 screensaver auto-away support" ON )
IF( WANT_XSCREENSAVER )
  MACRO_BOOL_TO_01( X11_Xscreensaver_FOUND HAVE_XSCREENSAVER )
  MACRO_OPTIONAL_FIND_PACKAGE(X11)
  IF( X11_FOUND )
    MACRO_LOG_FEATURE( X11_Xscreensaver_FOUND "XScreenSaver" "X11 extension used to check idle state" "" FALSE ""
    "Required for the auto-away feature.
      * Usually the package names for this library are:
        on Debian and Ubuntu: 'libxss-dev'
        on openSUSE:          'xorg-x11-libs'
      * Please refer to the KMess board for more info,
        and specially to this guide: http://trac.kmess.org/wiki/Compiling%20KMess" )
  ELSE( X11_FOUND )
    MESSAGE( STATUS "NOTE: The auto-away feature is not supported on this platform yet." )
  ENDIF( X11_FOUND )
ENDIF( WANT_XSCREENSAVER )

# Check for libkonq
# QUIET is to fix compiling on systems like Debian Lenny, which don't have FindLibKonq.cmake
#   (for an optional feature, we don't want that to be fatal)
MACRO_OPTIONAL_FIND_PACKAGE( LibKonq QUIET )
MACRO_LOG_FEATURE( LIBKONQ_FOUND "LibKonq" "Integration with Konqueror context menu" "http://www.kde.org/" FALSE ""
    "This is an optional feature.
      * Usually the package names for this library are:
        on Debian and Ubuntu: 'libkonq5' and 'libkonq5-dev'
        on openSUSE:          'libkonq5' and 'libkonq-devel'
      * Please refer to the KMess board for more info,
        and specially to this guide: http://trac.kmess.org/wiki/Compiling%20KMess" )

# Check for libisf-qt
MACRO_OPTIONAL_FIND_PACKAGE( IsfQt QUIET )
MACRO_LOG_FEATURE( ISFQT_FOUND "LibISF-Qt" "Library to manage Microsoft's Mobile Ink" "http://www.kmess.org/" FALSE ""
    "Support to send handwriting messages in a format compatible with Windows Live Messenger.
     In absence of an installed isf-qt version, the bundled version will be compiled.")
MACRO_BOOL_TO_01( ISFQT_FOUND HAVE_LIBISFQT ) # For config-kmess.h.in

# Check for KNotificationItem. KDE 4.3.1 and later have it integrated in kdelibs/experimental.
# It will be available by default in 4.4.
IF( ${KDE_VERSION} VERSION_LESS 4.3.70 ) # KDE trunk has a higher version number than this.
  MACRO_OPTIONAL_FIND_PACKAGE(LibKNotificationItem-1)
  MACRO_LOG_FEATURE( LIBKNOTIFICATIONITEM-1_FOUND "LibKNotificationItem-1" "The experimental new KDE systray library" "http://www.kde.org" FALSE ""
    "LibKNotificationItem-1 is the experimental new KDE systray library. It will be included
     by default in KDE 4.4 and is available for use in KDE 4.3.1 and above." )
  MACRO_BOOL_TO_01( LIBKNOTIFICATIONITEM-1_FOUND HAVE_NEW_TRAY )
ELSE()
  SET( HAVE_NEW_TRAY 1 )
ENDIF()

# Display the dependency collection results
MACRO_DISPLAY_FEATURE_LOG()



#### Configure build ####

INCLUDE( MacroLibrary )
INCLUDE( KDE4Defaults )

IF( NOT ISFQT_FOUND )
# isf-qt is not installed on the system.
# use the bundled version.
  SET( ISFQT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/isf-qt/include )
  SET( ISFQT_LIBRARIES isf-qt )

  SET( USE_BUNDLED_LIBRARIES ${USE_BUNDLED_LIBRARIES} ISFQT )
  SET( HAVE_LIBISFQT 1 )
  SET( ISFQT_FOUND TRUE )
ENDIF( NOT ISFQT_FOUND )

ADD_DEFINITIONS( ${QT_DEFINITIONS} ${KDE4_DEFINITIONS} )

INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${LIBXML2_INCLUDE_DIR} )


#### Define the app version number ####

# Switch between the following two commands to force using a predefined version number
EXECUTE_PROCESS( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/get-git-version.sh OUTPUT_VARIABLE KMESS_VERSION )
# SET( KMESS_VERSION "2.0.7dev" )


#### Define compiler flags ####

# Tune the debug build with even more flags
# also see FindKDE4Internal.cmake for more defaults
IF( CMAKE_COMPILER_IS_GNUCXX )
  # skipped: -ansi -pendantic -Wfatal-errors -Wold-style-cast -Wconversion
  SET( CMAKE_CXX_FLAGS_DEBUG     "-O0 -g -Wall" )
  SET( CMAKE_CXX_FLAGS_DEBUGFULL "-O0 -g3 -fno-inline -Wall -Woverloaded-virtual -Wsign-compare -Wundef" )
  # the -fvisibility option makes symbols also visible to the KDE backtrace dumper, but
  # the MinGW gcc doesn't seem to understand it well, so only add it if we're not on win32
  IF( NOT WIN32 )
    SET( CMAKE_CXX_FLAGS_DEBUGFULL "${CMAKE_CXX_FLAGS_DEBUGFULL} -fvisibility=default" )
  ENDIF( NOT WIN32 )
ENDIF( CMAKE_COMPILER_IS_GNUCXX )


# Define the default build type
# Possible values:
# - none
# - release
# - debug
# - debugfull       (even fewer optimisations)
# - relwithdebinfo  (release with debug info)
# - minsizerel      (minsize release)
# Uncomment the next line to always force building in full debug mode
# SET( CMAKE_BUILD_TYPE debugfull )

# Enable the KMess debug output when compiling a debug build
IF( CMAKE_BUILD_TYPE STREQUAL debugfull OR KMESS_DEBUG_OUTPUT EQUAL 1 )
  SET( KMESS_ENABLE_DEBUG_OUTPUT "1" )
ELSE( CMAKE_BUILD_TYPE STREQUAL debugfull OR KMESS_DEBUG_OUTPUT EQUAL 1 )
  SET( KMESS_ENABLE_DEBUG_OUTPUT "0" )
ENDIF( CMAKE_BUILD_TYPE STREQUAL debugfull OR KMESS_DEBUG_OUTPUT EQUAL 1 )

IF( CMAKE_BUILD_TYPE STREQUAL debugfull )
  SET( KMESS_BUILT_DEBUGFULL TRUE )
ELSE( CMAKE_BUILD_TYPE STREQUAL debugfull )
  SET( KMESS_BUILT_DEBUGFULL FALSE )
ENDIF( CMAKE_BUILD_TYPE STREQUAL debugfull )

# Change symbol visibility, to obtain clearer KDE backtraces
SET( __KDE_HAVE_GCC_VISIBILITY 0 )

# Disable LikeBack if not needed
IF( KMESS_DISABLE_LIKEBACK EQUAL 1 )
  SET( KMESS_DISABLE_LIKEBACK "1" )
ELSE( KMESS_DISABLE_LIKEBACK EQUAL 1 )
  SET( KMESS_DISABLE_LIKEBACK "0" )
ENDIF( KMESS_DISABLE_LIKEBACK EQUAL 1 )

# Set a default installation path
IF( NOT CMAKE_INSTALL_PREFIX )
  SET( CMAKE_INSTALL_PREFIX "/usr" )
ENDIF( NOT CMAKE_INSTALL_PREFIX )

IF( CMAKE_USE_CPACK EQUAL 1 )
  MESSAGE( STATUS "Enabling the CPack package target..." )
  # source: http://www.vtk.org/Wiki/CMake:Packaging_With_CPack
  INCLUDE( InstallRequiredSystemLibraries )
  # the installer will be named ${PACKAGENAME}-{VERSIONMAJOR}.{VERSIONMINOR}.{VERSIONPATCH}-win32.exe.
  # the installer will say "Welcome to the ${INSTALL_DIRECTORY} Setup Wizard and install to ${INSTALL_DIRECTORY} too, and
  # put the program in start menu under the ${INSTALL_DIRECTORY} name.
  # it will ask if ${PACKAGENAME} should be put in PATH.
  SET( CPACK_PACKAGE_NAME "KMess" )
  SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KMess (package description)" )
  SET( CPACK_PACKAGE_VENDOR "The KMess team" )
  SET( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README" )
  SET( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" )
  SET( CPACK_PACKAGE_VERSION_MAJOR "1" )
  SET( CPACK_PACKAGE_VERSION_MINOR "0" )
  SET( CPACK_PACKAGE_VERSION_PATCH "0" )
  SET( CPACK_PACKAGE_INSTALL_DIRECTORY "KMess" )
  IF( WIN32 AND NOT UNIX )
    # There is a bug in NSI that does not handle full unix paths properly. Make
    # sure there is at least one set of four (4) backslashes.
    SET( CPACK_GENERATOR "NSIS" )
    SET( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/icons\\\\hi32-app-kmess.png" )
    SET( CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\kmess.exe" )
    SET( CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} KMess (display name)" )
    SET( CPACK_NSIS_HELP_LINK "http:\\\\\\\\kmess.org" )
    SET( CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\kmess.org" )
    SET( CPACK_NSIS_CONTACT "project@kmess.org" )
    SET( CPACK_NSIS_MODIFY_PATH ON )
  ELSE( WIN32 AND NOT UNIX )
    SET( CPACK_STRIP_FILES "bin/kmess" )
    SET( CPACK_SOURCE_STRIP_FILES "" )
  ENDIF( WIN32 AND NOT UNIX )

  SET( CPACK_PACKAGE_EXECUTABLES "kmess" "KMess" )
  INCLUDE( CPack )
ENDIF( CMAKE_USE_CPACK EQUAL 1 )

#### Other settings ####

# Generate config-kmess.h
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/config-kmess.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-kmess.h )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )

# continue in directories
ADD_SUBDIRECTORY( po )
ADD_SUBDIRECTORY( data )
ADD_SUBDIRECTORY( doc )
ADD_SUBDIRECTORY( src )

IF( LIBKONQ_FOUND )
  ADD_SUBDIRECTORY( src/utils/kmess-send )
ENDIF( LIBKONQ_FOUND )

IF( USE_BUNDLED_LIBRARIES MATCHES "ISFQT" )
  ADD_SUBDIRECTORY( contrib/isf-qt )
ENDIF( )


# Also add the tests if compiling in development mode
IF( CMAKE_BUILD_TYPE STREQUAL debugfull AND KMESS_DEBUG_OUTPUT EQUAL 1 )
  ADD_SUBDIRECTORY( tests )
ENDIF( CMAKE_BUILD_TYPE STREQUAL debugfull AND KMESS_DEBUG_OUTPUT EQUAL 1 )