|
| 1 | +cmake_minimum_required(VERSION 3.15) |
| 2 | +project(sofia-sip C) |
| 3 | + |
| 4 | +# parse project version |
| 5 | +file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.spec SPEC_VERSION_LINE REGEX "^Version: +") |
| 6 | +string(REGEX REPLACE ".+ +(.+)" "\\1" PROJECT_VERSION ${SPEC_VERSION_LINE}) |
| 7 | +set(PACKAGE_NAME "${PROJECT_NAME}") |
| 8 | +set(PACKAGE_VERSION "${PROJECT_VERSION}") |
| 9 | +set(VERSION "${PROJECT_VERSION}") |
| 10 | +message(STATUS "${PROJECT_NAME}: ${PROJECT_VERSION}") |
| 11 | + |
| 12 | +# project default make options |
| 13 | +option(ENABLE_NTH "HTTP-related modules nth and http (enabled)" ON) |
| 14 | +option(ENABLE_STUN "enable stun module (enabled)" ON) |
| 15 | +option(ENABLE_NTLM "enable NTLM support (disabled)" OFF) |
| 16 | +option(ENABLE_MEMLEAK_LOG "enable logging of possible memory leaks (disabled)" OFF) |
| 17 | +option(ENABLE_TAG_CAST "cast tag values with inlined functions (enabled)" ON) |
| 18 | +option(ENABLE_TESTS "enable ctest framework" OFF) |
| 19 | + |
| 20 | +SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") |
| 21 | +include(glib) |
| 22 | +include(inline) |
| 23 | +include(openssl) |
| 24 | +include(pthread) |
| 25 | +include(size_compat) |
| 26 | +include(sofia) |
| 27 | +include(FindUnixCommands) |
| 28 | + |
| 29 | +# find pkg-config command |
| 30 | +find_package(PkgConfig REQUIRED) |
| 31 | + |
| 32 | +# Whether hava check library |
| 33 | +pkg_check_modules(CHECK check>=0.9.4) |
| 34 | +if (CHECK_FOUND) |
| 35 | + set(HAVE_CHECK 1) |
| 36 | +endif (CHECK_FOUND) |
| 37 | + |
| 38 | +# Check whether enable NTLM |
| 39 | +if (ENABLE_NTLM) |
| 40 | + set(HAVE_NTLM 1) |
| 41 | + set(HAVE_SOFIA_NTLM 1) |
| 42 | +endif (ENABLE_NTLM) |
| 43 | + |
| 44 | +# Check whether enable memory leak log |
| 45 | +if (ENABLE_MEMLEAK_LOG) |
| 46 | + set(HAVE_MEMLEAK_LOG 1) |
| 47 | +endif (ENABLE_MEMLEAK_LOG) |
| 48 | + |
| 49 | +# Check whether enable stun |
| 50 | +if (ENABLE_STUN) |
| 51 | + set(HAVE_STUN 1) |
| 52 | + set(HAVE_SOFIA_STUN 1) |
| 53 | + if (NOT HAVE_OPENSSL) |
| 54 | + message(WARNING "** TLS support for STUN disabled as OpenSSL headers and/or libraries were not found **") |
| 55 | + endif (NOT HAVE_OPENSSL) |
| 56 | +endif (ENABLE_STUN) |
| 57 | + |
| 58 | +# Check whether enable nth |
| 59 | +if (ENABLE_NTH) |
| 60 | + set(HAVE_NTH 1) |
| 61 | +endif (ENABLE_NTH) |
| 62 | + |
| 63 | +configure_file( |
| 64 | + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake |
| 65 | + ${CMAKE_CURRENT_BINARY_DIR}/config.h |
| 66 | +) |
| 67 | + |
| 68 | +include_directories( |
| 69 | + ${CMAKE_CURRENT_SOURCE_DIR}/s2check |
| 70 | + ${CMAKE_CURRENT_SOURCE_DIR}/tests |
| 71 | + ${CMAKE_CURRENT_BINARY_DIR} |
| 72 | +) |
| 73 | + |
| 74 | +# whether enable tests |
| 75 | +if (ENABLE_TESTS) |
| 76 | + include(CTest) |
| 77 | +endif (ENABLE_TESTS) |
| 78 | +if (NOT ENABLE_TESTS AND ENABLE_MODULE_TEST) |
| 79 | + string(TOUPPER "enable_${ENABLE_MODULE_TEST}_TESTS" _var) |
| 80 | + set(${_var} 1) |
| 81 | + if (ENABLE_TPORT_TESTS) |
| 82 | + set(ENABLE_MSG_TESTS 1) |
| 83 | + endif () |
| 84 | + include(CTest) |
| 85 | +endif (NOT ENABLE_TESTS AND ENABLE_MODULE_TEST) |
| 86 | + |
| 87 | +add_compile_options(-fPIC) |
| 88 | +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/dummy.c) |
| 89 | +add_library(empty OBJECT ${CMAKE_CURRENT_BINARY_DIR}/dummy.c) |
| 90 | + |
| 91 | +add_subdirectory(libsofia-sip-ua) |
| 92 | +add_subdirectory(libsofia-sip-ua-glib) |
| 93 | +add_subdirectory(s2check) |
| 94 | +add_subdirectory(tests) |
| 95 | +add_subdirectory(utils) |
0 commit comments