Merge branch 'daemon-ext'
[libi2ncommon] / CMakeLists.txt
index cf7e34f..a1751bc 100644 (file)
@@ -2,9 +2,7 @@
 project(libi2ncommon)
 
 # Version settings
-set(MAJOR_VERSION 2)
-set(MINOR_VERSION 0)
-set(VERSION 2.0)
+set(VERSION 2.11)
 
 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
 
@@ -21,6 +19,9 @@ if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
    add_definitions(-DDEBUG)
 endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
 
+# Enable all warnings
+add_definitions("-Wall")
+
 # Set components
 set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers)
 set(CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries")
@@ -34,6 +35,15 @@ set(CPACK_COMPONENT_HEADERS_DESCRIPTION
 set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development")
 set(CPACK_COMPONENT_HEADERS_GROUP    "Development")
 
+# Create suffix to eventually install in lib64
+IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    SET(LIB_SUFFIX "")
+    SET(PACK_ARCH "")
+  ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    SET(LIB_SUFFIX 64)
+    SET(PACK_ARCH .x86_64)
+endif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+
 # Package information
 set(CPACK_PACKAGE_VERSION              ${VERSION})
 set(CPACK_PACKAGE_CONTACT              "Intra2net AG <libi2ncommon@developer.intra2net.com>")
@@ -46,7 +56,8 @@ set(CPACK_CMAKE_GENERATOR              "Unix Makefiles")
 set(CPACK_PACKAGE_NAME                 ${PROJECT_NAME})
 set(CPACK_PACKAGE_FILE_NAME            ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PACK_ARCH})
 
-set(CPACK_RESOURCE_FILE_LICENSE        ${CMAKE_SOURCE_DIR}/COPYING.GPL)
+set(CPACK_RESOURCE_FILE_LICENSE        ${CMAKE_SOURCE_DIR}/Linking-Exception.txt)
+set(CPACK_RESOURCE_FILE_README         ${CMAKE_SOURCE_DIR}/COPYING.GPL)
 
 set(CPACK_SOURCE_GENERATOR             TGZ)
 set(CPACK_SOURCE_IGNORE_FILES
@@ -57,9 +68,17 @@ set(CPACK_SOURCE_IGNORE_FILES
 )
 set(CPACK_SOURCE_PACKAGE_FILE_NAME     ${CPACK_PACKAGE_FILE_NAME})
 
+# "make dist" target
+set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${VERSION})
+add_custom_target(dist
+    COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
+            | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
 # documentation
+option(DOCUMENTATION "Generate API documentation with Doxygen" ON)
 find_package(Doxygen)
-if(DOXYGEN_FOUND)
+if(DOCUMENTATION AND DOXYGEN_FOUND)
    # Set variables
    set(PACKAGE libi2ncommon)
    set(top_srcdir ${CMAKE_SOURCE_DIR})
@@ -91,9 +110,9 @@ if(DOXYGEN_FOUND)
    add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
 
    message(STATUS "Generating API documentation with Doxygen")
-else(DOXYGEN_FOUND)
+else(DOCUMENTATION AND DOXYGEN_FOUND)
    message(STATUS "Not generating API documentation")
-endif(DOXYGEN_FOUND)
+endif(DOCUMENTATION AND DOXYGEN_FOUND)
 
 # Conditional build itmes
 option(BUILD_XMLLIB "Build xml part of libi2ncommon - needs patched libxml++" OFF)
@@ -103,11 +122,23 @@ else(BUILD_XMLLIB)
    message(STATUS "NOT building xml library part")
 endif(BUILD_XMLLIB)
 
+option(IMAP_UTF7_SUPPORT "Enable imap modified utf7 support - needs patched libiconv" OFF)
+if (IMAP_UTF7_SUPPORT)
+   message(STATUS "Build imap modified utf7 support")
+else(IMAP_UTF7_SUPPORT)
+   message(STATUS "NOT building imap modified utf7 support")
+endif(IMAP_UTF7_SUPPORT)
+
 # Find external packages
 include(FindPkgConfig)
 
 # Find Boost
-find_package(Boost COMPONENTS iostreams unit_test_framework REQUIRED)
+find_package(Boost 1.44 COMPONENTS iostreams unit_test_framework thread REQUIRED)
+
+# Find pcrecpp
+pkg_check_modules(PCRECPP REQUIRED libpcrecpp)
+INCLUDE_DIRECTORIES(${PCRECPP_INCLUDE_DIRS})
+LINK_DIRECTORIES(${PCRECPP_LIBRARY_DIRS})
 
 # Find libxml++
 if (BUILD_XMLLIB)
@@ -115,20 +146,33 @@ if (BUILD_XMLLIB)
 endif(BUILD_XMLLIB)
 
 # Find iconv
-pkg_check_modules(ICONV REQUIRED libiconv)
-include_directories($ICONV_INCLUDE_DIRS})
-link_directories(${ICONV_LIBRARY_DIRS})
+if (IMAP_UTF7_SUPPORT)
+    pkg_check_modules(ICONV REQUIRED libiconv)
+    include_directories($ICONV_INCLUDE_DIRS})
+    link_directories(${ICONV_LIBRARY_DIRS})
+endif(IMAP_UTF7_SUPPORT)
 
+# Detect openssl - for base64 routines
+pkg_check_modules(OPENSSL REQUIRED openssl)
+INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIRS})
+LINK_DIRECTORIES(${OPENSSL_LIBRARY_DIRS})
 
 # pkgconfig output
 set(prefix      ${CMAKE_INSTALL_PREFIX})
 set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
-set(includedir  ${CMAKE_INSTALL_PREFIX}/include)
-set(libdir      ${CMAKE_INSTALL_PREFIX}/lib)
+set(includedir  ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
+set(libdir      ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
 
 # construct ${BOOST_LDADD} from ${Boost_LIBRARIES}
-string(REGEX REPLACE ";" " -l" BOOST_LDADD "${Boost_IOSTREAMS_LIBRARIES}")
-set(BOOST_LDADD "-l${BOOST_LDADD}")
+# forming "-L/some/path -lboost_a -L/other/path -lboost_b" from
+# "/some/path/libboost_a.so.3.5;/other/path/libboost_b.so"
+set(BOOST_LDADD "")
+FOREACH(boost_lib_full ${Boost_IOSTREAMS_LIBRARIES})
+    get_filename_component(boost_lib_path ${boost_lib_full} PATH)
+    get_filename_component(boost_lib_file ${boost_lib_full} NAME_WE)
+    string(REGEX REPLACE "^lib(boost.+)$" "\\1" boost_lib_name ${boost_lib_file})
+    set(BOOST_LDADD "${BOOST_LDADD} -L${boost_lib_path} -l${boost_lib_name}")
+ENDFOREACH()
 
 # construct ${BOOST_CFLAGS} from ${Boost_INCLUDE_DIRS}
 string(REGEX REPLACE ";" " -I" BOOST_CFLAGS "${Boost_INCLUDE_DIRS}")
@@ -145,11 +189,11 @@ configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon_utils.pc.in ${CMAKE_BINARY_DIR}/
 install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon.pc
                      ${CMAKE_BINARY_DIR}/libi2ncommon_config.pc
                      ${CMAKE_BINARY_DIR}/libi2ncommon_utils.pc
-        DESTINATION lib/pkgconfig)
+        DESTINATION lib${LIB_SUFFIX}/pkgconfig)
 
 if (BUILD_XMLLIB)
     configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon_xml.pc.in ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc @ONLY)
-    install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc DESTINATION lib/pkgconfig)
+    install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
 endif(BUILD_XMLLIB)