1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-26 19:39:53 +03:00

CMake: set build info as compiler macros

This commit is contained in:
Davide Beatrici 2018-08-27 05:50:40 +02:00
parent c21f427fc6
commit 9d601c2745
2 changed files with 63 additions and 30 deletions

View File

@ -18,3 +18,36 @@ target_link_libraries(cedar ${LIB_READLINE} ${CURSES_LIBRARIES})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
target_link_libraries(cedar pcap) target_link_libraries(cedar pcap)
endif() endif()
# Version
add_definitions(-DCEDAR_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} -DCEDAR_VERSION_MINOR=${PROJECT_VERSION_MINOR} -DCEDAR_VERSION_BUILD=${PROJECT_VERSION_PATCH})
# Builder
if(UNIX)
add_definitions(-DBUILDER_NAME="$ENV{USER}")
elseif(WIN32)
add_definitions(-DBUILDER_NAME="$ENV{USERNAME}")
endif()
cmake_host_system_information(RESULT BUILDER_HOSTNAME QUERY HOSTNAME)
add_definitions(-DBUILD_PLACE="${BUILDER_HOSTNAME}")
# Date and time
string(TIMESTAMP BUILD_DAY "%d" UTC)
string(TIMESTAMP BUILD_MONTH "%m" UTC)
string(TIMESTAMP BUILD_YEAR "%Y" UTC)
string(TIMESTAMP BUILD_HOUR "%H" UTC)
string(TIMESTAMP BUILD_MINUTE "%M" UTC)
string(TIMESTAMP BUILD_SECOND "%S" UTC)
## Remove leading 0
string(REGEX REPLACE "^0" "" BUILD_DAY "${BUILD_DAY}")
string(REGEX REPLACE "^0" "" BUILD_MONTH "${BUILD_MONTH}")
string(REGEX REPLACE "^0" "" BUILD_YEAR "${BUILD_YEAR}")
string(REGEX REPLACE "^0" "" BUILD_HOUR "${BUILD_HOUR}")
string(REGEX REPLACE "^0" "" BUILD_MINUTE "${BUILD_MINUTE}")
string(REGEX REPLACE "^0" "" BUILD_SECOND "${BUILD_SECOND}")
add_definitions(-DBUILD_DATE_D=${BUILD_DAY} -DBUILD_DATE_M=${BUILD_MONTH} -DBUILD_DATE_Y=${BUILD_YEAR})
add_definitions(-DBUILD_DATE_HO=${BUILD_HOUR} -DBUILD_DATE_MI=${BUILD_MINUTE} -DBUILD_DATE_SE=${BUILD_SECOND})

View File

@ -135,18 +135,18 @@
// Version number // Version number
#ifndef CEDAR_VERSION_MAJOR #ifndef CEDAR_VERSION_MAJOR
#define CEDAR_VERSION_MAJOR 0 #define CEDAR_VERSION_MAJOR 0
#endif // CEDAR_VERSION_MAJOR #endif // CEDAR_VERSION_MAJOR
#ifndef CEDAR_VERSION_MINOR #ifndef CEDAR_VERSION_MINOR
#define CEDAR_VERSION_MINOR 0 #define CEDAR_VERSION_MINOR 0
#endif // CEDAR_VER_MINOR #endif // CEDAR_VER_MINOR
// Build Number // Build number
#ifndef CEDAR_VERSION_BUILD #ifndef CEDAR_VERSION_BUILD
#define CEDAR_VERSION_BUILD 0 #define CEDAR_VERSION_BUILD 0
#endif // CEDAR_VERSION_BUILD #endif // CEDAR_VERSION_BUILD
// Beta number // Beta number
//#define BETA_NUMBER 3 //#define BETA_NUMBER 3
@ -156,38 +156,38 @@
// Specify the name of the person in charge building // Specify the name of the person in charge building
#ifndef BUILDER_NAME #ifndef BUILDER_NAME
#define BUILDER_NAME "Unknown" #define BUILDER_NAME "Unknown"
#endif // BUILDER_NAME #endif // BUILDER_NAME
// Specify the location to build // Specify the location to build
#ifndef BUILD_PLACE #ifndef BUILD_PLACE
#define BUILD_PLACE "Unknown" #define BUILD_PLACE "Unknown"
#endif // BUILD_PLACE #endif // BUILD_PLACE
// Specifies the build date // Specifies the build date
#ifndef BUILD_DATE_Y #ifndef BUILD_DATE_Y
#define BUILD_DATE_Y 1970 #define BUILD_DATE_Y 1970
#endif // BUILD_DATE_Y #endif // BUILD_DATE_Y
#ifndef BUILD_DATE_M #ifndef BUILD_DATE_M
#define BUILD_DATE_M 1 #define BUILD_DATE_M 1
#endif // BUILD_DATE_M #endif // BUILD_DATE_M
#ifndef BUILD_DATE_D #ifndef BUILD_DATE_D
#define BUILD_DATE_D 1 #define BUILD_DATE_D 1
#endif // BUILD_DATE_D #endif // BUILD_DATE_D
#ifndef BUILD_DATE_HO #ifndef BUILD_DATE_HO
#define BUILD_DATE_HO 0 #define BUILD_DATE_HO 0
#endif // BUILD_DATE_HO #endif // BUILD_DATE_HO
#ifndef BUILD_DATE_MI #ifndef BUILD_DATE_MI
#define BUILD_DATE_MI 0 #define BUILD_DATE_MI 0
#endif // BUILD_DATE_MI #endif // BUILD_DATE_MI
#ifndef BUILD_DATE_SE #ifndef BUILD_DATE_SE
#define BUILD_DATE_SE 0 #define BUILD_DATE_SE 0
#endif // BUILD_DATE_SE #endif // BUILD_DATE_SE
// Tolerable time difference // Tolerable time difference
#define ALLOW_TIMESTAMP_DIFF (UINT64)(3 * 24 * 60 * 60 * 1000) #define ALLOW_TIMESTAMP_DIFF (UINT64)(3 * 24 * 60 * 60 * 1000)