summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/configure_file/UseSourcePermissions.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/configure_file/UseSourcePermissions.cmake')
-rw-r--r--Tests/RunCMake/configure_file/UseSourcePermissions.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/Tests/RunCMake/configure_file/UseSourcePermissions.cmake b/Tests/RunCMake/configure_file/UseSourcePermissions.cmake
new file mode 100644
index 0000000..f7aedd1
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UseSourcePermissions.cmake
@@ -0,0 +1,40 @@
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt
+ ${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt
+ USE_SOURCE_PERMISSIONS
+)
+
+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_SOURCE_DIR}/sourcefile.txt"
+ OUTPUT_VARIABLE output1
+ )
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -f %Lp "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt"
+ OUTPUT_VARIABLE output2
+ )
+ elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt"
+ OUTPUT_VARIABLE output1
+ )
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt"
+ OUTPUT_VARIABLE output2
+ )
+ else()
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -c %a "${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt"
+ OUTPUT_VARIABLE output1
+ )
+ execute_process(COMMAND "${STAT_EXECUTABLE}" -c %a "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt"
+ OUTPUT_VARIABLE output2
+ )
+ endif()
+
+ if (NOT output1 EQUAL output2)
+ message(FATAL_ERROR "configure file has different permissions source "
+ "permissions: ${output1} generated permissions: ${output2}")
+ endif()
+
+endif()