diff options
Diffstat (limited to 'Tests/RunCMake/configure_file/SourcePermissions.cmake')
-rw-r--r-- | Tests/RunCMake/configure_file/SourcePermissions.cmake | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Tests/RunCMake/configure_file/SourcePermissions.cmake b/Tests/RunCMake/configure_file/SourcePermissions.cmake new file mode 100644 index 0000000..50330fc --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissions.cmake @@ -0,0 +1,34 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt + ${CMAKE_CURRENT_BINARY_DIR}/sourcefile-source-permissions.txt + FILE_PERMISSIONS + OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ +) + +if (UNIX) + find_program(STAT_EXECUTABLE NAMES stat) + if(NOT STAT_EXECUTABLE) + return() + endif() + + if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + execute_process(COMMAND "${STAT_EXECUTABLE}" -f %Lp "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-source-permissions.txt" + OUTPUT_VARIABLE output + ) + elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") + execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-source-permissions.txt" + OUTPUT_VARIABLE output + ) + else() + execute_process(COMMAND "${STAT_EXECUTABLE}" -c %a "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-source-permissions.txt" + OUTPUT_VARIABLE output + ) + endif() + + if (NOT output EQUAL "554") + message(FATAL_ERROR "configure file has different permissions than " + "desired, generated permissions: ${output}") + endif() + +endif() |