CMakeLists.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. cmake_minimum_required(VERSION 3.13)
  2. # Use cmake -DCMAKE_SYSTEM_NAME .. for cross-compiling (inside build directory)
  3. # Set the project name
  4. project(
  5. kamailio
  6. VERSION 6.1.0
  7. DESCRIPTION "Kamailio SIP Server"
  8. HOMEPAGE_URL "https://www.kamailio.org"
  9. )
  10. # ---- Include guards ----
  11. if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
  12. message(
  13. FATAL_ERROR
  14. "In-source builds not allowed. Please make a new directory (called a build directory) \
  15. and run CMake again accordingly."
  16. )
  17. endif()
  18. # ---- Project settings ----
  19. # Set the version number
  20. set(EXTRAVERSION "-dev1")
  21. set(RELEASE "${PROJECT_VERSION}${EXTRAVERSION}")
  22. message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")
  23. message(STATUS "RELEASE: ${RELEASE}")
  24. # cmake-format: off
  25. # Set the version number as a single integer
  26. math(EXPR VERSIONVAL
  27. "${PROJECT_VERSION_MAJOR}*1000000
  28. + ${PROJECT_VERSION_MINOR}*1000
  29. + ${PROJECT_VERSION_PATCH}"
  30. )
  31. message(STATUS "VERSIONVAL: ${VERSIONVAL}")
  32. # cmake-format: on
  33. # Specify the C standard if non provided by user
  34. if(NOT CMAKE_C_STANDARD)
  35. set(CMAKE_C_STANDARD 11)
  36. set(CMAKE_C_STANDARD_REQUIRED True)
  37. endif()
  38. list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
  39. include(${CMAKE_SOURCE_DIR}/cmake/BuildType.cmake)
  40. # -----------------------
  41. # Main project name
  42. # -----------------------
  43. # main binary name
  44. set(MAIN_NAME
  45. "kamailio"
  46. CACHE STRING "Main binary name"
  47. )
  48. # use kamailio config
  49. set(CFG_NAME
  50. "kamailio"
  51. CACHE STRING "Config name"
  52. )
  53. include(GNUInstallDirs)
  54. include(${CMAKE_SOURCE_DIR}/cmake/defs.cmake)
  55. # Add the source directory
  56. add_subdirectory(src)
  57. # Add utils
  58. # add_subdirectory(utils)
  59. add_subdirectory(utils/kamctl)
  60. add_subdirectory(utils/kamcmd)
  61. # ----------
  62. # Db schema files
  63. # Include it here due to calling a script where we need the base binary dir
  64. # and scirpts are using {CMAKE_BINARY_DIR} from where they where first included.
  65. include(${CMAKE_SOURCE_DIR}/cmake/dbschema.cmake)
  66. # ----------
  67. # Packaging
  68. # ----------
  69. include(${CMAKE_SOURCE_DIR}/cmake/deb-packaging.cmake)
  70. # Add uninstall target
  71. if(NOT TARGET uninstall)
  72. configure_file(
  73. "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-uninstall.cmake.in"
  74. "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake-uninstall.cmake" IMMEDIATE @ONLY
  75. )
  76. add_custom_target(
  77. uninstall
  78. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake-uninstall.cmake
  79. COMMENT "Uninstalling ${PROJECT_NAME}-${PROJECT_VERSION} from ${CMAKE_INSTALL_PREFIX}"
  80. )
  81. endif()