CMakeLists.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. cmake_minimum_required(VERSION 3.15)
  2. set(BUILD_NUMBER CACHE STRING "The number of the current build.")
  3. if ("${BUILD_NUMBER}" STREQUAL "")
  4. set(BUILD_NUMBER "5187")
  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. #
  13. # Link MSVC runtime statically
  14. # this should be revisited after installer migration to MSI
  15. #
  16. cmake_policy(SET CMP0091 NEW)
  17. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
  18. project("SoftEther VPN"
  19. VERSION "5.02.${BUILD_NUMBER}"
  20. LANGUAGES C
  21. )
  22. set(CMAKE_C_STANDARD 99)
  23. set(TOP_DIRECTORY ${CMAKE_SOURCE_DIR})
  24. set(BUILD_DIRECTORY ${CMAKE_BINARY_DIR})
  25. # We define a dedicated variable because CMAKE_BUILD_TYPE can have different
  26. # configurations than "Debug" and "Release", such as "RelWithDebInfo".
  27. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  28. set(BUILD_TYPE "Debug")
  29. else()
  30. set(BUILD_TYPE "Release")
  31. endif()
  32. # Check that submodules are present only if source was downloaded with git
  33. if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/libhamcore/CMakeLists.txt")
  34. message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
  35. endif()
  36. if(WIN32 AND VCPKG_TARGET_TRIPLET AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  37. message (FATAL_ERROR "vcpkg not installed or integrated with Visual Studio. Install it and run\n\tvcpkg integrate install")
  38. endif()
  39. if(UNIX)
  40. include(GNUInstallDirs)
  41. #
  42. # use rpath for locating installed libraries
  43. #
  44. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  45. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  46. include(CheckIncludeFile)
  47. Check_Include_File(sys/auxv.h HAVE_SYS_AUXV)
  48. if(EXISTS "/lib/systemd/system")
  49. set(CMAKE_INSTALL_SYSTEMD_UNITDIR "/lib/systemd/system" CACHE STRING "Where to install systemd unit files")
  50. endif()
  51. endif()
  52. configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY)
  53. # Date and time
  54. string(TIMESTAMP DATE_DAY "%d" UTC)
  55. string(TIMESTAMP DATE_MONTH "%m" UTC)
  56. string(TIMESTAMP DATE_YEAR "%Y" UTC)
  57. string(TIMESTAMP TIME_HOUR "%H" UTC)
  58. string(TIMESTAMP TIME_MINUTE "%M" UTC)
  59. string(TIMESTAMP TIME_SECOND "%S" UTC)
  60. message(STATUS "Build date: ${DATE_DAY}/${DATE_MONTH}/${DATE_YEAR}")
  61. message(STATUS "Build time: ${TIME_HOUR}:${TIME_MINUTE}:${TIME_SECOND}")
  62. add_subdirectory(src)
  63. if(UNIX)
  64. # Packaging
  65. set(CPACK_COMPONENTS_ALL common vpnserver vpnclient vpnbridge vpncmd)
  66. set(CPACK_PACKAGE_DIRECTORY ${BUILD_DIRECTORY})
  67. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  68. set(CPACK_PACKAGE_VENDOR "SoftEther")
  69. set(CPACK_PACKAGE_NAME "softether")
  70. set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_DIRECTORY}/description")
  71. 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.")
  72. # DEB
  73. if(BUILD_TYPE STREQUAL "Debug")
  74. set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
  75. endif()
  76. set(CPACK_DEB_COMPONENT_INSTALL ON)
  77. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  78. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
  79. set(CPACK_DEBIAN_PACKAGE_SECTION "net")
  80. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Unknown")
  81. # RPM
  82. set(CPACK_RPM_COMPONENT_INSTALL ON)
  83. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
  84. set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
  85. set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
  86. # Exclude system directories
  87. if(CPACK_GENERATOR STREQUAL "RPM")
  88. execute_process(
  89. COMMAND rpm -ql filesystem
  90. COMMAND tr \n \;
  91. OUTPUT_VARIABLE CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  92. ERROR_QUIET)
  93. endif()
  94. include(CPack)
  95. endif()