Alexandre Lision | ddd731e | 2014-01-31 11:50:08 -0500 | [diff] [blame] | 1 | ## 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 | |
| 14 | cmake_minimum_required(VERSION 2.6) |
| 15 | |
| 16 | PROJECT(libccrtp) |
| 17 | |
| 18 | # for debug and trace during CMakeList development |
| 19 | set(CMAKE_VERBOSE_MAKEFILE FALSE) |
| 20 | |
| 21 | SET(CPACK_PACKAGE_VERSION_MAJOR 2) |
| 22 | SET(CPACK_PACKAGE_VERSION_MINOR 0) |
| 23 | SET(CPACK_PACKAGE_VERSION_PATCH 4) |
| 24 | |
| 25 | # set some global variables, in particular version variables |
| 26 | set (VERSION 2.0.4) |
| 27 | set (SOVERSION ${VERSION}) |
| 28 | STRING(REGEX REPLACE "[.].*$" "" SOVERSION ${SOVERSION}) |
| 29 | set (REQUIRES 5.0.0) |
| 30 | set (PACKAGE ccrtp) |
| 31 | |
| 32 | # Set library postfix in case of 64 bit architecture |
| 33 | # this caused problems in debian where it has to always be lib.... |
| 34 | set(LIB64 "") |
| 35 | if (NOT EXISTS /etc/debian_version) |
| 36 | if ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" ) |
| 37 | set(LIB64 "64") |
| 38 | endif() |
| 39 | endif() |
| 40 | |
| 41 | include(cmake/Modules/AutoArgs.cmake) |
| 42 | enable_arg(srtp true) |
| 43 | |
| 44 | if(MSVC60) |
| 45 | set(BUILD_STATIC ON CACHE BOOL "static linking only" FORCE) |
| 46 | MARK_AS_ADVANCED(BUILD_STATIC) |
| 47 | else() |
| 48 | option(BUILD_STATIC "Set to OFF to build shared libraries" OFF) |
| 49 | endif() |
| 50 | |
| 51 | MESSAGE( STATUS "Configuring GNU ${PROJECT_NAME} ${VERSION}...") |
| 52 | |
| 53 | # include all the fine stuff we need |
| 54 | include(cmake/Modules/FindGcryptConfig.cmake) |
| 55 | include(FindPkgConfig) |
| 56 | include(CheckLibraryExists) |
| 57 | include(CheckIncludeFiles) |
| 58 | |
| 59 | if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) |
| 60 | include(cmake/Modules/GeneratePackage.cmake) |
| 61 | |
| 62 | GENERATE_PACKAGING(${PACKAGE} ${VERSION}) |
| 63 | endif() |
| 64 | |
| 65 | # setup the Thread include and lib |
| 66 | find_package(Threads) |
| 67 | if (CMAKE_HAVE_PTHREAD_H) |
| 68 | set(HAVE_PTHREAD_H TRUE) |
| 69 | endif() |
| 70 | set (LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) |
| 71 | |
| 72 | if (USES_UCOMMON_INCLUDE_DIRS) |
| 73 | message(STATUS " Using local commoncpp dependency") |
| 74 | else() |
| 75 | find_package(PkgConfig) |
| 76 | pkg_check_modules(USES_UCOMMON commoncpp>=${REQUIRES}) |
| 77 | endif() |
| 78 | |
| 79 | include_directories(${USES_UCOMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src/ccrtp) |
| 80 | link_directories(${USES_UCOMMON_LIBRARY_DIRS}) |
| 81 | add_definitions(${USES_UCOMMON_CFLAGS}) |
| 82 | set (LIBS ${LIBS} ${USES_UCOMMON_LDFLAGS} commoncpp ${USES_UCOMMON_LIBRARIES}) |
| 83 | |
| 84 | if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT MINGW) |
| 85 | check_include_files(openssl/ssl.h HAVE_OPENSSL_WINDOWS) |
| 86 | else() |
| 87 | pkg_check_modules(OPENSSL libssl>=0.9.8) |
| 88 | endif() |
| 89 | |
| 90 | if (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() |
| 114 | endif() |
| 115 | |
| 116 | # the following set(...) commands are only to have backward |
| 117 | # compatibility with autoconf stuff to generate the pc file |
| 118 | set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 119 | set(exec_prefix ${prefix}/bin) |
| 120 | set(libdir ${prefix}/lib${LIB64}) |
| 121 | set(includedir ${prefix}/include) |
| 122 | set(PACKAGE pkgconfig) |
| 123 | |
| 124 | configure_file(libccrtp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libccrtp.pc @ONLY) |
| 125 | configure_file(ccrtp.spec.cmake ${CMAKE_CURRENT_BINARY_DIR}/ccrtp.spec @ONLY) |
| 126 | |
| 127 | if(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) |
| 131 | endif() |
| 132 | |
| 133 | # now prepare and go for the sub-directories |
| 134 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/ccrtp) |
| 135 | |
| 136 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ccrtp-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/ccrtp-config.h) |
| 137 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
| 138 | |
| 139 | add_subdirectory(src) |
| 140 | |
| 141 | add_subdirectory(demo) |
| 142 | |
| 143 | add_subdirectory(doc) |
| 144 | |
| 145 | ########### install files ############### |
| 146 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libccrtp.pc DESTINATION lib${LIB64}/pkgconfig) |
| 147 | |
| 148 | if(${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") |
| 157 | endif() |
| 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() |