blob: c5de159bf268e852fe16103fd3b29eaa01112133 [file] [log] [blame]
Alexandre Lisionddd731e2014-01-31 11:50:08 -05001## Copyright (C) 1999-2005 Open Source Telecom Corporation.
2## Copyright (C) 2006-2008 David Sugar, Tycho Softworks.
3## Copyright (C) 2009-2011 Werner Dittmann
4##
5## This file is free software; as a special exception the author gives
6## unlimited permission to copy and/or distribute it, with or without
7## modifications, as long as this notice is preserved.
8##
9## This program is distributed in the hope that it will be useful, but
10## WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12#
13
14cmake_minimum_required(VERSION 2.6)
15
16PROJECT(libccrtp)
Alexandre Lision81ecad62014-04-04 14:11:58 -040017set (VERSION 2.0.8)
Alexandre Lisione41ecd42014-02-27 15:51:10 -050018set (SOVERSION ${VERSION})
19STRING(REGEX REPLACE "[.].*$" "" SOVERSION ${SOVERSION})
20set (REQUIRES 5.0.0)
21set (PACKAGE ccrtp)
Alexandre Lisionddd731e2014-01-31 11:50:08 -050022
23# for debug and trace during CMakeList development
24set(CMAKE_VERBOSE_MAKEFILE FALSE)
25
26SET(CPACK_PACKAGE_VERSION_MAJOR 2)
27SET(CPACK_PACKAGE_VERSION_MINOR 0)
Alexandre Lisione41ecd42014-02-27 15:51:10 -050028SET(CPACK_PACKAGE_VERSION_PATCH 7)
Alexandre Lisionddd731e2014-01-31 11:50:08 -050029
30# set some global variables, in particular version variables
Alexandre Lisionddd731e2014-01-31 11:50:08 -050031
32# Set library postfix in case of 64 bit architecture
33# this caused problems in debian where it has to always be lib....
34set(LIB64 "")
35if (NOT EXISTS /etc/debian_version)
36 if ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" )
37 set(LIB64 "64")
38 endif()
39endif()
40
41include(cmake/Modules/AutoArgs.cmake)
42enable_arg(srtp true)
43
44if(MSVC60)
45 set(BUILD_STATIC ON CACHE BOOL "static linking only" FORCE)
46 MARK_AS_ADVANCED(BUILD_STATIC)
47else()
48 option(BUILD_STATIC "Set to OFF to build shared libraries" OFF)
49endif()
50
51MESSAGE( STATUS "Configuring GNU ${PROJECT_NAME} ${VERSION}...")
52
53# include all the fine stuff we need
54include(cmake/Modules/FindGcryptConfig.cmake)
55include(FindPkgConfig)
56include(CheckLibraryExists)
57include(CheckIncludeFiles)
58
59if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
60 include(cmake/Modules/GeneratePackage.cmake)
61
62 GENERATE_PACKAGING(${PACKAGE} ${VERSION})
63endif()
64
65# setup the Thread include and lib
66find_package(Threads)
67if (CMAKE_HAVE_PTHREAD_H)
68 set(HAVE_PTHREAD_H TRUE)
69endif()
70set (LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
71
72if (USES_UCOMMON_INCLUDE_DIRS)
73 message(STATUS " Using local commoncpp dependency")
74else()
75 find_package(PkgConfig)
76 pkg_check_modules(USES_UCOMMON commoncpp>=${REQUIRES})
77endif()
78
79include_directories(${USES_UCOMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src/ccrtp)
80link_directories(${USES_UCOMMON_LIBRARY_DIRS})
81add_definitions(${USES_UCOMMON_CFLAGS})
82set (LIBS ${LIBS} ${USES_UCOMMON_LDFLAGS} commoncpp ${USES_UCOMMON_LIBRARIES})
83
84if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT MINGW)
85 check_include_files(openssl/ssl.h HAVE_OPENSSL_WINDOWS)
86else()
87 pkg_check_modules(OPENSSL libssl>=0.9.8)
88endif()
89
90if (enable_srtp)
91 # now get info about crypto libraries
92 gcr_check(GCRYPT gcrypt)
93 if (GCRYPT_FOUND AND NOT OPENSSL_FOUND)
94 set(SRTP_SUPPORT TRUE)
95 check_include_files(gcrypt.h HAVE_GCRYPT_H)
96 set(LIBS ${LIBS} ${GCRYPT_LIBRARIES})
97 else ()
98 set(GCRYPT_FOUND FALSE)
99 if (OPENSSL_FOUND OR HAVE_OPENSSL_WINDOWS)
100 set(SRTP_SUPPORT TRUE)
101 check_include_files(openssl/bn.h HAVE_OPENSSL_BN_H)
102 check_include_files(openssl/aes.h HAVE_OPENSSL_AES_H)
103 check_include_files(openssl/sha.h HAVE_OPENSSL_SHA_H)
104 check_library_exists(crypto EVP_CipherInit_ex "" HAVE_SSL_CRYPT)
105 if(HAVE_OPENSSL_WINDOWS)
106 set(LIBS ${LIBS} libeay32)
107 else()
108 set(LIBS ${LIBS} -lcrypto)
109 endif()
110 else()
111 message(WARNING "No crypto library found")
112 endif()
113 endif()
114endif()
115
116# the following set(...) commands are only to have backward
117# compatibility with autoconf stuff to generate the pc file
118set(prefix ${CMAKE_INSTALL_PREFIX})
119set(exec_prefix ${prefix}/bin)
120set(libdir ${prefix}/lib${LIB64})
121set(includedir ${prefix}/include)
122set(PACKAGE pkgconfig)
123
124configure_file(libccrtp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libccrtp.pc @ONLY)
125configure_file(ccrtp.spec.cmake ${CMAKE_CURRENT_BINARY_DIR}/ccrtp.spec @ONLY)
126
127if(CMAKE_COMPILER_IS_GNUCXX)
128 add_definitions(-g -O2 -fno-strict-aliasing)
129 add_definitions(-Wno-long-long -Wno-char-subscripts)
130 add_definitions(-Wall -ansi -pedantic)
131endif()
132
133# now prepare and go for the sub-directories
134include_directories(${CMAKE_CURRENT_BINARY_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/ccrtp)
135
136configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ccrtp-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/ccrtp-config.h)
137include_directories("${CMAKE_CURRENT_BINARY_DIR}")
138
139add_subdirectory(src)
140
141add_subdirectory(demo)
142
143add_subdirectory(doc)
144
145########### install files ###############
146install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libccrtp.pc DESTINATION lib${LIB64}/pkgconfig)
147
148if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
149
150 ########### Add uninstall target ###############
151 configure_file(
152 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
153 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
154 IMMEDIATE @ONLY)
155 add_custom_target(uninstall
156 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
157endif()
158
159####### define target to build RPM
160#include(UseRPMTools)
161#if(RPMTools_FOUND)
162# RPMTools_ADD_RPM_TARGETS(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/ccrtp.spec.cmake)
163#endif()