Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 2.6) |
| 2 | |
| 3 | # setup the Thread include and lib |
| 4 | find_package(Threads) |
| 5 | if(CMAKE_HAVE_PTHREAD_H) |
| 6 | set(HAVE_PTHREAD_H TRUE) |
| 7 | endif() |
| 8 | set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) |
| 9 | |
| 10 | if (USES_CCRTP_INCLUDE_DIRS) |
| 11 | message(STATUS " Using local commoncpp dependency") |
| 12 | else() |
| 13 | find_package(PkgConfig) |
| 14 | pkg_check_modules(USES_CCRTP libccrtp>=2.0.0) |
| 15 | endif() |
| 16 | include_directories(${USES_CCRTP_INCLUDE_DIRS}) |
| 17 | link_directories(${USES_CCRTP_LIBRARY_DIRS}) |
| 18 | add_definitions(${USES_CCRTP_CFLAGS}) |
| 19 | set (LIBS ${LIBS} ${USES_CCRTP_LDFLAGS} ${USES_CCRTP_LIBRARIES}) |
| 20 | |
| 21 | #to make sure includes are first taken - it contains config.h |
| 22 | include_directories(BEFORE ${CMAKE_BINARY_DIR}) |
| 23 | include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/zrtp |
| 24 | ${CMAKE_SOURCE_DIR}/srtp ${CMAKE_SOURCE_DIR}/bnlib) |
| 25 | |
| 26 | # **** setup the various crypto interface implementations *** |
| 27 | # Twofish is a special case: its always a standalone modlue and thus |
| 28 | # not specific to a library. |
| 29 | # NOTE: the standalone modules live in the 'crypto' |
| 30 | |
| 31 | set(cryptcommon_srcs |
| 32 | ${CMAKE_SOURCE_DIR}/cryptcommon/macSkein.cpp |
| 33 | ${CMAKE_SOURCE_DIR}/cryptcommon/skein.c |
| 34 | ${CMAKE_SOURCE_DIR}/cryptcommon/skein_block.c |
| 35 | ${CMAKE_SOURCE_DIR}/cryptcommon/skeinApi.c |
| 36 | ${CMAKE_SOURCE_DIR}/cryptcommon/twofish.c |
| 37 | ${CMAKE_SOURCE_DIR}/cryptcommon/twofish_cfb.c ${zrtp_skein_src}) |
| 38 | |
| 39 | if (OPENSSL_FOUND) |
| 40 | set(crypto_src |
| 41 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/zrtpDH.cpp |
| 42 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/hmac256.cpp |
| 43 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/sha256.cpp |
| 44 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/hmac384.cpp |
| 45 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/sha384.cpp |
| 46 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/aesCFB.cpp |
| 47 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/openssl/InitializeOpenSSL.cpp |
| 48 | ${CMAKE_SOURCE_DIR}/zrtp/crypto/twoCFB.cpp) |
| 49 | |
| 50 | endif() |
| 51 | |
| 52 | if (CRYPTO_STANDALONE) |
| 53 | set(crypto_src |
| 54 | ${CMAKE_SOURCE_DIR}/cryptcommon/ZrtpRandom.cpp |
| 55 | ${CMAKE_SOURCE_DIR}/common/Thread.cpp |
| 56 | ${CMAKE_SOURCE_DIR}/common/MutexClass.cpp |
| 57 | ${CMAKE_SOURCE_DIR}/common/EventClass.cpp |
| 58 | ${zrtp_crypto_src} ${bnlib_src}) |
| 59 | |
| 60 | set(cryptcommon_srcs ${cryptcommon_srcs} |
| 61 | ${CMAKE_SOURCE_DIR}/cryptcommon/aescrypt.c |
| 62 | ${CMAKE_SOURCE_DIR}/cryptcommon/aeskey.c |
| 63 | ${CMAKE_SOURCE_DIR}/cryptcommon/aestab.c |
| 64 | ${CMAKE_SOURCE_DIR}/cryptcommon/aes_modes.c) |
| 65 | endif() |
| 66 | |
| 67 | set(zrtp_ccrtp_src |
| 68 | ${CMAKE_CURRENT_SOURCE_DIR}/ZrtpQueue.cpp) |
| 69 | |
| 70 | set(zrtpcpp_src ${zrtp_src} ${zrtp_ccrtp_src} ${crypto_src} ${cryptcommon_srcs}) |
| 71 | |
| 72 | if(BUILD_STATIC AND NOT BUILD_SHARED) |
| 73 | set(LIBRARY_BUILD_TYPE STATIC) |
| 74 | else() |
| 75 | set(LIBRARY_BUILD_TYPE SHARED) |
| 76 | endif() |
| 77 | |
| 78 | add_library(${zrtplibName} ${LIBRARY_BUILD_TYPE} ${zrtpcpp_src}) |
| 79 | set_target_properties(${zrtplibName} PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION}) |
| 80 | target_link_libraries(${zrtplibName} ${LIBS}) |
| 81 | |
| 82 | add_dependencies(${zrtplibName} ccrtp) |
| 83 | |
| 84 | # **** Setup packing environment **** |
| 85 | # |
| 86 | if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) |
| 87 | include(${CMAKE_SOURCE_DIR}/cmake/Modules/GeneratePackage.cmake) |
| 88 | |
| 89 | GENERATE_PACKAGING(${PACKAGE} ${VERSION}) |
| 90 | endif() |
| 91 | |
| 92 | # **** Create the external files for RPM and pkgconfig **** |
| 93 | # |
| 94 | set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 95 | set(exec_prefix ${prefix}/bin) |
| 96 | set(libdir ${prefix}/${LIBDIRNAME}) |
| 97 | set(includedir ${prefix}/include) |
| 98 | set(PACKAGE pkgconfig) |
| 99 | |
| 100 | configure_file(${CMAKE_SOURCE_DIR}/libzrtpcpp.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplibName}.pc @ONLY) |
| 101 | configure_file(${CMAKE_SOURCE_DIR}/libzrtpcpp.spec.cmake ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplibName}.spec @ONLY) |
| 102 | |
| 103 | # **** install files **** |
| 104 | # |
| 105 | set(ccrtp_inst |
| 106 | ${CMAKE_CURRENT_SOURCE_DIR}/ZrtpQueue.h |
| 107 | ${CMAKE_CURRENT_SOURCE_DIR}/zrtpccrtp.h |
| 108 | ${CMAKE_CURRENT_SOURCE_DIR}/CcrtpTimeoutProvider.h) |
| 109 | |
| 110 | install(FILES |
| 111 | ${CMAKE_SOURCE_DIR}/zrtp/libzrtpcpp/ZrtpCodes.h |
| 112 | ${CMAKE_SOURCE_DIR}/zrtp/libzrtpcpp/ZrtpConfigure.h |
| 113 | ${CMAKE_SOURCE_DIR}/zrtp/libzrtpcpp/ZrtpCallback.h |
| 114 | ${CMAKE_SOURCE_DIR}/zrtp/libzrtpcpp/ZrtpCWrapper.h |
| 115 | ${CMAKE_SOURCE_DIR}/zrtp/libzrtpcpp/ZrtpUserCallback.h ${ccrtp_inst} DESTINATION include/libzrtpcpp) |
| 116 | |
| 117 | install(FILES ${CMAKE_SOURCE_DIR}/common/osSpecifics.h DESTINATION include/libzrtpcpp/common) |
| 118 | |
| 119 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplibName}.pc DESTINATION ${LIBDIRNAME}/pkgconfig) |
| 120 | |
| 121 | install(TARGETS ${zrtplibName} DESTINATION ${LIBDIRNAME}) |
| 122 | |
| 123 | if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) |
| 124 | |
| 125 | ########### Add uninstall target ############### |
| 126 | configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) |
| 127 | add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
| 128 | |
| 129 | endif() |
| 130 | |
| 131 | |