1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-23 01:49: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

@ -143,7 +143,7 @@
#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