1 cmake_minimum_required(VERSION 2.8)
3 project(libsrtp2 LANGUAGES C)
5 set(PACKAGE_VERSION 2.3.0)
6 set(PACKAGE_STRING "${CMAKE_PROJECT_NAME} ${PACKAGE_VERSION}")
9 include(CheckIncludeFile)
10 include(CheckFunctionExists)
11 include(CheckTypeSize)
12 include(CheckCSourceCompiles)
14 test_big_endian(WORDS_BIGENDIAN)
16 if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
22 check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
23 check_include_file(byteswap.h HAVE_BYTESWAP_H)
24 check_include_file(inttypes.h HAVE_INTTYPES_H)
25 check_include_file(machine/types.h HAVE_MACHINE_TYPES_H)
26 check_include_file(netinet/in.h HAVE_NETINET_IN_H)
27 check_include_file(stdint.h HAVE_STDINT_H)
28 check_include_file(stdlib.h HAVE_STDLIB_H)
29 check_include_file(sys/int_types.h HAVE_SYS_INT_TYPES_H)
30 check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
31 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
32 check_include_file(unistd.h HAVE_UNISTD_H)
33 check_include_file(windows.h HAVE_WINDOWS_H)
34 check_include_file(winsock2.h HAVE_WINSOCK2_H)
36 check_function_exists(sigaction HAVE_SIGACTION)
37 check_function_exists(inet_aton HAVE_INET_ATON)
38 check_function_exists(usleep HAVE_USLEEP)
40 check_type_size(uint8_t UINT8_T)
41 check_type_size(uint16_t UINT16_T)
42 check_type_size(uint32_t UINT32_T)
43 check_type_size(uint64_t UINT64_T)
44 check_type_size(int32_t INT32_T)
45 check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG)
46 check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
48 check_c_source_compiles("inline void func(); void func() { } int main() { func(); return 0; }" HAVE_INLINE)
50 check_c_source_compiles("__inline void func(); void func() { } int main() { func(); return 0; }" HAVE___INLINE)
53 set(ENABLE_DEBUG_LOGGING OFF CACHE BOOL "Enable debug logging in all modules")
54 set(ERR_REPORTING_STDOUT OFF CACHE BOOL "Enable logging to stdout")
55 set(ERR_REPORTING_FILE "" CACHE FILEPATH "Use file for logging")
56 set(ENABLE_OPENSSL OFF CACHE BOOL "Enable OpenSSL crypto engine")
57 set(TEST_APPS ON CACHE BOOL "Build test applications")
58 option(BUILD_SHARED_LIBS "Build shared library" OFF)
61 find_package(OpenSSL REQUIRED)
62 include_directories(${OPENSSL_INCLUDE_DIR})
64 set(OPENSSL ${ENABLE_OPENSSL} CACHE BOOL INTERNAL)
65 set(GCM ${ENABLE_OPENSSL} CACHE BOOL INTERNAL)
67 set(CONFIG_FILE_DIR ${CMAKE_CURRENT_BINARY_DIR})
68 include_directories(${CONFIG_FILE_DIR})
70 configure_file(config_in_cmake.h ${CONFIG_FILE_DIR}/config.h)
71 add_definitions(-DHAVE_CONFIG_H)
79 crypto/cipher/cipher.c
80 crypto/cipher/null_cipher.c
84 list(APPEND CIPHERS_SOURCES_C
85 crypto/cipher/aes_icm_ossl.c
86 crypto/cipher/aes_gcm_ossl.c
89 list(APPEND CIPHERS_SOURCES_C
91 crypto/cipher/aes_icm.c
97 crypto/hash/null_auth.c
101 list(APPEND HASHES_SOURCES_C
102 crypto/hash/hmac_ossl.c
105 list(APPEND HASHES_SOURCES_C
112 crypto/kernel/alloc.c
113 crypto/kernel/crypto_kernel.c
119 crypto/math/datatypes.c
126 crypto/replay/ut_sim.c
131 crypto/include/aes_icm.h
132 crypto/include/alloc.h
133 crypto/include/auth.h
134 crypto/include/cipher.h
135 crypto/include/cipher_types.h
136 crypto/include/crypto_kernel.h
137 crypto/include/crypto_types.h
138 crypto/include/datatypes.h
140 crypto/include/hmac.h
141 crypto/include/integers.h
143 crypto/include/null_auth.h
144 crypto/include/null_cipher.h
146 crypto/include/rdbx.h
147 crypto/include/sha1.h
148 crypto/include/stat.h
152 ${CONFIG_FILE_DIR}/config.h
155 if(BUILD_SHARED_LIBS AND WIN32)
156 list(APPEND SOURCES_C
161 source_group("src" FILES ${SOURCES_C})
162 source_group("src\\Ciphers" FILES ${CIPHERS_SOURCES_C})
163 source_group("src\\Hashes" FILES ${HASHES_SOURCES_C})
164 source_group("src\\Kernel" FILES ${KERNEL_SOURCES_C})
165 source_group("src\\Math" FILES ${MATH_SOURCES_C})
166 source_group("src\\Replay" FILES ${REPLAY_SOURCES_C})
167 source_group("include" FILES ${SOURCES_H})
179 target_include_directories(srtp2 PUBLIC crypto/include include)
181 target_link_libraries(srtp2 OpenSSL::Crypto)
184 target_link_libraries(srtp2 ws2_32)
187 install(TARGETS srtp2 DESTINATION lib)
188 install(FILES include/srtp.h crypto/include/auth.h
189 crypto/include/cipher.h
190 crypto/include/cipher_types.h
191 DESTINATION include/srtp2)
196 if(NOT (BUILD_SHARED_LIBS AND WIN32))
197 add_executable(test_srtp test/test_srtp.c)
198 target_link_libraries(test_srtp srtp2)
199 add_test(test_srtp test_srtp)
202 add_executable(srtp_driver test/srtp_driver.c
203 test/util.c test/getopt_s.c)
204 target_link_libraries(srtp_driver srtp2)
205 add_test(srtp_driver srtp_driver -v)