2012-11-01 17:20:06 +00:00
#
# CMake configuration file for VMime
#
# Usage:
#
# . 'cmake -LH' to list build settings variable
#
# . 'cmake -G <generator>' to generate makefiles for a build system
# eg. cmake -G "Unix Makefiles"
#
# For more information, please visit:
# http://www.cmake.org
#
CMAKE_MINIMUM_REQUIRED ( VERSION 2.6 FATAL_ERROR )
INCLUDE ( cmake/Utils.cmake )
2013-02-10 20:12:41 +00:00
INCLUDE ( CheckIncludeFiles )
2013-02-05 13:21:21 +00:00
INCLUDE ( CheckFunctionExists )
INCLUDE ( CheckSymbolExists )
INCLUDE ( CheckTypeSize )
2013-02-08 13:24:20 +00:00
INCLUDE ( CheckLibraryExists )
2013-02-05 13:21:21 +00:00
2012-11-01 17:20:06 +00:00
# CMake configuration
SET ( CMAKE_RUNTIME_OUTPUT_DIRECTORY build/bin )
SET ( CMAKE_LIBRARY_OUTPUT_DIRECTORY build/lib )
2013-03-06 21:06:15 +00:00
SET ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY build/lib )
2012-11-01 17:20:06 +00:00
SET ( CMAKE_VERBOSE_MAKEFILE ON )
# Project
PROJECT ( vmime )
# Package version number
SET ( VMIME_VERSION_MAJOR 0 )
SET ( VMIME_VERSION_MINOR 9 )
SET ( VMIME_VERSION_MICRO 2 )
# API version number (libtool)
#
# Increment this number only immediately before a public release.
# This is independent from package version number.
#
# See: http://www.gnu.org/software/libtool/manual.html#Libtool-versioning
#
# . Implementation changed (eg. bug/security fix): REVISION++
# . Interfaces added/removed/changed: CURRENT++, REVISION=0
# . Interfaces added (upward-compatible changes): AGE++
# . Interfaces removed: AGE=0
SET ( VMIME_API_VERSION_CURRENT 0 )
SET ( VMIME_API_VERSION_REVISION 0 )
SET ( VMIME_API_VERSION_AGE 0 )
SET ( VMIME_VERSION ${ VMIME_VERSION_MAJOR } . ${ VMIME_VERSION_MINOR } . ${ VMIME_VERSION_MICRO } )
SET ( VMIME_API_VERSION ${ VMIME_API_VERSION_CURRENT } . ${ VMIME_API_VERSION_REVISION } . ${ VMIME_API_VERSION_AGE } )
##############################################################################
# VMime Library
# Set base name
SET ( VMIME_LIBRARY_NAME vmime )
# Source files
FILE (
G L O B _ R E C U R S E
V M I M E _ L I B R A R Y _ S R C _ F I L E S
s r c / *
)
FILE (
G L O B _ R E C U R S E
V M I M E _ L I B R A R Y _ I N C L U D E _ F I L E S
v m i m e / *
)
2013-03-04 08:42:45 +00:00
LIST ( APPEND VMIME_LIBRARY_INCLUDE_FILES "vmime/config.hpp" )
2012-11-01 17:20:06 +00:00
INCLUDE_DIRECTORIES (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
)
# Shared library
2013-03-01 09:53:43 +00:00
OPTION (
V M I M E _ B U I L D _ S H A R E D _ L I B R A R Y
" B u i l d s h a r e d l i b r a r y "
O N
2012-11-01 17:20:06 +00:00
)
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
ADD_LIBRARY (
$ { V M I M E _ L I B R A R Y _ N A M E }
S H A R E D
$ { V M I M E _ L I B R A R Y _ S R C _ F I L E S }
$ { V M I M E _ L I B R A R Y _ I N C L U D E _ F I L E S }
)
SET_TARGET_PROPERTIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
P R O P E R T I E S
2013-03-24 07:27:24 +00:00
V E R S I O N " $ { V M I M E _ A P I _ V E R S I O N } "
S O V E R S I O N " $ { V M I M E _ A P I _ V E R S I O N _ C U R R E N T } "
2013-03-01 09:53:43 +00:00
)
ENDIF ( )
2012-11-01 17:20:06 +00:00
# Static library
#
# Note: cannot have two targets with the same name so the static version has
# '-static' appended and then the name of the output file is set separately.
2013-03-01 09:53:43 +00:00
OPTION (
V M I M E _ B U I L D _ S T A T I C _ L I B R A R Y
" B u i l d s t a t i c l i b r a r y "
O N
2012-11-01 17:20:06 +00:00
)
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_STATIC_LIBRARY )
ADD_LIBRARY (
$ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c
S T A T I C
$ { V M I M E _ L I B R A R Y _ S R C _ F I L E S }
$ { V M I M E _ L I B R A R Y _ I N C L U D E _ F I L E S }
)
SET_TARGET_PROPERTIES (
$ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c
P R O P E R T I E S
O U T P U T _ N A M E $ { V M I M E _ L I B R A R Y _ N A M E }
)
ENDIF ( )
# Ensure at least one type of library (either shared or static) is build
IF ( NOT(VMIME_BUILD_SHARED_LIBRARY OR VMIME_BUILD_STATIC_LIBRARY ) )
MESSAGE ( FATAL_ERROR "You should select at least one library to build (either VMIME_BUILD_SHARED_LIBRARY or VMIME_BUILD_STATIC_LIBRARY must be set to YES." )
ENDIF ( )
2012-11-01 17:20:06 +00:00
# These next two lines are required but it is unclear exactly what they do.
# The CMake FAQ mentions they are necessary and it does not work otherwise.
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
SET_TARGET_PROPERTIES ( ${ VMIME_LIBRARY_NAME } PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
ENDIF ( )
IF ( VMIME_BUILD_STATIC_LIBRARY )
SET_TARGET_PROPERTIES ( ${ VMIME_LIBRARY_NAME } -static PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
ENDIF ( )
2012-11-01 17:20:06 +00:00
SET ( CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries" )
2013-03-20 11:44:05 +00:00
# Automatically set lib suffix
IF ( UNIX AND NOT APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/debian_version" )
IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT LIB_SUFFIX )
# ...only if LIB_SUFFIX is not defined...
IF ( NOT DEFINED LIB_SUFFIX )
# ...and if CMAKE_INSTALL_LIBDIR does not already contain the suffix
IF ( NOT "${CMAKE_INSTALL_LIBDIR}" MATCHES ".*64.*" )
SET ( LIB_SUFFIX 64 )
ENDIF ( )
ENDIF ( )
ENDIF ( )
ENDIF ( )
# Determine library installation dir, in this order:
# 1) use VMIME_INSTALL_LIBDIR if set
# 2) use LIB_INSTALL_DIR if defined
# 3) use CMAKE_INSTALL_LIBDIR if set
# if it is a relative path, prepend CMAKE_INSTALL_PREFIX to it
# 4) use CMAKE_INSTALL_PREFIX/lib
IF ( NOT DEFINED VMIME_INSTALL_LIBDIR )
IF ( DEFINED LIB_INSTALL_DIR )
SET ( VMIME_INSTALL_LIBDIR ${ LIB_INSTALL_DIR } )
# respect CMAKE_INSTALL_LIBDIR if set
ELSEIF ( DEFINED CMAKE_INSTALL_LIBDIR )
SET ( VMIME_INSTALL_LIBDIR ${ CMAKE_INSTALL_LIBDIR } )
IF ( IS_ABSOLUTE ${ VMIME_INSTALL_LIBDIR } )
SET ( VMIME_INSTALL_LIBDIR ${ CMAKE_INSTALL_LIBDIR } ${ LIB_SUFFIX } )
ELSE ( )
SET ( VMIME_INSTALL_LIBDIR ${ CMAKE_INSTALL_PREFIX } / ${ CMAKE_INSTALL_LIBDIR } ${ LIB_SUFFIX } )
ENDIF ( )
ELSE ( )
SET ( VMIME_INSTALL_LIBDIR ${ CMAKE_INSTALL_PREFIX } /lib ${ LIB_SUFFIX } )
ENDIF ( )
ENDIF ( )
2012-11-01 17:20:06 +00:00
# Installation of libraries
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
INSTALL (
T A R G E T S $ { V M I M E _ L I B R A R Y _ N A M E }
2013-03-20 11:44:05 +00:00
L I B R A R Y D E S T I N A T I O N " $ { V M I M E _ I N S T A L L _ L I B D I R } " C O M P O N E N T s h a r e d l i b s
A R C H I V E D E S T I N A T I O N " $ { V M I M E _ I N S T A L L _ L I B D I R } " C O M P O N E N T s h a r e d l i b s
2013-03-01 09:53:43 +00:00
)
ENDIF ( )
2012-11-01 17:20:06 +00:00
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_STATIC_LIBRARY )
INSTALL (
T A R G E T S $ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c
2013-03-20 11:44:05 +00:00
L I B R A R Y D E S T I N A T I O N " $ { V M I M E _ I N S T A L L _ L I B D I R } " C O M P O N E N T s t a t i c l i b s
A R C H I V E D E S T I N A T I O N " $ { V M I M E _ I N S T A L L _ L I B D I R } " C O M P O N E N T s t a t i c l i b s
2013-03-01 09:53:43 +00:00
)
ENDIF ( )
2012-11-01 17:20:06 +00:00
# Installation of header files
INSTALL_HEADERS_WITH_DIRECTORY ( VMIME_LIBRARY_INCLUDE_FILES headers )
#INSTALL(
# FILES ${VMIME_LIBRARY_INCLUDE_FILES}
# DESTINATION include
# COMPONENT headers
#)
##############################################################################
# Tests
OPTION (
V M I M E _ B U I L D _ T E S T S
" B u i l d u n i t tests ( this will create a 'run-tests' binary ) "
O F F
)
IF ( VMIME_BUILD_TESTS )
2013-03-11 10:29:16 +00:00
ENABLE_TESTING ( )
INCLUDE ( cmake/FindCppUnit.cmake )
INCLUDE_DIRECTORIES ( ${ CPPUNIT_INCLUDE_DIR } )
2012-11-01 17:20:06 +00:00
FILE (
G L O B _ R E C U R S E
V M I M E _ T E S T S _ S R C _ F I L E S
2013-03-11 10:29:16 +00:00
$ { C M A K E _ S O U R C E _ D I R } / t e s t s / * T e s t . c p p
2012-11-01 17:20:06 +00:00
)
2013-03-11 10:29:16 +00:00
# Build one file for each test
FOREACH ( VMIME_TEST_SRC_FILE ${ VMIME_TESTS_SRC_FILES } )
# "/path/to/vmime/tests/module/testFile.cpp" --> "module_testFile"
GET_FILENAME_COMPONENT ( VMIME_TEST_SRC_PATH "${VMIME_TEST_SRC_FILE}" PATH )
STRING ( REPLACE "${CMAKE_SOURCE_DIR}" "" VMIME_TEST_SRC_PATH "${VMIME_TEST_SRC_PATH}" )
GET_FILENAME_COMPONENT ( VMIME_TEST_NAME "${VMIME_TEST_SRC_FILE}" NAME_WE )
SET ( VMIME_TEST_NAME "${VMIME_TEST_SRC_PATH}/${VMIME_TEST_NAME}" )
STRING ( REPLACE "/" "_" VMIME_TEST_NAME "${VMIME_TEST_NAME}" )
STRING ( REPLACE "_tests_" "" VMIME_TEST_NAME "${VMIME_TEST_NAME}" )
ADD_EXECUTABLE (
$ { V M I M E _ T E S T _ N A M E }
$ { V M I M E _ T E S T _ S R C _ F I L E } $ { C M A K E _ S O U R C E _ D I R } / t e s t s / t e s t R u n n e r . c p p $ { C M A K E _ S O U R C E _ D I R } / t e s t s / t e s t U t i l s . c p p
)
TARGET_LINK_LIBRARIES (
$ { V M I M E _ T E S T _ N A M E }
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { C P P U N I T _ L I B R A R Y }
)
ADD_DEPENDENCIES (
$ { V M I M E _ T E S T _ N A M E }
$ { V M I M E _ L I B R A R Y _ N A M E }
)
ADD_TEST (
$ { V M I M E _ T E S T _ N A M E }
$ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / $ { V M I M E _ T E S T _ N A M E }
)
ENDFOREACH ( )
# Build one file for all tests
2012-11-01 17:20:06 +00:00
ADD_EXECUTABLE (
" r u n - t e s t s "
2013-03-11 10:29:16 +00:00
$ { V M I M E _ T E S T S _ S R C _ F I L E S } $ { C M A K E _ S O U R C E _ D I R } / t e s t s / t e s t R u n n e r . c p p $ { C M A K E _ S O U R C E _ D I R } / t e s t s / t e s t U t i l s . c p p
2012-11-01 17:20:06 +00:00
)
TARGET_LINK_LIBRARIES (
" r u n - t e s t s "
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { C P P U N I T _ L I B R A R Y }
)
ADD_DEPENDENCIES (
" r u n - t e s t s "
$ { V M I M E _ L I B R A R Y _ N A M E }
)
ENDIF ( )
##############################################################################
# Packaging / Distribution
# Package information
SET ( VMIME_PACKAGE_NAME ${ VMIME_LIBRARY_NAME } )
SET ( VMIME_PACKAGE_VERSION ${ VMIME_VERSION } )
SET ( VMIME_PACKAGE_CONTACT "Vincent Richard <vincent@vmime.org>" )
SET ( VMIME_PACKAGE_DESCRIPTION "VMime C++ Mail Library (http://www.vmime.org)" )
SET ( CPACK_PACKAGE_NAME "${VMIME_PACKAGE_NAME}" )
SET ( CPACK_PACKAGE_CONTACT "${VMIME_PACKAGE_CONTACT}" )
SET ( CPACK_PACKAGE_DESCRIPTION "${VMIME_PACKAGE_DESCRIPTION}" )
SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION}" )
SET ( CPACK_PACKAGE_VERSION "${VMIME_PACKAGE_VERSION}" )
# Package settings
SET ( CPACK_RESOURCE_FILE_LICENSE ${ CMAKE_SOURCE_DIR } /COPYING )
IF ( APPLE )
# CPack/PackageManager won't allow file without recognized extension
# to be used as license file.
CONFIGURE_FILE ( "${CMAKE_SOURCE_DIR}/COPYING" "${CMAKE_BINARY_DIR}/COPYING.txt" COPYONLY )
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/COPYING.txt" )
ELSE ( )
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING" )
ENDIF ( APPLE )
SET ( CPACK_SOURCE_GENERATOR TGZ )
SET ( CPACK_SOURCE_IGNORE_FILES "\\\\.git;~$;build/" )
SET ( CPACK_SOURCE_PACKAGE_FILE_NAME ${ CPACK_PACKAGE_NAME } - ${ CPACK_PACKAGE_VERSION } )
# Set components
SET ( CPACK_COMPONENTS_ALL sharedlibs staticlibs headers )
SET ( CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries" )
SET ( CPACK_COMPONENT_SHAREDLIBS_DESCRIPTION
" S h a r e d l i b r a r y f o r g e n e r a l u s e . " )
SET ( CPACK_COMPONENT_STATICLIBS_DISPLAY_NAME "Static libraries" )
SET ( CPACK_COMPONENT_STATICLIBS_DESCRIPTION
" S t a t i c l i b r a r y , g o o d i f y o u w a n t t o e m b e d V M i m e i n y o u r a p p l i c a t i o n . " )
SET ( CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers" )
SET ( CPACK_COMPONENT_HEADERS_DESCRIPTION
" C / C + + h e a d e r f i l e s . " )
SET ( CPACK_COMPONENT_SHAREDLIBS_GROUP "Development" )
SET ( CPACK_COMPONENT_STATICLIBS_GROUP "Development" )
SET ( CPACK_COMPONENT_HEADERS_GROUP "Development" )
SET ( CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "" )
# Make a target "dist" to generate tarball
SET ( ARCHIVE_NAME ${ CPACK_PACKAGE_NAME } - ${ CPACK_PACKAGE_VERSION } )
ADD_CUSTOM_TARGET (
d i s t
C O M M A N D g i t a r c h i v e - - p r e f i x = $ { A R C H I V E _ N A M E } / H E A D
| b z i p 2 > $ { C M A K E _ B I N A R Y _ D I R } / $ { A R C H I V E _ N A M E } . t a r . b z 2
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
)
# PkgConfig
SET ( prefix ${ CMAKE_INSTALL_PREFIX } )
SET ( exec_prefix ${ CMAKE_INSTALL_PREFIX } /bin )
SET ( includedir ${ CMAKE_INSTALL_PREFIX } /include/vmime )
2013-03-20 11:44:05 +00:00
SET ( libdir ${ VMIME_INSTALL_LIBDIR } )
2012-11-01 17:20:06 +00:00
SET ( VMIME_PKGCONFIG_LIBS "" )
SET ( VMIME_PKGCONFIG_CFLAGS "" )
SET ( VMIME_PKGCONFIG_REQUIRES "" )
##############################################################################
# Build type
IF ( NOT CMAKE_BUILD_TYPE )
SET (
C M A K E _ B U I L D _ T Y P E
" D e b u g "
C A C H E S T R I N G
" C h o o s e t h e t y p e o f b u i l d , o p t i o n s a r e : N o n e D e b u g R e l e a s e R e l W i t h D e b I n f o M i n S i z e R e l . "
F O R C E
)
ENDIF ( NOT CMAKE_BUILD_TYPE )
# Set a default build type for single-configuration
# CMake generators if no build type is set.
IF ( NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE Debug )
ENDIF ( )
# Debug build
MESSAGE ( "-- Build type: ${CMAKE_BUILD_TYPE}" )
IF ( ${ CMAKE_BUILD_TYPE } STREQUAL Debug )
ADD_DEFINITIONS ( -DDEBUG )
ENDIF ( ${ CMAKE_BUILD_TYPE } STREQUAL Debug )
IF ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
SET ( VMIME_DEBUG 1 )
ELSE ( )
SET ( VMIME_DEBUG 0 )
ENDIF ( )
##############################################################################
# Test endianness and basic type sizes
INCLUDE ( TestBigEndian )
TEST_BIG_ENDIAN ( BIGENDIAN )
IF ( BIGENDIAN EQUAL 0 )
set ( VMIME_BYTE_ORDER_BIG_ENDIAN 0 )
set ( VMIME_BYTE_ORDER_LITTLE_ENDIAN 1 )
ELSE ( BIGENDIAN EQUAL 0 )
SET ( VMIME_BYTE_ORDER_BIG_ENDIAN 1 )
SET ( VMIME_BYTE_ORDER_LITTLE_ENDIAN 0 )
ENDIF ( BIGENDIAN EQUAL 0 )
SET ( VMIME_DEFAULT_8BIT_TYPE "char" )
SET ( VMIME_DEFAULT_16BIT_TYPE "short" )
SET ( VMIME_DEFAULT_32BIT_TYPE "int" )
SET (
V M I M E _ 8 B I T _ T Y P E
$ { V M I M E _ D E F A U L T _ 8 B I T _ T Y P E }
C A C H E S T R I N G
" T h e C - l a n g u a g e 8 - b i t t y p e f o r y o u r p l a t f o r m "
)
SET (
V M I M E _ 1 6 B I T _ T Y P E
$ { V M I M E _ D E F A U L T _ 1 6 B I T _ T Y P E }
C A C H E S T R I N G
" T h e C - l a n g u a g e 1 6 - b i t t y p e f o r y o u r p l a t f o r m "
)
SET (
V M I M E _ 3 2 B I T _ T Y P E
$ { V M I M E _ D E F A U L T _ 3 2 B I T _ T Y P E }
C A C H E S T R I N G
" T h e C - l a n g u a g e 3 2 - b i t t y p e f o r y o u r p l a t f o r m "
)
INCLUDE ( cmake/TargetArch.cmake )
TARGET_ARCHITECTURE ( CMAKE_TARGET_ARCHITECTURES )
2012-12-12 15:35:55 +00:00
CHECK_TYPE_SIZE ( size_t VMIME_HAVE_SIZE_T )
2012-11-01 17:20:06 +00:00
##############################################################################
# Sendmail path
FOREACH ( SENDMAIL_PATH /usr/sbin/sendmail /usr/lib/sendmail /usr/bin/sendmail /bin/sendmail /var/qmail/bin/qmail-inject /bin/cgimail )
IF ( EXISTS ${ SENDMAIL_PATH } )
MESSAGE ( STATUS "Sendmail binary found at ${SENDMAIL_PATH}" )
SET ( VMIME_DEFAULT_SENDMAIL_PATH ${ SENDMAIL_PATH } )
ENDIF ( )
ENDFOREACH ( SENDMAIL_PATH )
SET (
V M I M E _ S E N D M A I L _ P A T H
$ { V M I M E _ D E F A U L T _ S E N D M A I L _ P A T H }
C A C H E
S T R I N G
" S p e c i f i e s t h e p a t h t o s e n d m a i l b i n a r y "
)
##############################################################################
# Messaging features
# Module
OPTION (
V M I M E _ H A V E _ M E S S A G I N G _ F E A T U R E S
" E n a b l e m e s s a g i n g features ( connection to IMAP, POP3, SMTP... ) "
O N
)
# Protocols
OPTION (
V M I M E _ H A V E _ M E S S A G I N G _ P R O T O _ P O P 3
" E n a b l e P O P 3 p r o t o c o l "
O N
)
OPTION (
V M I M E _ H A V E _ M E S S A G I N G _ P R O T O _ S M T P
" E n a b l e S M T P p r o t o c o l "
O N
)
OPTION (
V M I M E _ H A V E _ M E S S A G I N G _ P R O T O _ I M A P
" E n a b l e I M A P p r o t o c o l "
O N
)
OPTION (
V M I M E _ H A V E _ M E S S A G I N G _ P R O T O _ M A I L D I R
" E n a b l e M a i l d i r p r o t o c o l "
O N
)
OPTION (
V M I M E _ H A V E _ M E S S A G I N G _ P R O T O _ S E N D M A I L
" E n a b l e S e n d m a i l p r o t o c o l "
O N
)
##############################################################################
# File-system features
OPTION (
V M I M E _ H A V E _ F I L E S Y S T E M _ F E A T U R E S
" E n a b l e f i l e - s y s t e m features ( required for file attachments and Maildir ) "
O N
)
##############################################################################
# SASL support
INCLUDE ( cmake/FindGSasl.cmake )
OPTION (
V M I M E _ H A V E _ S A S L _ S U P P O R T
" E n a b l e S A S L support ( requires GNU SASL library ) "
O N
)
IF ( VMIME_HAVE_SASL_SUPPORT )
INCLUDE_DIRECTORIES (
$ { I N C L U D E _ D I R E C T O R I E S }
$ { G S A S L _ I N C L U D E _ D I R }
)
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { G S A S L _ L I B R A R I E S }
)
ENDIF ( )
2012-11-01 17:20:06 +00:00
SET ( VMIME_PKGCONFIG_REQUIRES "${VMIME_PKGCONFIG_REQUIRES} libgsasl" )
ENDIF ( )
##############################################################################
# SSL/TLS support
INCLUDE ( FindGnuTLS )
2012-11-03 08:27:12 +00:00
INCLUDE ( FindOpenSSL )
2012-11-01 17:20:06 +00:00
SET ( CMAKE_REQUIRED_LIBRARIES "${GNUTLS_LIBRARY}" )
CHECK_FUNCTION_EXISTS ( gnutls_priority_set_direct VMIME_HAVE_GNUTLS_PRIORITY_FUNCS )
OPTION (
V M I M E _ H A V E _ T L S _ S U P P O R T
2012-11-03 08:27:12 +00:00
" S S L / T L S support ( requires either GNU TLS or OpenSSL library ) "
2012-11-01 17:20:06 +00:00
O N
)
OPTION (
V M I M E _ T L S _ S U P P O R T _ L I B _ I S _ G N U T L S
" U s e G N U T L S l i b r a r y f o r S S L / T L S s u p p o r t "
O N
)
2012-11-03 08:27:12 +00:00
OPTION (
V M I M E _ T L S _ S U P P O R T _ L I B _ I S _ O P E N S S L
" U s e O p e n S S L l i b r a r y f o r S S L / T L S s u p p o r t "
O F F
)
2012-11-01 17:20:06 +00:00
IF ( VMIME_HAVE_TLS_SUPPORT )
IF ( VMIME_TLS_SUPPORT_LIB_IS_GNUTLS )
INCLUDE_DIRECTORIES (
$ { I N C L U D E _ D I R E C T O R I E S }
$ { G N U T L S _ I N C L U D E _ D I R }
)
LINK_DIRECTORIES (
$ { L I N K _ D I R E C T O R I E S }
$ { G N U T L S _ L I B R A R Y _ D I R S }
)
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { G N U T L S _ L I B R A R Y }
)
ENDIF ( )
2012-11-01 17:20:06 +00:00
2013-03-01 11:25:20 +00:00
SET ( VMIME_PKGCONFIG_REQUIRES "${VMIME_PKGCONFIG_REQUIRES} gnutls" )
2012-11-01 17:20:06 +00:00
2012-11-03 08:27:12 +00:00
ELSEIF ( VMIME_TLS_SUPPORT_LIB_IS_OPENSSL )
INCLUDE_DIRECTORIES (
$ { I N C L U D E _ D I R E C T O R I E S }
$ { O P E N S S L _ I N C L U D E _ D I R }
)
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { O P E N S S L _ L I B R A R I E S }
)
ENDIF ( )
2012-11-03 08:27:12 +00:00
2013-03-01 11:25:20 +00:00
SET ( VMIME_PKGCONFIG_REQUIRES "${VMIME_PKGCONFIG_REQUIRES} openssl" )
2012-11-03 08:27:12 +00:00
2012-11-01 17:20:06 +00:00
ELSE ( )
MESSAGE ( FATAL_ERROR "TLS support is enabled, but no TLS/SSL library was selected/found" )
ENDIF ( )
ENDIF ( VMIME_HAVE_TLS_SUPPORT )
##############################################################################
# iconv
INCLUDE ( cmake/FindIconv.cmake )
INCLUDE_DIRECTORIES (
$ { I N C L U D E _ D I R E C T O R I E S }
$ { I C O N V _ I N C L U D E _ D I R }
)
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { I C O N V _ L I B R A R I E S }
)
ENDIF ( )
2012-11-01 17:20:06 +00:00
2013-03-01 11:25:20 +00:00
SET ( VMIME_PKGCONFIG_LIBS "${VMIME_PKGCONFIG_LIBS} ${ICONV_LIBRARIES}" )
2013-03-01 12:16:25 +00:00
SET ( VMIME_PKGCONFIG_CFLAGS "${VMIME_PKGCONFIG_CFLAGS} -I${ICONV_INCLUDE_DIR}" )
2013-03-01 11:25:20 +00:00
2012-11-01 17:20:06 +00:00
##############################################################################
# Platform
SET ( VMIME_PLATFORM_IS_POSIX OFF )
SET ( VMIME_PLATFORM_IS_WINDOWS OFF )
IF ( WIN32 )
SET ( VMIME_PLATFORM_IS_WINDOWS ON )
ELSE ( )
SET ( VMIME_PLATFORM_IS_POSIX ON )
ENDIF ( )
##############################################################################
2013-02-05 13:21:21 +00:00
# Platform-specific checks
2012-11-01 17:20:06 +00:00
2013-02-05 13:21:21 +00:00
CHECK_FUNCTION_EXISTS ( gmtime_s VMIME_HAVE_GMTIME_S )
CHECK_FUNCTION_EXISTS ( gmtime_r VMIME_HAVE_GMTIME_R )
CHECK_FUNCTION_EXISTS ( localtime_s VMIME_HAVE_LOCALTIME_S )
CHECK_FUNCTION_EXISTS ( localtime_r VMIME_HAVE_LOCALTIME_R )
2013-02-28 08:16:40 +00:00
CHECK_FUNCTION_EXISTS ( strcpy_s VMIME_HAVE_STRCPY_S )
2013-02-05 13:21:21 +00:00
2013-02-08 13:24:20 +00:00
##############################################################################
# Windows-specific checks
IF ( WIN32 )
# Winsock
CHECK_LIBRARY_EXISTS ( "ws2_32" getch "${CMAKE_LIBRARY_PATH}" VMIME_HAVE_LIBWS2_32 )
IF ( VMIME_HAVE_LIBWS2_32 )
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
" w s 2 _ 3 2 "
)
2013-03-06 23:26:12 +00:00
ELSE ( )
SET ( VMIME_PKGCONFIG_LIBS "${VMIME_PKGCONFIG_LIBS} -lws2_32" )
2013-03-01 09:53:43 +00:00
ENDIF ( )
2013-02-08 13:24:20 +00:00
ENDIF ( )
2013-02-10 20:12:41 +00:00
# MLang
CHECK_INCLUDE_FILES ( Mlang.h VMIME_HAVE_MLANG_H )
CHECK_LIBRARY_EXISTS ( "mlang" ConvertINetString "${CMAKE_LIBRARY_PATH}" VMIME_HAVE_MLANG_LIB )
IF ( VMIME_HAVE_MLANG_H )
IF ( VMIME_HAVE_MLANG_LIB )
SET ( VMIME_HAVE_MLANG ON )
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
" m l a n g "
)
ENDIF ( )
2013-02-10 20:12:41 +00:00
ENDIF ( )
ENDIF ( )
2013-02-08 13:24:20 +00:00
ENDIF ( )
2013-02-05 13:21:21 +00:00
##############################################################################
# POSIX-specific checks
2012-11-03 08:27:12 +00:00
2012-11-01 17:20:06 +00:00
CHECK_FUNCTION_EXISTS ( getaddrinfo VMIME_HAVE_GETADDRINFO )
2012-12-10 21:59:19 +00:00
CHECK_FUNCTION_EXISTS ( getnameinfo VMIME_HAVE_GETNAMEINFO )
2012-11-01 17:20:06 +00:00
2012-11-03 08:27:12 +00:00
CHECK_FUNCTION_EXISTS ( gettid VMIME_HAVE_GETTID )
CHECK_FUNCTION_EXISTS ( syscall VMIME_HAVE_SYSCALL )
CHECK_SYMBOL_EXISTS ( SYS_gettid sys/syscall.h VMIME_HAVE_SYSCALL_GETTID )
2012-11-01 17:20:06 +00:00
FIND_PACKAGE ( Threads )
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { C M A K E _ T H R E A D _ L I B S _ I N I T }
)
ENDIF ( )
2013-02-05 14:15:37 +00:00
FIND_LIBRARY ( PTHREAD_LIB pthread )
IF ( PTHREAD_LIB )
2012-11-01 17:20:06 +00:00
SET ( VMIME_HAVE_PTHREAD 1 )
2013-03-01 09:53:43 +00:00
IF ( VMIME_BUILD_SHARED_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E }
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { P T H R E A D _ L I B }
)
ENDIF ( )
2013-02-05 14:15:37 +00:00
ELSE ( PTHREAD_LIB )
2012-11-01 17:20:06 +00:00
SET ( VMIME_HAVE_PTHREAD 0 )
2013-02-05 14:15:37 +00:00
ENDIF ( PTHREAD_LIB )
2012-11-01 17:20:06 +00:00
##############################################################################
# Additional compiler flags
IF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
SET (
C M A K E _ C X X _ F L A G S
" $ { C M A K E _ C X X _ F L A G S } - D _ R E E N T R A N T = 1 - W - W a l l - p e d a n t i c - W a r r a y - b o u n d s - p o i n t e r - a r i t h m e t i c - W o l d - s t y l e - c a s t - W c o n v e r s i o n - W c a s t - a l i g n - W n o - s i g n - c o n v e r s i o n "
C A C H E S T R I N G
" g + + C o m p i l e r F l a g s "
F O R C E
)
SET ( CMAKE_CXX_FLAGS_RELEASE "-O2" )
SET ( CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" )
#SET(CMAKE_EXE_LINKER_FLAGS "-s")
ELSE ( )
IF ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
SET (
C M A K E _ C X X _ F L A G S
" $ { C M A K E _ C X X _ F L A G S } - D _ R E E N T R A N T = 1 - W - W a l l - a n s i - p e d a n t i c - W p o i n t e r - a r i t h - W o l d - s t y l e - c a s t - W c o n v e r s i o n - W c a s t - a l i g n "
C A C H E S T R I N G
" g + + C o m p i l e r F l a g s "
F O R C E
)
SET ( CMAKE_CXX_FLAGS_RELEASE "-O2" )
SET ( CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" )
#SET(CMAKE_EXE_LINKER_FLAGS "-s")
ENDIF ( )
ENDIF ( )
##############################################################################
# Documentation
FIND_PACKAGE ( Doxygen )
IF ( DOXYGEN_FOUND )
CONFIGURE_FILE ( ${ CMAKE_SOURCE_DIR } /Doxyfile.in ${ CMAKE_BINARY_DIR } /Doxyfile @ONLY )
# Make a target so that documentation can be generated by running "make doc"
ADD_CUSTOM_TARGET (
d o c
$ { D O X Y G E N _ E X E C U T A B L E } $ { C M A K E _ B I N A R Y _ D I R } / D o x y f i l e
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R }
C O M M E N T " G e n e r a t i n g A P I d o c u m e n t a t i o n w i t h D o x y g e n " V E R B A T I M
)
ENDIF ( DOXYGEN_FOUND )
##############################################################################
# Sanity checks
# Maildir protocol is available only if file-system features are enabled
IF ( VMIME_HAVE_MESSAGING_FEATURES AND VMIME_HAVE_MESSAGING_PROTO_MAILDIR AND NOT VMIME_HAVE_FILESYSTEM_FEATURES )
MESSAGE ( FATAL_ERROR "Maildir protocol requires file-system support (VMIME_HAVE_FILESYSTEM_FEATURES must be set to ON)." )
ENDIF ( )
# Path to 'sendmail' must be specified if Sendmail protocol is enabled
IF ( VMIME_HAVE_MESSAGING_PROTO_SENDMAIL )
IF ( NOT VMIME_SENDMAIL_PATH OR VMIME_SENDMAIL_PATH STREQUAL "" )
MESSAGE ( FATAL_ERROR "Enabling Sendmail protocol requires that you specify path to 'sendmail' binary." )
ENDIF ( )
ENDIF ( )
# Set our configure file
2013-03-06 21:06:15 +00:00
CONFIGURE_FILE ( cmake/config.hpp.cmake ${ CMAKE_SOURCE_DIR } /vmime/config.hpp )
2012-11-01 17:20:06 +00:00
2013-03-01 11:25:20 +00:00
# PkgConfig post-configuration
CONFIGURE_FILE ( ${ CMAKE_SOURCE_DIR } /libvmime.pc.in ${ CMAKE_BINARY_DIR } /libvmime.pc @ONLY )
2013-03-20 11:44:05 +00:00
INSTALL ( FILES ${ CMAKE_BINARY_DIR } /libvmime.pc DESTINATION "${VMIME_INSTALL_LIBDIR}/pkgconfig" COMPONENT headers )
2013-03-01 11:25:20 +00:00
2012-11-01 17:20:06 +00:00
INCLUDE ( CPack )