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

CMake: build targets with versioning info on Windows

This commit is contained in:
Davide Beatrici 2018-11-27 05:26:21 +01:00
parent 0642427080
commit 6903f9b89f
9 changed files with 93 additions and 62 deletions

View File

@ -45,6 +45,17 @@ endif()
configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY) configure_file("${TOP_DIRECTORY}/AUTHORS.TXT" "${TOP_DIRECTORY}/src/bin/hamcore/authors.txt" COPYONLY)
# 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}")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
add_subdirectory(src) add_subdirectory(src)

View File

@ -54,24 +54,13 @@ cmake_host_system_information(RESULT BUILDER_HOSTNAME QUERY HOSTNAME)
add_definitions(-DBUILD_PLACE="${BUILDER_HOSTNAME}") add_definitions(-DBUILD_PLACE="${BUILDER_HOSTNAME}")
# Date and time # Remove leading 0 from date and time
string(TIMESTAMP BUILD_DAY "%d" UTC) string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_DAY "${DATE_DAY}")
string(TIMESTAMP BUILD_MONTH "%m" UTC) string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_MONTH "${DATE_MONTH}")
string(TIMESTAMP BUILD_YEAR "%Y" UTC) string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_YEAR "${DATE_YEAR}")
string(TIMESTAMP BUILD_HOUR "%H" UTC) string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_HOUR "${TIME_HOUR}")
string(TIMESTAMP BUILD_MINUTE "%M" UTC) string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_MINUTE "${TIME_MINUTE}")
string(TIMESTAMP BUILD_SECOND "%S" UTC) string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_SECOND "${TIME_SECOND}")
## Remove leading 0
string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_DAY "${BUILD_DAY}")
string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_MONTH "${BUILD_MONTH}")
string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_YEAR "${BUILD_YEAR}")
string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_HOUR "${BUILD_HOUR}")
string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_MINUTE "${BUILD_MINUTE}")
string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_SECOND "${BUILD_SECOND}")
message(STATUS "Build date: ${BUILD_DAY}/${BUILD_MONTH}/${BUILD_YEAR}")
message(STATUS "Build time: ${BUILD_HOUR}:${BUILD_MINUTE}:${BUILD_SECOND}")
add_definitions(-DBUILD_DATE_D=${BUILD_DAY} -DBUILD_DATE_M=${BUILD_MONTH} -DBUILD_DATE_Y=${BUILD_YEAR}) 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}) add_definitions(-DBUILD_DATE_HO=${BUILD_HOUR} -DBUILD_DATE_MI=${BUILD_MINUTE} -DBUILD_DATE_SE=${BUILD_SECOND})

View File

@ -1,10 +1,7 @@
set(VPNBRIDGE_SOURCES vpnbridge.c) set(COMPONENT_NAME "Bridge")
set(COMPONENT_INTERNAL_NAME "vpnbridge")
if(WIN32) add_executable(vpnbridge vpnbridge.c)
set(VPNBRIDGE_SOURCES ${VPNBRIDGE_SOURCES} vpnbridge.rc)
endif()
add_executable(vpnbridge ${VPNBRIDGE_SOURCES})
set_target_properties(vpnbridge set_target_properties(vpnbridge
PROPERTIES PROPERTIES
@ -18,6 +15,12 @@ if(WIN32)
PROPERTIES PROPERTIES
PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
get_filename_component(COMPONENT_FILE_NAME vpnbridge NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpnbridge.rc")
target_sources(vpnbridge PRIVATE vpnbridge.rc "${CMAKE_BINARY_DIR}/VerScript/vpnbridge.rc")
endif() endif()
target_link_libraries(vpnbridge cedar mayaqua) target_link_libraries(vpnbridge cedar mayaqua)

View File

@ -1,10 +1,7 @@
set(VPNCLIENT_SOURCES vpncsvc.c vpncsvc.h) set(COMPONENT_NAME "Client")
set(COMPONENT_INTERNAL_NAME "vpnclient")
if(WIN32) add_executable(vpnclient vpncsvc.c vpncsvc.h)
set(VPNCLIENT_SOURCES ${VPNCLIENT_SOURCES} vpnclient.rc)
endif()
add_executable(vpnclient ${VPNCLIENT_SOURCES})
set_target_properties(vpnclient set_target_properties(vpnclient
PROPERTIES PROPERTIES
@ -18,6 +15,12 @@ if(WIN32)
PROPERTIES PROPERTIES
PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
get_filename_component(COMPONENT_FILE_NAME vpnclient NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpnclient.rc")
target_sources(vpnclient PRIVATE vpnclient.rc "${CMAKE_BINARY_DIR}/VerScript/vpnclient.rc")
endif() endif()
target_link_libraries(vpnclient cedar mayaqua) target_link_libraries(vpnclient cedar mayaqua)

View File

@ -1,10 +1,7 @@
set(VPNCMD_SOURCES vpncmd.c) set(COMPONENT_NAME "Command Line Management Utility")
set(COMPONENT_INTERNAL_NAME "vpncmd")
if(WIN32) add_executable(vpncmd vpncmd.c)
set(VPNCMD_SOURCES ${VPNCMD_SOURCES} vpncmd.rc)
endif()
add_executable(vpncmd ${VPNCMD_SOURCES})
set_target_properties(vpncmd set_target_properties(vpncmd
PROPERTIES PROPERTIES
@ -18,6 +15,12 @@ if(WIN32)
PROPERTIES PROPERTIES
PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
get_filename_component(COMPONENT_FILE_NAME vpncmd NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpncmd.rc")
target_sources(vpncmd PRIVATE vpncmd.rc "${CMAKE_BINARY_DIR}/VerScript/vpncmd.rc")
endif() endif()
target_link_libraries(vpncmd cedar mayaqua) target_link_libraries(vpncmd cedar mayaqua)

View File

@ -2,16 +2,23 @@ if(NOT WIN32)
message(FATAL_ERROR "VPN Client Manager is available only for Windows.") message(FATAL_ERROR "VPN Client Manager is available only for Windows.")
endif() endif()
set(VPNCMGR_SOURCES vpncmgr.c vpncmgr.rc) set(COMPONENT_NAME "Client Manager")
set(COMPONENT_INTERNAL_NAME "vpncmgr")
add_executable(vpncmgr WIN32 vpncmgr.c vpncmgr.rc)
get_filename_component(COMPONENT_FILE_NAME vpncmgr NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpncmgr.rc")
target_sources(vpncmgr PRIVATE "${CMAKE_BINARY_DIR}/VerScript/vpncmgr.rc")
if(${COMPILER_ARCHITECTURE} STREQUAL "x64") if(${COMPILER_ARCHITECTURE} STREQUAL "x64")
set(VPNCMGR_SOURCES ${VPNCMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest) target_sources(vpncmgr PRIVATE "${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest")
else() else()
set(VPNCMGR_SOURCES ${VPNCMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest) target_sources(vpncmgr PRIVATE "${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest")
endif() endif()
add_executable(vpncmgr WIN32 ${VPNCMGR_SOURCES})
set_target_properties(vpncmgr set_target_properties(vpncmgr
PROPERTIES PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"

View File

@ -1,10 +1,7 @@
set(VPNSERVER_SOURCES vpnserver.c) set(COMPONENT_NAME "Server")
set(COMPONENT_INTERNAL_NAME "vpnserver")
if(WIN32) add_executable(vpnserver vpnserver.c)
set(VPNSERVER_SOURCES ${VPNSERVER_SOURCES} vpnserver.rc)
endif()
add_executable(vpnserver ${VPNSERVER_SOURCES})
set_target_properties(vpnserver set_target_properties(vpnserver
PROPERTIES PROPERTIES
@ -18,6 +15,12 @@ if(WIN32)
PROPERTIES PROPERTIES
PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
get_filename_component(COMPONENT_FILE_NAME vpnserver NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpnserver.rc")
target_sources(vpnserver PRIVATE vpnserver.rc "${CMAKE_BINARY_DIR}/VerScript/vpnserver.rc")
endif() endif()
target_link_libraries(vpnserver cedar mayaqua) target_link_libraries(vpnserver cedar mayaqua)

View File

@ -2,16 +2,23 @@ if(NOT WIN32)
message(FATAL_ERROR "VPN Server Manager is available only for Windows.") message(FATAL_ERROR "VPN Server Manager is available only for Windows.")
endif() endif()
set(VPNSMGR_SOURCES vpnsmgr.c vpnsmgr.rc) set(COMPONENT_NAME "Server Manager")
set(COMPONENT_INTERNAL_NAME "vpnsmgr")
add_executable(vpnsmgr WIN32 vpnsmgr.c vpnsmgr.rc)
get_filename_component(COMPONENT_FILE_NAME vpnsmgr NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpnsmgr.rc")
target_sources(vpnsmgr PRIVATE "${CMAKE_BINARY_DIR}/VerScript/vpnsmgr.rc")
if(${COMPILER_ARCHITECTURE} STREQUAL "x64") if(${COMPILER_ARCHITECTURE} STREQUAL "x64")
set(VPNSMGR_SOURCES ${VPNSMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest) target_sources(vpnsmgr PRIVATE "${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest")
else() else()
set(VPNSMGR_SOURCES ${VPNSMGR_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest) target_sources(vpnsmgr PRIVATE "${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest")
endif() endif()
add_executable(vpnsmgr WIN32 ${VPNSMGR_SOURCES})
set_target_properties(vpnsmgr set_target_properties(vpnsmgr
PROPERTIES PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ARCHIVE_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"

View File

@ -1,14 +1,7 @@
set(VPNTEST_SOURCES vpntest.c vpntest.h) set(COMPONENT_NAME "Testing Utility")
set(COMPONENT_INTERNAL_NAME "vpntest")
if(WIN32) add_executable(vpntest vpntest.c vpntest.h)
if(${COMPILER_ARCHITECTURE} STREQUAL "x64")
set(VPNTEST_SOURCES ${VPNTEST_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest)
else()
set(VPNTEST_SOURCES ${VPNTEST_SOURCES} ${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest)
endif()
endif()
add_executable(vpntest ${VPNTEST_SOURCES})
set_target_properties(vpntest set_target_properties(vpntest
PROPERTIES PROPERTIES
@ -22,6 +15,18 @@ if(WIN32)
PROPERTIES PROPERTIES
PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}"
) )
get_filename_component(COMPONENT_FILE_NAME vpntest NAME)
set(COMPONENT_FILE_NAME "${COMPONENT_FILE_NAME}.exe")
configure_file("${TOP_DIRECTORY}/src/BuildFiles/VerScript/ver.rc" "${CMAKE_BINARY_DIR}/VerScript/vpntest.rc")
target_sources(vpntest PRIVATE vpntest.rc "${CMAKE_BINARY_DIR}/VerScript/vpntest.rc")
if(${COMPILER_ARCHITECTURE} STREQUAL "x64")
target_sources(vpntest PRIVATE "${TOP_DIRECTORY}/src/BuildFiles/Manifests/x64_user.manifest")
else()
target_sources(vpntest PRIVATE "${TOP_DIRECTORY}/src/BuildFiles/Manifests/x86_user.manifest")
endif()
endif() endif()
target_link_libraries(vpntest cedar mayaqua) target_link_libraries(vpntest cedar mayaqua)