summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake
diff options
context:
space:
mode:
authorAsit Dhal <dhal.asitk@gmail.com>2020-10-28 10:07:57 (GMT)
committerAsit Dhal <dhal.asitk@gmail.com>2020-12-21 11:16:16 (GMT)
commitc3385dd8bd7c78cf03d7e52ae0f49e8216cdaaea (patch)
tree429c6d6e88db90402670eef5e288f7f4a1bb29ca /Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake
parentc89514a6a47b678dddb703c302def4fe56abe275 (diff)
downloadCMake-c3385dd8bd7c78cf03d7e52ae0f49e8216cdaaea.zip
CMake-c3385dd8bd7c78cf03d7e52ae0f49e8216cdaaea.tar.gz
CMake-c3385dd8bd7c78cf03d7e52ae0f49e8216cdaaea.tar.bz2
file(GENERATE): Support options to manipulate file permissions
Fixes: #15653
Diffstat (limited to 'Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake')
-rw-r--r--Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake36
1 files changed, 36 insertions, 0 deletions
diff --git a/Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake b/Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake
new file mode 100644
index 0000000..a87e916
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CustomFilePermissionsVerify.cmake
@@ -0,0 +1,36 @@
+if(NOT EXISTS "${generatedFile}")
+ message(SEND_ERROR "Missing file:\n ${generatedFile}")
+endif()
+
+if (UNIX)
+ find_program(STAT_EXECUTABLE NAMES stat)
+ if(NOT STAT_EXECUTABLE)
+ return()
+ endif()
+
+ if (CMAKE_HOST_SYSTEM_NAME MATCHES "FreeBSD")
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -f %Lp "${generatedFile}"
+ OUTPUT_VARIABLE output
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ COMMAND_ERROR_IS_FATAL ANY
+ )
+ elseif (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${generatedFile}"
+ OUTPUT_VARIABLE output
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ COMMAND_ERROR_IS_FATAL ANY
+ )
+ else()
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -c %a "${generatedFile}"
+ OUTPUT_VARIABLE output
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ COMMAND_ERROR_IS_FATAL ANY
+ )
+ endif()
+
+ if (NOT output EQUAL "711")
+ message(SEND_ERROR "file generate has different permissions source "
+ "permissions: \"${output}\" desired permissions: \"711\"")
+ endif()
+
+endif()