project(openfetion-all)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
set(TARNAME openfetion-all)
# program name, version etc
set(OFETION_VERSION_MAJOR "2")
set(OFETION_VERSION_MINER "1")
set(OFETION_VERSION_PATCH "0")
# library API version
set(LIBOFETION_MAJOR_VERSION "1")
set(LIBOFETION_MINOR_VERSION "1")
set(LIBOFETION_PATCH_VERSION "0")
# library ABI version
set(LIBOFETION_SO_CUR_VERSION "1")
set(LIBOFETION_SO_REV_VERSION "0")
set(LIBOFETION_SO_AGE_VERSION "0")
set(LIBOFETION_VERSION_STRING
"${LIBOFETION_MAJOR_VERSION}.${LIBOFETION_MINOR_VERSION}.${LIBOFETION_PATCH_VERSION}"
)
set(LIBOFETION_SO_VERION_STRING
"${LIBOFETION_SO_CUR_VERSION}.${LIBOFETION_SO_REV_VERSION}.${LIBOFETION_SO_AGE_VERSION}"
)
set(PACKAGE_VERSION "${OFETION_VERSION_MAJOR}.${OFETION_VERSION_MINER}.${OFETION_VERSION_PATCH}")
set(PACKAGE_NAME "openfetion")
set(PACKAGE_TARNAME "${TARNAME}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "http://code.google.com/p/ofetion/issues/list")
find_package(PkgConfig REQUIRED)
##########################################################################
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(NOT DEFINED LIB_INSTALL_DIR)
if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
##########################################################################
if(NOT DEFINED BIN_INSTALL_DIR)
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
endif(NOT DEFINED BIN_INSTALL_DIR)
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(NOT DEFINED LIB_INSTALL_DIR)
if(NOT DEFINED DATA_INSTALL_DIR)
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share")
endif(NOT DEFINED DATA_INSTALL_DIR)
if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
add_definitions(-DRESOURCE_DIR="${DATA_INSTALL_DIR}/openfetion/resource/")
install(
FILES resource/city.xml resource/province.xml
DESTINATION ${DATA_INSTALL_DIR}/openfetion/resource
)
install(FILES resource/newmessage.wav DESTINATION ${DATA_INSTALL_DIR}/openfetion/resource)
install(FILES resource/openfetion.desktop DESTINATION ${DATA_INSTALL_DIR}/applications)
pkg_check_modules(LIBXML2 REQUIRED libxml-2.0)
pkg_check_modules(OPENSSL REQUIRED openssl)
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
# gnu ld version script
set(_link_flags " ")
if(CMAKE_COMPILER_IS_GNUCXX)
include(TestCXXAcceptsFlag)
set(_version_script "${CMAKE_CURRENT_SOURCE_DIR}/lib/libofetion.map")
check_cxx_accepts_flag("-Wl,--version-script,${_version_script}" LD_ACCEPTS_VERSION_SCRIPT)
if(LD_ACCEPTS_VERSION_SCRIPT)
set(_link_flags "${_link_flags} -Wl,--version-script,'${_version_script}'")
endif(LD_ACCEPTS_VERSION_SCRIPT)
endif(CMAKE_COMPILER_IS_GNUCXX)
##########################################################################
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(NOT DEFINED LIB_INSTALL_DIR)
if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
##########################################################################
add_definitions(-Wall -Wextra)
##########################################################################
include_directories(
${LIBXML2_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set(libofetion_SRC
lib/fetion_buddylist.c
lib/fetion_config.c
lib/fetion_connection.c
lib/fetion_contact.c
lib/fetion_conversation.c
lib/fetion_debug.c
lib/fetion_directsms.c
lib/fetion_group.c
lib/fetion_history.c
lib/fetion_list.c
lib/fetion_login.c
lib/fetion_message.c
lib/fetion_share.c
lib/fetion_sip.c
lib/fetion_user.c
)
add_library(ofetion SHARED ${libofetion_SRC})
target_link_libraries(ofetion ${LIBXML2_LIBRARIES} ${OPENSSL_LIBRARIES} ${SQLITE3_LIBRARIES})
set_target_properties(ofetion PROPERTIES
VERSION ${LIBOFETION_SO_VERION_STRING}
SOVERSION ${LIBOFETION_SO_CUR_VERSION}
LINK_FLAGS ${_link_flags}
)
add_library(ofetion-static STATIC ${libofetion_SRC})
SET_TARGET_PROPERTIES(ofetion-static PROPERTIES OUTPUT_NAME "ofetion")
SET_TARGET_PROPERTIES(ofetion-static PROPERTIES PREFIX "lib")
install(TARGETS ofetion ofetion-static
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
file(GLOB ofetion_INCLUDES "lib/*.h")
install(FILES ${ofetion_INCLUDES} DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
##########################################################################
configure_file(lib/ofetion.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/ofetion.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ofetion.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
# compile option switch
option(WITH_LIBNOTIFY "Libnotify support" ON)
option(WITH_GSTREAMER "GStreamer support" ON)
option(WITH_LIBXSS "LibXScrnSaver support" ON)
option(WITH_NETWORKMANAGER "NetworkManager support" ON)
# openfetion build requirements
find_package(PkgConfig REQUIRED)
if(NOT DISABLE_NLS)
find_package(Gettext)
endif(NOT DISABLE_NLS)
# openfetion build requirements
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
pkg_check_modules(GDKPIXBUF REQUIRED gdk-pixbuf-2.0)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
#if use system ofetion, need check ofetion,
#if build localely, no need to check
if(WITH_LIBNOTIFY)
pkg_check_modules(LIBNOTIFY libnotify)
endif(WITH_LIBNOTIFY)
if(WITH_GSTREAMER)
pkg_check_modules(GSTREAMER gstreamer-0.10)
endif(WITH_GSTREAMER)
if(WITH_LIBXSS)
pkg_check_modules(LIBXSS xscrnsaver)
endif(WITH_LIBXSS)
if(WITH_NETWORKMANAGER)
pkg_check_modules(NETWORKMANAGER NetworkManager)
pkg_check_modules(DBUSGLIB dbus-glib-1)
endif(WITH_NETWORKMANAGER)
##########################################################################
message("==========================================")
if(WITH_LIBNOTIFY AND LIBNOTIFY_FOUND)
set(USE_LIBNOTIFY 1)
if(LIBNOTIFY_VERSION LESS 0.7)
set(LIBNOTIFY_OLD 1)
message(STATUS "Libnotify support: OLD" )
else(LIBNOTIFY_VERSION LESS 0.7)
message(STATUS "Libnotify support: NEW" )
endif(LIBNOTIFY_VERSION LESS 0.7)
else(WITH_LIBNOTIFY AND LIBNOTIFY_FOUND)
message(STATUS "Libnotify support: NO" )
endif(WITH_LIBNOTIFY AND LIBNOTIFY_FOUND)
if(WITH_GSTREAMER AND GSTREAMER_FOUND)
set(USE_GSTREAMER 1)
message(STATUS "GStreamer support: YES" )
else(WITH_GSTREAMER AND GSTREAMER_FOUND)
message(STATUS "GStreamer support: NO" )
endif(WITH_GSTREAMER AND GSTREAMER_FOUND)
if(WITH_LIBXSS AND LIBXSS_FOUND)
set(USE_LIBXSS 1)
message(STATUS "Xscreensaver support: YES" )
else(WITH_LIBXSS AND LIBXSS_FOUND)
message(STATUS "Xscreensaver support: NO" )
endif(WITH_LIBXSS AND LIBXSS_FOUND)
if(WITH_NETWORKMANAGER AND NETWORKMANAGER_FOUND AND DBUSGLIB_FOUND)
set(USE_NETWORKMANAGER 1)
message(STATUS "NetworkManager support: YES" )
else(WITH_NETWORKMANAGER AND NETWORKMANAGER_FOUND AND DBUSGLIB_FOUND)
message(STATUS "NetworkManager support: NO" )
endif(WITH_NETWORKMANAGER AND NETWORKMANAGER_FOUND AND DBUSGLIB_FOUND)
message("==========================================")
configure_file(config-ofetion.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
##########################################################################
add_definitions(-Wall -Wextra)
if(NOT DEFINED DISABLE_NLS AND GETTEXT_FOUND)
add_definitions(-DGETTEXT_PACKAGE="${PACKAGE_NAME}")
add_definitions(-DENABLE_NLS="1")
endif(NOT DEFINED DISABLE_NLS AND GETTEXT_FOUND)
add_definitions(-DSKIN_DIR="${DATA_INSTALL_DIR}/openfetion/skin/")
add_definitions(-DLOCALE_DIR="${