CMakeLists.txt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. cmake_minimum_required(VERSION 3.7)
  2. set(BUILD_NUMBER CACHE STRING "The number of the current build.")
  3. if ("${BUILD_NUMBER}" STREQUAL "")
  4. set(BUILD_NUMBER "0")
  5. endif()
  6. project("SoftEther VPN"
  7. VERSION "5.01.${BUILD_NUMBER}"
  8. LANGUAGES C
  9. )
  10. set(TOP_DIRECTORY ${CMAKE_SOURCE_DIR})
  11. set(BUILD_DIRECTORY ${CMAKE_BINARY_DIR})
  12. # We define a dedicated variable because CMAKE_BUILD_TYPE can have different
  13. # configurations than "Debug" and "Release", such as "RelWithDebInfo".
  14. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  15. set(BUILD_TYPE "Debug")
  16. else()
  17. set(BUILD_TYPE "Release")
  18. endif()
  19. # Check that submodules are present only if source was downloaded with git
  20. if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/Mayaqua/3rdparty/cpu_features/CMakeLists.txt")
  21. message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
  22. endif()
  23. if(UNIX)
  24. include(GNUInstallDirs)
  25. include(CheckIncludeFile)
  26. Check_Include_File(sys/auxv.h HAVE_SYS_AUXV)
  27. if(EXISTS "/lib/systemd/system")
  28. set(CMAKE_INSTALL_SYSTEMD_UNITDIR "/lib/systemd/system" CACHE STRING "Where to install systemd unit files")
  29. endif()
  30. endif()
  31. configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY)
  32. # Date and time
  33. string(TIMESTAMP DATE_DAY "%d" UTC)
  34. string(TIMESTAMP DATE_MONTH "%m" UTC)
  35. string(TIMESTAMP DATE_YEAR "%Y" UTC)
  36. string(TIMESTAMP TIME_HOUR "%H" UTC)
  37. string(TIMESTAMP TIME_MINUTE "%M" UTC)
  38. string(TIMESTAMP TIME_SECOND "%S" UTC)
  39. message(STATUS "Build date: ${DATE_DAY}/${DATE_MONTH}/${DATE_YEAR}")
  40. message(STATUS "Build time: ${TIME_HOUR}:${TIME_MINUTE}:${TIME_SECOND}")
  41. add_subdirectory(src)
  42. if(UNIX)
  43. # Packaging
  44. set(CPACK_COMPONENTS_ALL common vpnserver vpnclient vpnbridge vpncmd)
  45. set(CPACK_PACKAGE_DIRECTORY ${BUILD_DIRECTORY})
  46. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  47. set(CPACK_PACKAGE_VENDOR "SoftEther")
  48. set(CPACK_PACKAGE_NAME "softether")
  49. set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_DIRECTORY}/description")
  50. 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.")
  51. # DEB
  52. if(BUILD_TYPE STREQUAL "Debug")
  53. set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
  54. endif()
  55. set(CPACK_DEB_COMPONENT_INSTALL ON)
  56. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  57. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
  58. set(CPACK_DEBIAN_PACKAGE_SECTION "net")
  59. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Unknown")
  60. # RPM
  61. set(CPACK_RPM_COMPONENT_INSTALL ON)
  62. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
  63. set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
  64. set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
  65. # Exclude system directories
  66. if(CPACK_GENERATOR STREQUAL "RPM")
  67. execute_process(
  68. COMMAND rpm -ql filesystem
  69. COMMAND tr \n \;
  70. OUTPUT_VARIABLE CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  71. ERROR_QUIET)
  72. endif()
  73. include(CPack)
  74. endif()