2021-03-01 04:37:00 +03:00
cmake_minimum_required ( VERSION 3.10 )
2018-05-22 23:20:41 +03:00
2021-02-19 23:05:43 +03:00
set ( BUILD_NUMBER CACHE STRING "The number of the current build." )
if ( "${BUILD_NUMBER}" STREQUAL "" )
set ( BUILD_NUMBER "0" )
endif ( )
2018-11-19 02:13:59 +03:00
project ( "SoftEther VPN"
2021-05-25 02:29:36 +03:00
V E R S I O N " 5 . 0 2 . $ { B U I L D _ N U M B E R } "
2018-08-10 00:33:38 +03:00
L A N G U A G E S C
)
2018-05-22 23:20:41 +03:00
2021-02-27 02:35:58 +03:00
set ( CMAKE_C_STANDARD 99 )
2018-11-19 02:13:59 +03:00
set ( TOP_DIRECTORY ${ CMAKE_SOURCE_DIR } )
2020-07-20 19:31:41 +03:00
set ( BUILD_DIRECTORY ${ CMAKE_BINARY_DIR } )
2018-11-19 02:13:59 +03:00
2018-11-18 06:18:42 +03:00
# We define a dedicated variable because CMAKE_BUILD_TYPE can have different
# configurations than "Debug" and "Release", such as "RelWithDebInfo".
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set ( BUILD_TYPE "Debug" )
else ( )
set ( BUILD_TYPE "Release" )
endif ( )
2018-05-22 23:20:41 +03:00
2018-08-07 18:38:06 +03:00
# Check that submodules are present only if source was downloaded with git
2021-03-10 04:13:00 +03:00
if ( EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/libhamcore/CMakeLists.txt" )
2018-08-07 18:38:06 +03:00
message ( FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive" )
endif ( )
2018-10-24 20:23:07 +03:00
if ( UNIX )
include ( GNUInstallDirs )
2018-10-23 22:32:41 +03:00
2018-10-24 20:23:07 +03:00
include ( CheckIncludeFile )
Check_Include_File ( sys/auxv.h HAVE_SYS_AUXV )
2019-10-29 18:33:28 +03:00
if ( EXISTS "/lib/systemd/system" )
set ( CMAKE_INSTALL_SYSTEMD_UNITDIR "/lib/systemd/system" CACHE STRING "Where to install systemd unit files" )
endif ( )
2018-10-24 20:23:07 +03:00
endif ( )
2018-10-11 23:03:12 +03:00
2018-11-19 02:13:59 +03:00
configure_file ( "${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY )
2018-10-03 08:24:42 +03:00
2018-11-27 07:26:21 +03:00
# Date and time
string ( TIMESTAMP DATE_DAY "%d" UTC )
string ( TIMESTAMP DATE_MONTH "%m" UTC )
string ( TIMESTAMP DATE_YEAR "%Y" UTC )
string ( TIMESTAMP TIME_HOUR "%H" UTC )
string ( TIMESTAMP TIME_MINUTE "%M" UTC )
string ( TIMESTAMP TIME_SECOND "%S" UTC )
message ( STATUS "Build date: ${DATE_DAY}/${DATE_MONTH}/${DATE_YEAR}" )
message ( STATUS "Build time: ${TIME_HOUR}:${TIME_MINUTE}:${TIME_SECOND}" )
2018-05-22 23:20:41 +03:00
add_subdirectory ( src )
2018-08-10 00:33:38 +03:00
2018-10-24 20:23:07 +03:00
if ( UNIX )
# Packaging
set ( CPACK_COMPONENTS_ALL common vpnserver vpnclient vpnbridge vpncmd )
set ( CPACK_PACKAGE_DIRECTORY ${ BUILD_DIRECTORY } )
set ( CPACK_PACKAGE_VERSION ${ PROJECT_VERSION } )
set ( CPACK_PACKAGE_VENDOR "SoftEther" )
set ( CPACK_PACKAGE_NAME "softether" )
2018-11-19 02:13:59 +03:00
set ( CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_DIRECTORY}/description" )
2018-10-24 20:23:07 +03:00
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." )
# DEB
2018-11-19 02:13:59 +03:00
if ( BUILD_TYPE STREQUAL "Debug" )
2018-10-24 20:23:07 +03:00
set ( CPACK_DEBIAN_PACKAGE_DEBUG ON )
endif ( )
set ( CPACK_DEB_COMPONENT_INSTALL ON )
set ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" )
set ( CPACK_DEBIAN_PACKAGE_SECTION "net" )
set ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Unknown" )
# RPM
set ( CPACK_RPM_COMPONENT_INSTALL ON )
set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" )
set ( CPACK_RPM_PACKAGE_GROUP "Applications/Internet" )
2019-01-14 06:42:15 +03:00
set ( CPACK_RPM_PACKAGE_LICENSE "ASL 2.0" )
2018-10-24 20:23:07 +03:00
2020-06-30 06:11:05 +03:00
# Exclude system directories
if ( CPACK_GENERATOR STREQUAL "RPM" )
execute_process (
C O M M A N D r p m - q l f i l e s y s t e m
C O M M A N D t r \ n \ ;
O U T P U T _ V A R I A B L E C P A C K _ R P M _ E X C L U D E _ F R O M _ A U T O _ F I L E L I S T _ A D D I T I O N
E R R O R _ Q U I E T )
endif ( )
2018-10-24 20:23:07 +03:00
include ( CPack )
2018-10-23 22:32:41 +03:00
endif ( )