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
#
2023-08-09 08:59:38 +00:00
CMAKE_MINIMUM_REQUIRED ( VERSION 3.12 FATAL_ERROR )
2012-11-01 17:20:06 +00:00
INCLUDE ( cmake/Utils.cmake )
2013-02-10 20:12:41 +00:00
INCLUDE ( CheckIncludeFiles )
2013-09-06 21:10:54 +00:00
INCLUDE ( CheckIncludeFileCXX )
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-11-21 21:16:57 +00:00
INCLUDE ( CheckCXXSourceCompiles )
2017-06-19 20:08:45 +00:00
INCLUDE ( GNUInstallDirs )
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 )
# 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.
#
2017-01-03 20:00:08 +00:00
# See: http://semver.org/
2012-11-01 17:20:06 +00:00
#
# . Implementation changed (eg. bug/security fix): REVISION++
# . Interfaces added/removed/changed: CURRENT++, REVISION=0
# . Interfaces added (upward-compatible changes): AGE++
# . Interfaces removed: AGE=0
2017-01-03 20:00:08 +00:00
SET ( VMIME_API_VERSION_CURRENT 1 )
2012-11-01 17:20:06 +00:00
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
2020-02-14 22:02:58 +00:00
# Project
PROJECT (
v m i m e
L A N G U A G E S C X X C
V E R S I O N $ { V M I M E _ V E R S I O N }
)
2021-05-06 19:06:47 +00:00
# Install directories
IF ( IS_ABSOLUTE ${ CMAKE_INSTALL_LIBDIR } )
SET ( VMIME_INSTALL_LIBDIR ${ CMAKE_INSTALL_LIBDIR } )
ELSE ( )
SET ( VMIME_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
ENDIF ( )
MESSAGE ( "CMAKE_INSTALL_LIBDIR='${CMAKE_INSTALL_LIBDIR}" )
MESSAGE ( "VMIME_INSTALL_LIBDIR='${VMIME_INSTALL_LIBDIR}" )
IF ( IS_ABSOLUTE ${ CMAKE_INSTALL_BINDIR } )
SET ( VMIME_INSTALL_BINDIR ${ CMAKE_INSTALL_BINDIR } )
ELSE ( )
SET ( VMIME_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" )
ENDIF ( )
IF ( IS_ABSOLUTE ${ CMAKE_INSTALL_INCLUDEDIR } )
SET ( VMIME_INSTALL_INCLUDEDIR ${ CMAKE_INSTALL_INCLUDEDIR } )
ELSE ( )
SET ( VMIME_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" )
ENDIF ( )
2012-11-01 17:20:06 +00:00
# Set base name
SET ( VMIME_LIBRARY_NAME vmime )
2020-02-14 22:02:58 +00:00
SET ( VMIME_LIBRARY_VENDOR Kisli )
2012-11-01 17:20:06 +00:00
2018-04-01 09:29:07 +00:00
# Enable C++11
SET ( CMAKE_CXX_STANDARD 11 )
SET ( CMAKE_CXX_STANDARD_REQUIRED ON )
SET ( CMAKE_CXX_EXTENSIONS OFF )
2024-06-11 18:46:59 +00:00
##############################################################################
# Charset conversion library (1/2)
INCLUDE ( cmake/FindIconv.cmake )
INCLUDE ( cmake/FindICU.cmake )
FIND_PACKAGE ( ICU QUIET )
IF ( ICU_LIBRARIES )
SET ( VMIME_CHARSETCONV_LIB_DETECTED "icu" )
SET ( CMAKE_CXX_STANDARD 17 )
ELSEIF ( ICONV_FOUND )
SET ( VMIME_CHARSETCONV_LIB_DETECTED "iconv" )
ELSEIF ( WIN32 )
SET ( VMIME_CHARSETCONV_LIB_DETECTED "win" )
ENDIF ( )
2012-11-01 17:20:06 +00:00
# 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
2013-12-29 09:02:12 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / v m i m e / * . c p p
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 _ L I B R A R Y _ I N C L U D E _ F I L E S
2013-12-29 09:02:12 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / v m i m e / * . h p p
2012-11-01 17:20:06 +00:00
)
INCLUDE_DIRECTORIES (
2024-01-12 12:36:00 +00:00
$ { C M A K E _ S O U R C E _ D I R } # for "contrib/"
$ { C M A K E _ S O U R C E _ D I R } / s r c # for "vmime/
$ { C M A K E _ B I N A R Y _ D I R } / s r c # for "config.hpp" and other generated sources
2012-11-01 17:20:06 +00:00
)
2013-05-13 09:16:31 +00:00
INCLUDE ( GenerateExportHeader )
ADD_COMPILER_EXPORT_FLAGS ( )
2012-11-01 17:20:06 +00:00
# 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 }
)
2017-10-12 15:06:53 +00:00
TARGET_INCLUDE_DIRECTORIES ( ${ VMIME_LIBRARY_NAME } PUBLIC
2023-08-09 08:59:38 +00:00
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e >
2017-10-12 15:06:53 +00:00
)
2013-05-12 14:51:40 +00:00
GENERATE_EXPORT_HEADER (
$ { V M I M E _ L I B R A R Y _ N A M E }
B A S E _ N A M E V M I M E
2013-05-13 09:16:31 +00:00
S T A T I C _ D E F I N E V M I M E _ S T A T I C
2024-01-12 12:36:00 +00:00
E X P O R T _ F I L E _ N A M E $ { C M A K E _ B I N A R Y _ D I R } / s r c / v m i m e / e x p o r t - s h a r e d . h p p
2013-05-12 14:51:40 +00:00
)
2024-01-12 12:36:00 +00:00
LIST ( APPEND VMIME_LIBRARY_GENERATED_INCLUDE_FILES "${CMAKE_BINARY_DIR}/src/vmime/export-shared.hpp" )
2013-05-13 09:16:31 +00:00
2013-03-01 09:53:43 +00:00
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-05-13 09:16:31 +00:00
C O M P I L E _ F L A G S - D V M I M E _ S H A R E D
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 }
)
2023-08-09 08:59:38 +00:00
TARGET_INCLUDE_DIRECTORIES ( ${ VMIME_LIBRARY_NAME } -static PUBLIC
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e >
2017-10-12 15:06:53 +00:00
)
2013-05-13 09:16:31 +00:00
GENERATE_EXPORT_HEADER (
$ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c
B A S E _ N A M E V M I M E
S T A T I C _ D E F I N E V M I M E _ S T A T I C
2024-01-12 12:36:00 +00:00
E X P O R T _ F I L E _ N A M E $ { C M A K E _ B I N A R Y _ D I R } / s r c / v m i m e / e x p o r t - s t a t i c . h p p
2013-05-13 09:16:31 +00:00
)
2024-01-12 12:36:00 +00:00
LIST ( APPEND VMIME_LIBRARY_GENERATED_INCLUDE_FILES "${CMAKE_BINARY_DIR}/src/vmime/export-static.hpp" )
2013-05-13 09:16:31 +00:00
2013-03-01 09:53:43 +00:00
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 }
2013-05-13 09:16:31 +00:00
C O M P I L E _ F L A G S - D V M I M E _ S T A T I C
2013-03-01 09:53:43 +00:00
)
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
##############################################################################
# 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
2017-10-04 08:52:54 +00:00
$ { C M A K E _ C U R R E N T _ 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
)
2014-07-24 20:12:15 +00:00
ADD_LIBRARY (
t e s t - r u n n e r
2017-10-04 08:52:54 +00:00
$ { C M A K E _ C U R R E N T _ 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 _ C U R R E N T _ 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
2014-07-24 20:12:15 +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 )
2017-10-04 08:52:54 +00:00
STRING ( REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" VMIME_TEST_SRC_PATH "${VMIME_TEST_SRC_PATH}" )
2013-03-11 10:29:16 +00:00
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 }
2014-07-24 20:12:15 +00:00
$ { V M I M E _ T E S T _ S R C _ F I L E }
2013-03-11 10:29:16 +00:00
)
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 }
2014-07-24 20:12:15 +00:00
$ { C P P U N I T _ L I B R A R Y } t e s t - r u n n e r
2013-03-11 10:29:16 +00:00
)
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 "
2014-07-24 20:12:15 +00:00
$ { V M I M E _ T E S T S _ S R C _ F I L E S }
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 }
2014-07-24 20:12:15 +00:00
$ { C P P U N I T _ L I B R A R Y } t e s t - r u n n e r
2012-11-01 17:20:06 +00:00
)
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 ( )
2013-10-20 11:24:34 +00:00
##############################################################################
# Examples
OPTION (
V M I M E _ B U I L D _ S A M P L E S
" B u i l d samples ( in 'examples' directory ) "
2017-03-13 17:45:26 +00:00
O F F
2013-10-20 11:24:34 +00:00
)
2023-08-09 08:59:38 +00:00
IF ( VMIME_BUILD_SAMPLES )
ADD_SUBDIRECTORY ( examples )
ENDIF ( )
2013-10-20 11:24:34 +00:00
2012-11-01 17:20:06 +00:00
##############################################################################
# Packaging / Distribution
# Package information
SET ( VMIME_PACKAGE_NAME ${ VMIME_LIBRARY_NAME } )
2020-02-14 22:02:58 +00:00
SET ( VMIME_PACKAGE_VENDOR ${ VMIME_LIBRARY_VENDOR } )
2012-11-01 17:20:06 +00:00
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)" )
2020-02-14 22:02:58 +00:00
SET ( VMIME_PACKAGE_HOMEPAGE_URL "https://www.vmime.org" )
2012-11-01 17:20:06 +00:00
SET ( CPACK_PACKAGE_NAME "${VMIME_PACKAGE_NAME}" )
2020-02-14 22:02:58 +00:00
SET ( CPACK_PACKAGE_VENDOR "${VMIME_PACKAGE_VENDOR}" )
2012-11-01 17:20:06 +00:00
SET ( CPACK_PACKAGE_CONTACT "${VMIME_PACKAGE_CONTACT}" )
SET ( CPACK_PACKAGE_DESCRIPTION "${VMIME_PACKAGE_DESCRIPTION}" )
SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION}" )
2020-02-14 22:02:58 +00:00
SET ( CPACK_PACKAGE_HOMEPAGE_URL "${VMIME_PACKAGE_HOMEPAGE_URL}" )
2012-11-01 17:20:06 +00:00
SET ( CPACK_PACKAGE_VERSION "${VMIME_PACKAGE_VERSION}" )
# Package settings
IF ( APPLE )
# CPack/PackageManager won't allow file without recognized extension
# to be used as license file.
2017-10-04 08:52:54 +00:00
CONFIGURE_FILE ( "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" "${CMAKE_BINARY_DIR}/COPYING.txt" COPYONLY )
2012-11-01 17:20:06 +00:00
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/COPYING.txt" )
2020-02-14 22:02:58 +00:00
CONFIGURE_FILE ( "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_BINARY_DIR}/README.txt" COPYONLY )
SET ( CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.txt" )
2012-11-01 17:20:06 +00:00
ELSE ( )
2017-10-04 08:52:54 +00:00
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" )
2020-02-14 22:02:58 +00:00
SET ( CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README" )
2012-11-01 17:20:06 +00:00
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
2017-10-04 08:52:54 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
2012-11-01 17:20:06 +00:00
)
# PkgConfig
SET ( prefix ${ CMAKE_INSTALL_PREFIX } )
2021-05-06 19:06:47 +00:00
SET ( exec_prefix ${ VMIME_INSTALL_BINDIR } )
SET ( includedir ${ VMIME_INSTALL_INCLUDEDIR } /vmime )
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 )
2013-09-02 08:12:08 +00:00
CHECK_INCLUDE_FILE_CXX ( cstdint VMIME_HAVE_CSTDINT )
2013-07-15 08:35:09 +00:00
CHECK_TYPE_SIZE ( "char" SIZEOF_CHAR )
CHECK_TYPE_SIZE ( "short" SIZEOF_SHORT )
CHECK_TYPE_SIZE ( "int" SIZEOF_INT )
CHECK_TYPE_SIZE ( "long" SIZEOF_LONG )
CHECK_TYPE_SIZE ( "long long" SIZEOF_LONG_LONG )
CHECK_TYPE_SIZE ( "__int64" SIZEOF___INT64 )
2012-11-01 17:20:06 +00:00
2013-09-02 08:12:08 +00:00
SET ( CMAKE_EXTRA_INCLUDE_FILES cstdint )
CHECK_TYPE_SIZE ( "int64_t" SIZEOF_INT64_T )
SET ( CMAKE_EXTRA_INCLUDE_FILES )
2013-07-15 08:35:09 +00:00
IF ( SIZEOF_CHAR EQUAL 1 )
SET ( VMIME_8BIT_TYPE "char" )
ELSE ( )
MESSAGE ( FATAL_ERROR "Cannot determine 8-bit type" )
ENDIF ( )
2012-11-01 17:20:06 +00:00
2013-07-15 08:35:09 +00:00
IF ( SIZEOF_INT EQUAL 2 )
SET ( VMIME_16BIT_TYPE "int" )
ELSE ( )
IF ( SIZEOF_SHORT EQUAL 2 )
SET ( VMIME_16BIT_TYPE "short" )
ELSE ( )
MESSAGE ( FATAL_ERROR "Cannot determine 16-bit type" )
ENDIF ( )
ENDIF ( )
2012-11-01 17:20:06 +00:00
2013-07-15 08:35:09 +00:00
IF ( SIZEOF_INT EQUAL 4 )
SET ( VMIME_32BIT_TYPE "int" )
ELSE ( )
IF ( SIZEOF_LONG EQUAL 4 )
SET ( VMIME_32BIT_TYPE "long" )
ELSE ( )
IF ( SIZEOF_LONG_LONG EQUAL 4 )
SET ( VMIME_32BIT_TYPE "long long" )
ELSE ( )
MESSAGE ( FATAL_ERROR "Cannot determine 32-bit type" )
ENDIF ( )
ENDIF ( )
ENDIF ( )
IF ( SIZEOF_INT EQUAL 8 )
SET ( VMIME_64BIT_TYPE "int" )
ELSE ( )
IF ( SIZEOF_LONG EQUAL 8 )
SET ( VMIME_64BIT_TYPE "long" )
ELSE ( )
IF ( SIZEOF_LONG_LONG EQUAL 8 )
SET ( VMIME_64BIT_TYPE "long long" )
ELSE ( )
2013-09-02 08:12:08 +00:00
IF ( SIZEOF_INT64_T EQUAL 8 )
SET ( VMIME_64BIT_TYPE "int64_t" )
2013-07-15 08:35:09 +00:00
ELSE ( )
2013-09-02 08:12:08 +00:00
IF ( SIZEOF___INT64 EQUAL 8 )
SET ( VMIME_64BIT_TYPE "__int64" )
ELSE ( )
MESSAGE ( FATAL_ERROR "Cannot determine 64-bit type" )
ENDIF ( )
2013-07-15 08:35:09 +00:00
ENDIF ( )
ENDIF ( )
ENDIF ( )
ENDIF ( )
2012-11-01 17:20:06 +00:00
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
##############################################################################
# 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
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 )
2023-08-09 08:59:38 +00:00
INCLUDE ( cmake/FindGSasl.cmake )
2012-11-01 17:20:06 +00:00
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
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
)
2014-05-27 19:59:37 +00:00
IF ( VMIME_HAVE_TLS_SUPPORT )
2013-03-25 14:56:37 +00:00
2023-08-09 08:59:38 +00:00
SET (
V M I M E _ T L S _ S U P P O R T _ L I B
" g n u t l s "
C A C H E
S T R I N G
" L i b r a r y t o u s e f o r S S L / T L S c o n v e r s i o n "
)
SET_PROPERTY (
C A C H E
V M I M E _ T L S _ S U P P O R T _ L I B
P R O P E R T Y S T R I N G S g n u t l s o p e n s s l
)
2014-05-27 19:59:37 +00:00
IF ( VMIME_TLS_SUPPORT_LIB STREQUAL "gnutls" )
2012-11-01 17:20:06 +00:00
2023-08-09 08:59:38 +00:00
INCLUDE ( FindGnuTLS )
SET ( CMAKE_REQUIRED_LIBRARIES "${GNUTLS_LIBRARY}" )
CHECK_FUNCTION_EXISTS ( gnutls_priority_set_direct VMIME_HAVE_GNUTLS_PRIORITY_FUNCS )
2012-11-01 17:20:06 +00:00
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
2014-05-27 19:59:37 +00:00
SET ( VMIME_TLS_SUPPORT_LIB_IS_GNUTLS "ON" )
SET ( VMIME_TLS_SUPPORT_LIB_IS_OPENSSL "OFF" )
ELSEIF ( VMIME_TLS_SUPPORT_LIB STREQUAL "openssl" )
2012-11-03 08:27:12 +00:00
2023-08-09 08:59:38 +00:00
INCLUDE ( FindOpenSSL )
2012-11-03 08:27:12 +00:00
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
2014-05-27 19:59:37 +00:00
SET ( VMIME_TLS_SUPPORT_LIB_IS_GNUTLS "OFF" )
SET ( VMIME_TLS_SUPPORT_LIB_IS_OPENSSL "ON" )
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 )
##############################################################################
2024-06-11 18:46:59 +00:00
# Charset conversion library (2/2)
2013-03-25 11:32:48 +00:00
2014-05-27 19:59:37 +00:00
SET (
V M I M E _ C H A R S E T C O N V _ L I B
" $ { V M I M E _ C H A R S E T C O N V _ L I B _ D E T E C T E D } "
C A C H E
S T R I N G
" L i b r a r y t o u s e f o r c h a r s e t c o n v e r s i o n "
2013-03-25 11:32:48 +00:00
)
2014-05-27 19:59:37 +00:00
SET_PROPERTY (
C A C H E
V M I M E _ C H A R S E T C O N V _ L I B
P R O P E R T Y S T R I N G S w i n i c o n v i c u
2014-02-06 20:29:59 +00:00
)
2013-03-25 14:56:37 +00:00
2014-05-27 19:59:37 +00:00
IF ( VMIME_CHARSETCONV_LIB STREQUAL "iconv" )
2013-03-25 11:32:48 +00:00
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
)
2012-11-01 17:20:06 +00:00
2013-03-25 11:32:48 +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 ( )
2023-12-31 14:54:48 +00:00
IF ( VMIME_BUILD_STATIC_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c
$ { 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 ( )
2013-03-25 11:32:48 +00:00
SET ( VMIME_PKGCONFIG_LIBS "${VMIME_PKGCONFIG_LIBS} ${ICONV_LIBRARIES}" )
SET ( VMIME_PKGCONFIG_CFLAGS "${VMIME_PKGCONFIG_CFLAGS} -I${ICONV_INCLUDE_DIR}" )
2014-05-27 19:59:37 +00:00
SET ( VMIME_CHARSETCONV_LIB_IS_ICONV "ON" )
SET ( VMIME_CHARSETCONV_LIB_IS_ICU "OFF" )
SET ( VMIME_CHARSETCONV_LIB_IS_WIN "OFF" )
ELSEIF ( VMIME_CHARSETCONV_LIB STREQUAL "icu" )
2013-03-25 11:32:48 +00:00
INCLUDE_DIRECTORIES (
$ { I N C L U D E _ D I R E C T O R I E S }
$ { I C U _ I N C L U D E _ D I R S }
)
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 U _ L I B R A R I E S }
)
ENDIF ( )
2023-12-31 14:54:48 +00:00
IF ( VMIME_BUILD_STATIC_LIBRARY )
TARGET_LINK_LIBRARIES (
$ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c
$ { T A R G E T _ L I N K _ L I B R A R I E S }
$ { I C U _ L I B R A R I E S }
)
ENDIF ( )
2013-03-25 11:32:48 +00:00
SET ( VMIME_PKGCONFIG_LIBS "${VMIME_PKGCONFIG_LIBS} ${ICU_LIBRARIES}" )
SET ( VMIME_PKGCONFIG_CFLAGS "${VMIME_PKGCONFIG_CFLAGS} -I${ICU_INCLUDE_DIRS}" )
2014-05-27 19:59:37 +00:00
SET ( VMIME_CHARSETCONV_LIB_IS_ICONV "OFF" )
SET ( VMIME_CHARSETCONV_LIB_IS_ICU "ON" )
SET ( VMIME_CHARSETCONV_LIB_IS_WIN "OFF" )
ELSEIF ( VMIME_CHARSETCONV_LIB STREQUAL "win" )
2014-02-06 20:29:59 +00:00
2015-02-16 17:43:03 +00:00
MESSAGE ( WARNING "*** ICU or iconv library should always be preferred"
" o v e r M u l t i B y t e T o W i d e C h a r / W i d e C h a r T o M u l t i B y t e o n W i n d o w s , a s "
" e r r o r h a n d l i n g i s v e r y p o o r , a n d t h e r e i s n o s t r e a m i n g s u p p o r t . " )
2014-05-27 19:59:37 +00:00
SET ( VMIME_CHARSETCONV_LIB_IS_ICONV "OFF" )
SET ( VMIME_CHARSETCONV_LIB_IS_ICU "OFF" )
SET ( VMIME_CHARSETCONV_LIB_IS_WIN "ON" )
2014-02-06 20:29:59 +00:00
2013-03-25 11:32:48 +00:00
ELSE ( )
MESSAGE ( FATAL_ERROR "No charset conversion library was selected/found" )
ENDIF ( )
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
2024-12-01 01:32:41 +00:00
# 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)
# IF(VMIME_BUILD_SHARED_LIBRARY)
# TARGET_LINK_LIBRARIES(
# ${VMIME_LIBRARY_NAME}
# ${TARGET_LINK_LIBRARIES}
# "mlang"
# )
# ENDIF()
# ENDIF()
# ENDIF()
2013-02-10 20:12:41 +00:00
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 )
2017-08-09 18:39:54 +00:00
CHECK_SYMBOL_EXISTS ( getthrid unistd.h VMIME_HAVE_GETTHRID )
2023-12-31 14:22:36 +00:00
CHECK_SYMBOL_EXISTS ( thr_self sys/thr.h VMIME_HAVE_THR_SELF )
2023-11-09 19:32:47 +00:00
CHECK_SYMBOL_EXISTS ( _lwp_self sys/lwp.h VMIME_HAVE_LWP_SELF )
2012-11-03 08:27:12 +00:00
2016-02-28 19:43:43 +00:00
CHECK_SYMBOL_EXISTS ( SO_KEEPALIVE sys/socket.h VMIME_HAVE_SO_KEEPALIVE )
2016-04-25 06:28:34 +00:00
CHECK_SYMBOL_EXISTS ( SO_NOSIGPIPE sys/socket.h VMIME_HAVE_SO_NOSIGPIPE )
CHECK_SYMBOL_EXISTS ( MSG_NOSIGNAL sys/socket.h VMIME_HAVE_MSG_NOSIGNAL )
2016-02-28 19:43:43 +00:00
2016-03-25 20:50:35 +00:00
CHECK_SYMBOL_EXISTS ( strerror_r string.h VMIME_HAVE_STRERROR_R )
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
2016-03-02 19:33:55 +00:00
# getaddrinfo_a() - GNU libc
LIST ( APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES anl )
CHECK_SYMBOL_EXISTS ( getaddrinfo_a netdb.h VMIME_HAVE_GETADDRINFO_A )
IF ( VMIME_HAVE_GETADDRINFO_A )
2016-04-10 17:16:44 +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 }
a n l
)
ENDIF ( )
2016-03-02 19:33:55 +00:00
ENDIF ( )
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
2018-04-24 18:31:26 +00:00
" - 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 M A K E _ C X X _ F L A G S } "
2012-11-01 17:20:06 +00:00
)
2018-04-24 18:31:26 +00:00
SET ( CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}" )
SET ( CMAKE_CXX_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}" )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
2012-11-01 17:20:06 +00:00
#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
2018-04-24 18:31:26 +00:00
" - 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 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 - W n o - l o n g - l o n g $ { C M A K E _ C X X _ F L A G S } "
2012-11-01 17:20:06 +00:00
)
2018-04-24 18:31:26 +00:00
SET ( CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}" )
SET ( CMAKE_CXX_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}" )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
2012-11-01 17:20:06 +00:00
#SET(CMAKE_EXE_LINKER_FLAGS "-s")
ENDIF ( )
ENDIF ( )
##############################################################################
# Documentation
2013-11-21 21:16:57 +00:00
OPTION (
V M I M E _ B U I L D _ D O C U M E N T A T I O N
" B u i l d d o c u m e n t a t i o n "
O N
)
2012-11-01 17:20:06 +00:00
2013-11-21 21:16:57 +00:00
IF ( VMIME_BUILD_DOCUMENTATION )
FIND_PACKAGE ( Doxygen )
2012-11-01 17:20:06 +00:00
2013-11-21 21:16:57 +00:00
IF ( DOXYGEN_FOUND )
2017-10-04 08:52:54 +00:00
CONFIGURE_FILE ( ${ CMAKE_CURRENT_SOURCE_DIR } /Doxyfile.in ${ CMAKE_BINARY_DIR } /Doxyfile @ONLY )
2012-11-01 17:20:06 +00:00
2013-11-21 21:16:57 +00:00
# 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 )
ENDIF ( VMIME_BUILD_DOCUMENTATION )
2012-11-01 17:20:06 +00:00
##############################################################################
# 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 ( )
2015-01-01 11:54:21 +00:00
# Sendmail protocol is available only if file-system features are enabled
IF ( VMIME_HAVE_MESSAGING_FEATURES AND VMIME_HAVE_MESSAGING_PROTO_SENDMAIL AND NOT VMIME_HAVE_FILESYSTEM_FEATURES )
MESSAGE ( FATAL_ERROR "Sendmail protocol requires file-system support (VMIME_HAVE_FILESYSTEM_FEATURES must be set to ON)." )
ENDIF ( )
2012-11-01 17:20:06 +00:00
# Path to 'sendmail' must be specified if Sendmail protocol is enabled
IF ( VMIME_HAVE_MESSAGING_PROTO_SENDMAIL )
2023-08-09 08:59:38 +00:00
# Sendmail path
# only configure this if we are enabling sendmail
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 "
)
2012-11-01 17:20:06 +00:00
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 ( )
2014-01-21 19:23:51 +00:00
2012-11-01 17:20:06 +00:00
# Set our configure file
2024-01-12 12:36:00 +00:00
CONFIGURE_FILE ( cmake/config.hpp.cmake ${ CMAKE_BINARY_DIR } /src/vmime/config.hpp )
LIST ( APPEND VMIME_LIBRARY_GENERATED_INCLUDE_FILES ${ CMAKE_BINARY_DIR } /src/vmime/config.hpp )
2012-11-01 17:20:06 +00:00
2013-03-01 11:25:20 +00:00
# PkgConfig post-configuration
2017-10-04 08:52:54 +00:00
CONFIGURE_FILE ( ${ CMAKE_CURRENT_SOURCE_DIR } /vmime.pc.in ${ CMAKE_BINARY_DIR } /vmime.pc @ONLY )
2013-03-01 11:25:20 +00:00
2012-11-01 17:20:06 +00:00
INCLUDE ( CPack )
2023-08-09 08:59:38 +00:00
# Installation of libraries
OPTION (
V M I M E _ I N S T A L L
" S h o u l d t h e v m i m e l i b r a r y b e i n s t a l l e d "
O N
)
IF ( VMIME_INSTALL )
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 }
E X P O R T $ { V M I M E _ L I B R A R Y _ N A M E } - c o n f i g
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 } "
P U B L I C _ H E A D E R D E S T I N A T I O N " $ { V M I M E _ I N S T A L L _ I N C L U D E D I R } "
C O M P O N E N T s h a r e d l i b s
)
INSTALL (
E X P O R T $ { V M I M E _ L I B R A R Y _ N A M E } - c o n f i g
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 m a k e / v m i m e "
)
ENDIF ( )
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
E X P O R T $ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c - c o n f i g
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 } "
P U B L I C _ H E A D E R D E S T I N A T I O N " $ { V M I M E _ I N S T A L L _ I N C L U D E D I R } "
C O M P O N E N T s t a t i c l i b s
)
INSTALL (
E X P O R T $ { V M I M E _ L I B R A R Y _ N A M E } - s t a t i c - c o n f i g
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 m a k e / v m i m e "
)
ENDIF ( )
# Installation of header files
INSTALL_HEADERS_WITH_DIRECTORY ( VMIME_LIBRARY_INCLUDE_FILES headers "${CMAKE_CURRENT_SOURCE_DIR}/src/" )
INSTALL_HEADERS_WITH_DIRECTORY ( VMIME_LIBRARY_GENERATED_INCLUDE_FILES headers "${CMAKE_BINARY_DIR}/src" )
INSTALL ( FILES ${ CMAKE_BINARY_DIR } /vmime.pc DESTINATION "${VMIME_INSTALL_LIBDIR}/pkgconfig" COMPONENT headers )
2021-05-06 19:06:47 +00:00
2023-08-09 08:59:38 +00:00
MESSAGE ( "" )
MESSAGE ( "VMime will install to the following directories:" )
MESSAGE ( " libraries: ${VMIME_INSTALL_LIBDIR}" )
MESSAGE ( " headers: ${VMIME_INSTALL_INCLUDEDIR}" )
MESSAGE ( "" )
ENDIF ( VMIME_INSTALL )