blob: 093b3691892abd2ae86869873e09ee3e5b6597d3 [file] [log] [blame]
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -05001cmake_minimum_required (VERSION 2.6)
2
3# setup the Thread include and lib
4find_package(Threads)
5if(CMAKE_HAVE_PTHREAD_H)
6 set(HAVE_PTHREAD_H TRUE)
7endif()
8set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
9
10if (USES_CCRTP_INCLUDE_DIRS)
11 message(STATUS " Using local commoncpp dependency")
12else()
13 find_package(PkgConfig)
14 pkg_check_modules(USES_CCRTP libccrtp>=2.0.0)
15endif()
16include_directories(${USES_CCRTP_INCLUDE_DIRS})
17link_directories(${USES_CCRTP_LIBRARY_DIRS})
18add_definitions(${USES_CCRTP_CFLAGS})
19set (LIBS ${LIBS} ${USES_CCRTP_LDFLAGS} ${USES_CCRTP_LIBRARIES})
20
21#to make sure includes are first taken - it contains config.h
22include_directories(BEFORE ${CMAKE_BINARY_DIR})
23include_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
31set(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
39if (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
50endif()
51
52if (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)
65endif()
66
67set(zrtp_ccrtp_src
68 ${CMAKE_CURRENT_SOURCE_DIR}/ZrtpQueue.cpp)
69
70set(zrtpcpp_src ${zrtp_src} ${zrtp_ccrtp_src} ${crypto_src} ${cryptcommon_srcs})
71
72if(BUILD_STATIC AND NOT BUILD_SHARED)
73 set(LIBRARY_BUILD_TYPE STATIC)
74else()
75 set(LIBRARY_BUILD_TYPE SHARED)
76endif()
77
78add_library(${zrtplibName} ${LIBRARY_BUILD_TYPE} ${zrtpcpp_src})
79set_target_properties(${zrtplibName} PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION})
80target_link_libraries(${zrtplibName} ${LIBS})
81
82add_dependencies(${zrtplibName} ccrtp)
83
84# **** Setup packing environment ****
85#
86if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
87 include(${CMAKE_SOURCE_DIR}/cmake/Modules/GeneratePackage.cmake)
88
89 GENERATE_PACKAGING(${PACKAGE} ${VERSION})
90endif()
91
92# **** Create the external files for RPM and pkgconfig ****
93#
94set(prefix ${CMAKE_INSTALL_PREFIX})
95set(exec_prefix ${prefix}/bin)
96set(libdir ${prefix}/${LIBDIRNAME})
97set(includedir ${prefix}/include)
98set(PACKAGE pkgconfig)
99
100configure_file(${CMAKE_SOURCE_DIR}/libzrtpcpp.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplibName}.pc @ONLY)
101configure_file(${CMAKE_SOURCE_DIR}/libzrtpcpp.spec.cmake ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplibName}.spec @ONLY)
102
103# **** install files ****
104#
105set(ccrtp_inst
106 ${CMAKE_CURRENT_SOURCE_DIR}/ZrtpQueue.h
107 ${CMAKE_CURRENT_SOURCE_DIR}/zrtpccrtp.h
108 ${CMAKE_CURRENT_SOURCE_DIR}/CcrtpTimeoutProvider.h)
109
110install(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
117install(FILES ${CMAKE_SOURCE_DIR}/common/osSpecifics.h DESTINATION include/libzrtpcpp/common)
118
119install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplibName}.pc DESTINATION ${LIBDIRNAME}/pkgconfig)
120
121install(TARGETS ${zrtplibName} DESTINATION ${LIBDIRNAME})
122
123if(${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
129endif()
130
131