From d7328953bab6ebaab61512641ba994fbdab05fb7 Mon Sep 17 00:00:00 2001 From: xixiha5230 <31526189+xixiha5230@users.noreply.github.com> Date: Sat, 24 Feb 2024 17:57:12 +0800 Subject: [PATCH] Use CMake string(TIMESTAMP) for portable compile timestamp The previous usage of the date command is not portable across different platforms. date is not guaranteed to be available and the format varies. Replace it with CMake's built-in string(TIMESTAMP) command which generates a string with the given timestamp format independent of the platform. This commit changes it to use "%y%m%d" format for a YYMMDD timestamp commonly used for compilation. --- core/src/main/cpp/CMakeLists.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/src/main/cpp/CMakeLists.txt b/core/src/main/cpp/CMakeLists.txt index 357b3363..b7de87df 100644 --- a/core/src/main/cpp/CMakeLists.txt +++ b/core/src/main/cpp/CMakeLists.txt @@ -28,11 +28,7 @@ string (REGEX REPLACE "[\n\t\r]" "" CURRENT_BRANCH ${CURRENT_BRANCH}) message(STATUS "git current branch = ${CURRENT_BRANCH}") # 获取生成时间 -execute_process( - COMMAND date +"%y%m%d" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE COMPILE_TIME -) +string(TIMESTAMP COMPILE_TIME "%y%m%d") string (REGEX REPLACE "[\n\t\r]" "" COMPILE_TIME ${COMPILE_TIME}) string(REGEX REPLACE "\"" "" COMPILE_TIME ${COMPILE_TIME}) @@ -70,4 +66,4 @@ include_directories("${GO_SOURCE}") link_directories("${GO_OUTPUT_BASE}/${CMAKE_ANDROID_ARCH_ABI}") add_library(bridge SHARED main.c jni_helper.c bridge_helper.c) -target_link_libraries(bridge log clash) \ No newline at end of file +target_link_libraries(bridge log clash)