CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. cmake_minimum_required(VERSION 3.10)
  2. set(BUILD_NUMBER CACHE STRING "The number of the current build.")
  3. if ("${BUILD_NUMBER}" STREQUAL "")
  4. set(BUILD_NUMBER "5180")
  5. endif()
  6. if (BUILD_NUMBER LESS 5180)
  7. message(WARNING
  8. "Setting BUILD_NUMBER to a value less than 5180 will break compatibility with client binaries distributed by SoftEther Corporation. "
  9. "Set to a value greater than or equal to 5180 if you want such clients to work properly.\n"
  10. "For detailed info: https://github.com/SoftEtherVPN/SoftEtherVPN/issues/1392#issuecomment-867348281")
  11. endif()
  12. project("SoftEther VPN"
  13. VERSION "5.02.${BUILD_NUMBER}"
  14. LANGUAGES C
  15. )
  16. set(CMAKE_C_STANDARD 99)
  17. set(TOP_DIRECTORY ${CMAKE_SOURCE_DIR})
  18. set(BUILD_DIRECTORY ${CMAKE_BINARY_DIR})
  19. # We define a dedicated variable because CMAKE_BUILD_TYPE can have different
  20. # configurations than "Debug" and "Release", such as "RelWithDebInfo".
  21. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  22. set(BUILD_TYPE "Debug")
  23. else()
  24. set(BUILD_TYPE "Release")
  25. endif()
  26. # Check that submodules are present only if source was downloaded with git
  27. if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/libhamcore/CMakeLists.txt")
  28. message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
  29. endif()
  30. if(UNIX)
  31. include(GNUInstallDirs)
  32. #
  33. # use rpath for locating installed libraries
  34. #
  35. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  36. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  37. include(CheckIncludeFile)
  38. Check_Include_File(sys/auxv.h HAVE_SYS_AUXV)
  39. if(EXISTS "/lib/systemd/system")
  40. set(CMAKE_INSTALL_SYSTEMD_UNITDIR "/lib/systemd/system" CACHE STRING "Where to install systemd unit files")
  41. endif()
  42. endif()
  43. configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY)
  44. # Date and time
  45. string(TIMESTAMP DATE_DAY "%d" UTC)
  46. string(TIMESTAMP DATE_MONTH "%m" UTC)
  47. string(TIMESTAMP DATE_YEAR "%Y" UTC)
  48. string(TIMESTAMP TIME_HOUR "%H" UTC)
  49. string(TIMESTAMP TIME_MINUTE "%M" UTC)
  50. string(TIMESTAMP TIME_SECOND "%S" UTC)
  51. message(STATUS "Build date: ${DATE_DAY}/${DATE_MONTH}/${DATE_YEAR}")
  52. message(STATUS "Build time: ${TIME_HOUR}:${TIME_MINUTE}:${TIME_SECOND}")
  53. add_subdirectory(src)
  54. if(UNIX)
  55. # Packaging
  56. set(CPACK_COMPONENTS_ALL common vpnserver vpnclient vpnbridge vpncmd)
  57. set(CPACK_PACKAGE_DIRECTORY ${BUILD_DIRECTORY})
  58. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  59. set(CPACK_PACKAGE_VENDOR "SoftEther")
  60. set(CPACK_PACKAGE_NAME "softether")
  61. set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_DIRECTORY}/description")
  62. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SoftEther VPN is an open-source cross-platform multi-protocol VPN program, created as an academic project in the University of Tsukuba.")
  63. # DEB
  64. if(BUILD_TYPE STREQUAL "Debug")
  65. set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
  66. endif()
  67. set(CPACK_DEB_COMPONENT_INSTALL ON)
  68. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  69. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
  70. set(CPACK_DEBIAN_PACKAGE_SECTION "net")
  71. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Unknown")
  72. # RPM
  73. set(CPACK_RPM_COMPONENT_INSTALL ON)
  74. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
  75. set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
  76. set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
  77. # Exclude system directories
  78. if(CPACK_GENERATOR STREQUAL "RPM")
  79. execute_process(
  80. COMMAND rpm -ql filesystem
  81. COMMAND tr \n \;
  82. OUTPUT_VARIABLE CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  83. ERROR_QUIET)
  84. endif()
  85. include(CPack)
  86. endif()