cmake: use date -r on more BSDs

- macOS `date` is based on FreeBSD while `-r` is from historical BSD
- GNU `date` may not be installed or installed as `gdate`
This commit is contained in:
Jan Beich 2023-06-23 19:25:20 +00:00
parent 6ca7f92b0e
commit c3700819a6

View File

@ -24,7 +24,7 @@ execute_process(
string(REPLACE "\n" "" TZ_COMMIT_TIME "${TZ_COMMIT_TIME}")
if (APPLE)
if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
set(VERSION_COMMAND ${GNU_DATE} -r ${TZ_COMMIT_TIME} +%y%m%d)
else ()
set(VERSION_COMMAND ${GNU_DATE} +%y%m%d --date=@${TZ_COMMIT_TIME})