diff options
author | Brad King <brad.king@kitware.com> | 2020-11-20 15:15:53 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-20 15:15:53 (GMT) |
commit | 3bc549540e117a949707c51fcdf110fdc51e3d93 (patch) | |
tree | e736abff616bf3c411881074a156fdae490f6f71 /Tests/RunCMake/configure_file/UseSourcePermissions.cmake | |
parent | 64dc4efc511f766d0a099df717e2f35f9eccabce (diff) | |
parent | bf241bcc1e5cda69775c05022e146a7f4f76b41b (diff) | |
download | CMake-3bc549540e117a949707c51fcdf110fdc51e3d93.zip CMake-3bc549540e117a949707c51fcdf110fdc51e3d93.tar.gz CMake-3bc549540e117a949707c51fcdf110fdc51e3d93.tar.bz2 |
Merge branch 'master' into FindGTest-revert-no-release
Diffstat (limited to 'Tests/RunCMake/configure_file/UseSourcePermissions.cmake')
-rw-r--r-- | Tests/RunCMake/configure_file/UseSourcePermissions.cmake | 40 |
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() |