CMakeLists.txt 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 3.7)
  2. project("SoftEther VPN"
  3. VERSION 5.01.9665
  4. LANGUAGES C
  5. )
  6. set(TOP_DIRECTORY ${CMAKE_SOURCE_DIR})
  7. set(BUILD_DIRECTORY ${TOP_DIRECTORY}/build)
  8. # We define a dedicated variable because CMAKE_BUILD_TYPE can have different
  9. # configurations than "Debug" and "Release", such as "RelWithDebInfo".
  10. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  11. set(BUILD_TYPE "Debug")
  12. else()
  13. set(BUILD_TYPE "Release")
  14. endif()
  15. # Check that submodules are present only if source was downloaded with git
  16. if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/Mayaqua/3rdparty/cpu_features/CMakeLists.txt")
  17. message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
  18. endif()
  19. # Compare ${PROJECT_VERSION} and src/CurrentBuild.txt
  20. file(READ ${TOP_DIRECTORY}/src/CurrentBuild.txt CurrentBuild)
  21. string(REGEX MATCH "VERSION_MAJOR ([0-9]+)" temp ${CurrentBuild})
  22. string(REGEX REPLACE "VERSION_MAJOR ([0-9]+)" "\\1" CurrentBuild_MAJOR ${temp})
  23. string(REGEX MATCH "VERSION_MINOR ([0-9]+)" temp ${CurrentBuild})
  24. string(REGEX REPLACE "VERSION_MINOR ([0-9]+)" "\\1" CurrentBuild_MINOR ${temp})
  25. string(REGEX MATCH "VERSION_BUILD ([0-9]+)" temp ${CurrentBuild})
  26. string(REGEX REPLACE "VERSION_BUILD ([0-9]+)" "\\1" CurrentBuild_BUILD ${temp})
  27. if(NOT ${PROJECT_VERSION} VERSION_EQUAL "${CurrentBuild_MAJOR}.${CurrentBuild_MINOR}.${CurrentBuild_BUILD}")
  28. message (FATAL_ERROR "PROJECT_VERSION does not match to src/CurrentBuild.txt")
  29. endif()
  30. if(UNIX)
  31. include(GNUInstallDirs)
  32. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  33. include(CheckIncludeFile)
  34. Check_Include_File(sys/auxv.h HAVE_SYS_AUXV)
  35. endif()
  36. configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY)
  37. # Date and time
  38. string(TIMESTAMP DATE_DAY "%d" UTC)
  39. string(TIMESTAMP DATE_MONTH "%m" UTC)
  40. string(TIMESTAMP DATE_YEAR "%Y" UTC)
  41. string(TIMESTAMP TIME_HOUR "%H" UTC)
  42. string(TIMESTAMP TIME_MINUTE "%M" UTC)
  43. string(TIMESTAMP TIME_SECOND "%S" UTC)
  44. message(STATUS "Build date: ${DATE_DAY}/${DATE_MONTH}/${DATE_YEAR}")
  45. message(STATUS "Build time: ${TIME_HOUR}:${TIME_MINUTE}:${TIME_SECOND}")
  46. set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
  47. add_subdirectory(src)
  48. if(UNIX)
  49. # Packaging
  50. set(CPACK_COMPONENTS_ALL common vpnserver vpnclient vpnbridge vpncmd)
  51. set(CPACK_PACKAGE_DIRECTORY ${BUILD_DIRECTORY})
  52. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  53. set(CPACK_PACKAGE_VENDOR "SoftEther")
  54. set(CPACK_PACKAGE_NAME "softether")
  55. set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_DIRECTORY}/description")
  56. 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.")
  57. # DEB
  58. if(BUILD_TYPE STREQUAL "Debug")
  59. set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
  60. endif()
  61. set(CPACK_DEB_COMPONENT_INSTALL ON)
  62. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  63. set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
  64. set(CPACK_DEBIAN_PACKAGE_SECTION "net")
  65. set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Unknown")
  66. # RPM
  67. set(CPACK_RPM_COMPONENT_INSTALL ON)
  68. set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
  69. set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
  70. set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
  71. include(CPack)
  72. endif()