CMakeLists.txt
d1caf0b6
 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
23e43be6
 
e1c2e2f6
 IF(COMMAND cmake_policy)
 	# Don't do automatic escaping of variables
 	CMAKE_POLICY(SET CMP0005 OLD)
83968f90
 	CMAKE_POLICY(SET CMP0003 NEW)
e1c2e2f6
 ENDIF(COMMAND cmake_policy)
 
618ad404
 
7293634e
 # Add path for additional FindXXX.cmake scenarios
 set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
 
23e43be6
 PROJECT (SEMS)
 
 SET(SEMS_MAJOR_VERSION 1)
ca241c15
 SET(SEMS_MINOR_VERSION 6)
923c4dbe
 SET(SEMS_BUILD_VERSION 0)
23e43be6
 SET(SEMS_EXTRA_VERSION dev)
2f176184
 
55cf0a19
 IF(EXISTS ${CMAKE_SOURCE_DIR}/.git)
2f176184
 	SET(SEMS_VERSION
 	    "${SEMS_MAJOR_VERSION}.${SEMS_MINOR_VERSION}.${SEMS_BUILD_VERSION}-${SEMS_EXTRA_VERSION}")
55cf0a19
 ELSE(EXISTS ${CMAKE_SOURCE_DIR}/.git)
2f176184
 	SET(SEMS_VERSION
 	    "${SEMS_MAJOR_VERSION}.${SEMS_MINOR_VERSION}.${SEMS_BUILD_VERSION}")
55cf0a19
 ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/.git)
 
2f176184
 MESSAGE(STATUS "Configuring ${CMAKE_PROJECT_NAME} v. ${SEMS_VERSION}")
23e43be6
 
6aff5f86
 SET(SEMS_APP_NAME "sems")
 
f0f9a5ea
 IF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
 	message(FATAL_ERROR "In-source builds are not allowed.
 CMake would overwrite all makefiles distributed with SEMS.
 Please create a directory and run cmake from there, passing the path
 to this source directory as the last argument.
 This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
 Please delete them.")
 ENDIF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
 
23e43be6
 OPTION(SEMS_USE_SPANDSP       "Build with spandsp" OFF)
 OPTION(SEMS_USE_LIBSAMPLERATE "Build with libsamplerate" OFF)
 OPTION(SEMS_USE_ZRTP          "Build with ZRTP" OFF)
6b1b2d52
 OPTION(SEMS_USE_MP3           "Build with Lame MP3" OFF)
5312d88c
 OPTION(SEMS_USE_ILBC          "Build with iLBC library (fallback to bundled)" ON)
6b1b2d52
 OPTION(SEMS_USE_TTS           "Build with Text-to-speech support (requires Flite)" OFF)
 OPTION(SEMS_USE_OPENSSL       "Build with OpenSSL" OFF)
23e43be6
 OPTION(SEMS_USE_MONITORING    "Build with monitoring support" OFF)
6b1b2d52
 OPTION(SEMS_USE_IPV6          "Build with IPv6 support" OFF)
93d1f4b1
 OPTION(MAX_RTP_SESSIONS:int   "How many rtp sessions SEMS will handle simultaneously? (default 2048)" 2048)
23e43be6
 
08a5a3bf
 # Fix weird static libs handling in old CMake
 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STREQUAL "2.4")
 	SET(SEMS_WORKAROUND_FOR_OLD_CMAKE_2_4_FOR_STATIC_LIBS  ON)
 ELSE (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STREQUAL "2.4")
 	SET(SEMS_WORKAROUND_FOR_OLD_CMAKE_2_4_FOR_STATIC_LIBS  OFF)
 ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STREQUAL "2.4")
a7ee9ca6
 
 # add -lm and -lpthread to all targets
 SET(CMAKE_DL_LIBS ${CMAKE_DL_LIBS} m pthread)
95f6267f
 
 IF (NOT SEMS_CFG_PREFIX)
 	SET(SEMS_CFG_PREFIX "/usr/local")
 ENDIF (NOT SEMS_CFG_PREFIX)
a7ee9ca6
 MESSAGE(STATUS "SEMS cfg prefix was set to: ${SEMS_CFG_PREFIX}")
95f6267f
 
 IF (NOT SEMS_AUDIO_PREFIX)
a7ee9ca6
 	SET(SEMS_AUDIO_PREFIX "/usr/local/lib")
95f6267f
 ENDIF (NOT SEMS_AUDIO_PREFIX)
a7ee9ca6
 MESSAGE(STATUS "SEMS audio prefix was set to: ${SEMS_AUDIO_PREFIX}")
95f6267f
 
 IF (NOT SEMS_EXEC_PREFIX)
 	SET(SEMS_EXEC_PREFIX "/usr/local")
 ENDIF (NOT SEMS_EXEC_PREFIX)
a7ee9ca6
 MESSAGE(STATUS "SEMS exec prefix was set to: ${SEMS_EXEC_PREFIX}")
95f6267f
 
 IF (NOT SEMS_LIBDIR)
 	SET(SEMS_LIBDIR "lib")
 ENDIF (NOT SEMS_LIBDIR)
a7ee9ca6
 MESSAGE(STATUS "SEMS libdir was set to: ${SEMS_LIBDIR}")
95f6267f
 
d2b7aa71
 IF (NOT SEMS_DOC_PREFIX)
 	SET(SEMS_DOC_PREFIX "/usr/share/doc")
 ENDIF (NOT SEMS_DOC_PREFIX)
 MESSAGE(STATUS "SEMS doc prefix was set to: ${SEMS_DOC_PREFIX}")
 
6b1b2d52
 SET(CMAKE_VERBOSE_MAKEFILE ON)
 
dd1e5f69
 FIND_PACKAGE(Libevent2 REQUIRED)
 
6b1b2d52
 # compile with spandsp DTMF detection? see soft-switch.org
 #   this needs a fairly new version of spandsp - tested with 0.0.4pre11
 #   will not work with spandsp 0.0.2 .
 #   (which means that current debian and gentoo packages don't work)
23e43be6
 IF(SEMS_USE_SPANDSP)
7293634e
 	FIND_PACKAGE(Spandsp REQUIRED)
423329a2
 	ADD_DEFINITIONS(-DUSE_SPANDSP -D__STDC_LIMIT_MACROS)
7293634e
 	MESSAGE(STATUS "Using spandsp: YES")
6b1b2d52
 ELSE(SEMS_USE_SPANDSP)
 	MESSAGE(STATUS "Using spandsp: NO (default)")
23e43be6
 ENDIF(SEMS_USE_SPANDSP)
 
6b1b2d52
 # compile with sample rate conversion from secret rabbit code?
 # (see http://www.mega-nerd.com/SRC/)
23e43be6
 IF(SEMS_USE_LIBSAMPLERATE)
7293634e
 	FIND_PACKAGE(Libsamplerate REQUIRED)
423329a2
 	ADD_DEFINITIONS(-DUSE_LIBSAMPLERATE)
7293634e
 	MESSAGE(STATUS "Using libsamplerate: YES")
6b1b2d52
 ELSE(SEMS_USE_LIBSAMPLERATE)
 	MESSAGE(STATUS "Using libsamplerate: NO (default)")
23e43be6
 ENDIF(SEMS_USE_LIBSAMPLERATE)
 
6b1b2d52
 # ZRTP support? (see zfoneproject.com)
 IF(SEMS_USE_ZRTP)
23b4bae9
 	FIND_PACKAGE(Libzrtp REQUIRED)
6b1b2d52
 	MESSAGE(STATUS "Using libzrtp: YES")
7fe3137a
 	ADD_DEFINITIONS(-DWITH_ZRTP -DBUILD_ZRTP_MUTEXES -DBUILD_DEFAULT_CACHE -DBUILD_DEFAULT_TIMER -DUNIX -DBUILD_ZRTP_MUTEXES)
6b1b2d52
 ELSE(SEMS_USE_ZRTP)
 	MESSAGE(STATUS "Using libzrtp: NO (default)")
 ENDIF(SEMS_USE_ZRTP)
 
 # Lame MP3 support
1b0185b3
 IF(SEMS_USE_MP3)
7293634e
 	FIND_PACKAGE(Lame REQUIRED)
 	MESSAGE(STATUS "Using lame mp3: YES")
1b0185b3
 ELSE(SEMS_USE_MP3)
6b1b2d52
 	MESSAGE(STATUS "Using lame mp3: NO (default)")
1b0185b3
 ENDIF(SEMS_USE_MP3)
6b1b2d52
 
6631bfc2
 IF(SEMS_USE_ILBC)
5312d88c
 	FIND_PACKAGE(Ilbc)
 	IF(ILBC_FOUND)
 		MESSAGE(STATUS "Using iLBC library: YES (external)")
 	ELSE(ILBC_FOUND)
 		MESSAGE(STATUS "Using iLBC library: YES (bundled, default)")
 	ENDIF(ILBC_FOUND)
6631bfc2
 ELSE(SEMS_USE_ILBC)
5312d88c
 	MESSAGE(STATUS "Uusing iLBC library: NO")
6631bfc2
 ENDIF(SEMS_USE_ILBC)
 
6b1b2d52
 # build in support for monitoring?
23e43be6
 IF(SEMS_USE_MONITORING)
6b1b2d52
 	MESSAGE(STATUS "Enable monitoring: YES")
7fe3137a
 	ADD_DEFINITIONS(-DUSE_MONITORING)
6b1b2d52
 ELSE(SEMS_USE_MONITORING)
 	MESSAGE(STATUS "Enable monitoring: NO (default)")
23e43be6
 ENDIF(SEMS_USE_MONITORING)
 
6b1b2d52
 IF(SEMS_USE_IPV6)
423329a2
 	ADD_DEFINITIONS(-DSUPPORT_IPV6)
6b1b2d52
 	MESSAGE(STATUS "Enable IPv6 support: YES")
 ELSE(SEMS_USE_IPV6)
 	MESSAGE(STATUS "Enable IPv6 support: NO (default)")
 ENDIF(SEMS_USE_IPV6)
 
 # Let's try to find GSM library and header files
7293634e
 FIND_PACKAGE(Gsm)
 IF(GSM_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using gsm: YES")
7293634e
 ELSE(GSM_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using gsm: NO")
7293634e
 ENDIF(GSM_FOUND)
6b1b2d52
 
 # Let's try to find SPEEX library and header files
7293634e
 FIND_PACKAGE(Speex)
 IF(SPEEX_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using speex: YES")
7293634e
 ELSE(SPEEX_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using speex: NO")
7293634e
 ENDIF(SPEEX_FOUND)
6b1b2d52
 
 IF(SEMS_USE_OPENSSL)
 	FIND_PACKAGE(OpenSSL REQUIRED QUIETLY)
 	MESSAGE(STATUS "Found OpenSSL includes:	${OPENSSL_INCLUDE_DIR}/openssl/ssl.h")
 	MESSAGE(STATUS "Found OpenSSL library: ${OPENSSL_LIBRARIES}")
 	MESSAGE(STATUS "Using OpenSSL: YES")
 ELSE(SEMS_USE_OPENSSL)
 	MESSAGE(STATUS "Using OpenSSL: NO (default)")
 ENDIF(SEMS_USE_OPENSSL)
 
 # Let's try to find Python development files
 FIND_PACKAGE(PythonLibs)
a0f3d9f6
 IF(PYTHONLIBS_FOUND OR PYTHON_LIBRARIES)
 	SET(PYTHONLIBS_FOUND TRUE)
6b1b2d52
 	MESSAGE(STATUS "Found Python includes:	${PYTHON_INCLUDE_PATH}/Python.h")
 	MESSAGE(STATUS "Found Python library: ${PYTHON_LIBRARIES}")
 	MESSAGE(STATUS "Using Python: YES")
a0f3d9f6
 ELSE(PYTHONLIBS_FOUND OR PYTHON_LIBRARIES)
6b1b2d52
 	MESSAGE(STATUS "Using Python: NO")
a0f3d9f6
 ENDIF(PYTHONLIBS_FOUND OR PYTHON_LIBRARIES)
6b1b2d52
 
 # Let's try to find SIP (Python bindings generator) development files
2625d97c
 FIND_PACKAGE(SIP)
 IF(SIP_FOUND)
3f038c41
 	MESSAGE(STATUS "Using SIP: YES")
2625d97c
 ELSE(SIP_FOUND)
3f038c41
 	MESSAGE(STATUS "Using SIP: NO")
2625d97c
 ENDIF(SIP_FOUND)
6b1b2d52
 
 # Let's try to find MySQL++ development files
7293634e
 FIND_PACKAGE(MySQLpp)
 IF(MYSQLPP_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using MySQL++: YES")
7293634e
 ELSE(MYSQLPP_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using MySQL++: NO")
7293634e
 ENDIF(MYSQLPP_FOUND)
6b1b2d52
 
 # Let's try to find Flite library and header files
 IF(SEMS_USE_TTS)
7293634e
 	FIND_PACKAGE(Flite REQUIRED)
 	MESSAGE(STATUS "Using text-to-speech: YES")
6b1b2d52
 ELSE(SEMS_USE_TTS)
 	SET(FLITE_FOUND FALSE)
 	MESSAGE(STATUS "Using text-to-speech: NO (default)")
 ENDIF(SEMS_USE_TTS)
 
 # Let's try to find mISDN library and header files
7293634e
 FIND_PACKAGE(MISDN)
 IF(MISDN_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using mISDN: YES")
7293634e
 ELSE(MISDN_FOUND)
6b1b2d52
 	MESSAGE(STATUS "Using mISDN: NO")
7293634e
 ENDIF(MISDN_FOUND)
23e43be6
 
9c17cf43
 # Let's try to find libev development files
 FIND_PACKAGE(Libev)
 IF(LIBEV_FOUND)
 	MESSAGE(STATUS "Using libev: YES")
 ELSE(LIBEV_FOUND)
 	MESSAGE(STATUS "Using libev: NO")
 ENDIF(LIBEV_FOUND)
 
7064eb5c
 # Let's try to find librtmp development files
 FIND_PACKAGE(Librtmp)
 IF(RTMP_FOUND)
 	MESSAGE(STATUS "Using librtmp: YES")
 ELSE(RTMP_FOUND)
 	MESSAGE(STATUS "Using librtmp: NO")
 ENDIF(RTMP_FOUND)
9c17cf43
 
277ff2e1
 # Check for res_search in -lresolv
 include(${CMAKE_SOURCE_DIR}/cmake/CheckSymbolExists.cmake)
 SET(CMAKE_REQUIRED_LIBRARIES resolv)
 CHECK_SYMBOL_EXISTS(res_search resolv.h HAVE_RES_SEARCH)
 MESSAGE(STATUS "Have res_search: ${HAVE_RES_SEARCH} ")
 
23e43be6
 INCLUDE_DIRECTORIES (${SEMS_SOURCE_DIR}/core/ampi)
 INCLUDE_DIRECTORIES (${SEMS_SOURCE_DIR}/core/amci)
 INCLUDE_DIRECTORIES (${SEMS_SOURCE_DIR}/core)
 
423d3c3b
 CONFIGURE_FILE( ${SEMS_SOURCE_DIR}/core/sems.h.cmake ${SEMS_SOURCE_DIR}/core/sems.h )
23e43be6
 
 IF(CMAKE_COMPILER_IS_GNUCC)
01f7fb81
 	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_THREAD_SAFE -D_REENTRANT -Wall -fPIC -g -O2")
23e43be6
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 IF(CMAKE_COMPILER_IS_GNUCXX)
6b1b2d52
 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_THREAD_SAFE -D_REENTRANT -Wall -Wno-reorder -fPIC -g -O2")
23e43be6
 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
 
 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
 SET(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}   -D_DEBUG")
 
412b8d9d
 # compile with session thread pool support?
 #      use this for very high concurrent call count
 #      applications (e.g. for signaling only)
 #      if compiled with thread pool, there will be a
 #      thread pool of configurable size processing the
 #      signaling and application logic of the calls.
 #      if compiled without thread pool support, every
 #      session will have its own thread.
 #
 #ADD_DEFINITIONS(-DSESSION_THREADPOOL)
 
 #ADD_DEFINITIONS(-DNO_THREADID_LOG)
 #ADD_DEFINITIONS(-DLOG_LOC_DATA_ATEND)
 
 # Support for long debug messages? (useful for debugging SIP messages' contents)
 #
 # disable for slight performance gain
 ADD_DEFINITIONS(-DLOG_BUFFER_LEN=2048)
 
 #ADD_DEFINITIONS(-DDEBUG_PLAYOUTBUF)
 
1c4788fd
 SET(CMAKE_SHARED_LIBRARY_PREFIX "")
23e43be6
 
 ADD_SUBDIRECTORY (core)
6b1b2d52
 ADD_SUBDIRECTORY (apps)
f3e543cb
 ADD_SUBDIRECTORY (tools)
23e43be6
 
6b1b2d52
 #SET_DIRECTORY_PROPERTIES(ADDITIONAL_MAKE_CLEAN_FILES *~)