diff options
author | Asit Dhal <dhal.asitk@gmail.com> | 2020-10-04 17:44:31 (GMT) |
---|---|---|
committer | Asit Dhal <dhal.asitk@gmail.com> | 2020-10-24 10:00:47 (GMT) |
commit | 03ad0e61c19304ae145cfa0683b43d9756d37ff5 (patch) | |
tree | 4b80c6107710ce8e1ccca1de4ec03ac9232ba024 /Tests/RunCMake/configure_file | |
parent | 5988a4deea67ed122b30c2c0437f70e074273789 (diff) | |
download | CMake-03ad0e61c19304ae145cfa0683b43d9756d37ff5.zip CMake-03ad0e61c19304ae145cfa0683b43d9756d37ff5.tar.gz CMake-03ad0e61c19304ae145cfa0683b43d9756d37ff5.tar.bz2 |
configure_file: Add option for user defined permissions
User defined permissions and options to copy permissions are
implemented.
Fixes: #20866
Diffstat (limited to 'Tests/RunCMake/configure_file')
21 files changed, 135 insertions, 0 deletions
diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake index 71694fb..0a2e3f9 100644 --- a/Tests/RunCMake/configure_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake @@ -16,6 +16,13 @@ run_cmake(NewLineStyle-WrongArg) run_cmake(NewLineStyle-ValidArg) run_cmake(NewLineStyle-COPYONLY) run_cmake(NoSourcePermissions) +run_cmake(SourcePermissionsInvalidArg-1) +run_cmake(SourcePermissionsInvalidArg-2) +run_cmake(SourcePermissionsInvalidArg-3) +run_cmake(SourcePermissionsInvalidArg-4) +run_cmake(SourcePermissionsInvalidArg-5) +run_cmake(UseSourcePermissions) +run_cmake(SourcePermissions) if(RunCMake_GENERATOR MATCHES "Make") # Use a single build tree for a few tests without cleaning. diff --git a/Tests/RunCMake/configure_file/SourcePermissions-result.txt b/Tests/RunCMake/configure_file/SourcePermissions-result.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissions-result.txt diff --git a/Tests/RunCMake/configure_file/SourcePermissions-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissions-stderr.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissions-stderr.txt 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() diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1-result.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1-stderr.txt new file mode 100644 index 0000000..d483d34 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at SourcePermissionsInvalidArg-1.cmake:1 \(configure_file\): + configure_file given both USE_SOURCE_PERMISSIONS and NO_SOURCE_PERMISSIONS. + Only one option allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1.cmake b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1.cmake new file mode 100644 index 0000000..4969880 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-1.cmake @@ -0,0 +1,5 @@ +configure_file(sourcefile.txt + ${CMAKE_CURRENT_BINARY_DIR}/sourcefile.txt + NO_SOURCE_PERMISSIONS + USE_SOURCE_PERMISSIONS +) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2-result.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2-stderr.txt new file mode 100644 index 0000000..2fcfe58 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at SourcePermissionsInvalidArg-2.cmake:1 \(configure_file\): + configure_file given both FILE_PERMISSIONS and NO_SOURCE_PERMISSIONS. Only + one option allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2.cmake b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2.cmake new file mode 100644 index 0000000..8a3fb87 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-2.cmake @@ -0,0 +1,5 @@ +configure_file(sourcefile.txt + ${CMAKE_CURRENT_BINARY_DIR}/sourcefile.txt + NO_SOURCE_PERMISSIONS + FILE_PERMISSIONS OWNER_READ +) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3-result.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3-stderr.txt new file mode 100644 index 0000000..29fae1b --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at SourcePermissionsInvalidArg-3.cmake:1 \(configure_file\): + configure_file given both FILE_PERMISSIONS and USE_SOURCE_PERMISSIONS. + Only one option allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3.cmake b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3.cmake new file mode 100644 index 0000000..78ecb0f --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-3.cmake @@ -0,0 +1,5 @@ +configure_file(sourcefile.txt + ${CMAKE_CURRENT_BINARY_DIR}/sourcefile.txt + USE_SOURCE_PERMISSIONS + FILE_PERMISSIONS OWNER_READ +) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4-result.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4-stderr.txt new file mode 100644 index 0000000..7d477cb --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at SourcePermissionsInvalidArg-4.cmake:1 \(configure_file\): + configure_file given FILE_PERMISSIONS without any options. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4.cmake b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4.cmake new file mode 100644 index 0000000..308b455 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-4.cmake @@ -0,0 +1,4 @@ +configure_file(sourcefile.txt + ${CMAKE_CURRENT_BINARY_DIR}/sourcefile.txt + FILE_PERMISSIONS +) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5-result.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5-stderr.txt new file mode 100644 index 0000000..7cab120 --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at SourcePermissionsInvalidArg-5.cmake:1 \(configure_file\): + configure_file given invalid permission "OWNER_RX","GROUP_RWX". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5.cmake b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5.cmake new file mode 100644 index 0000000..15c6f9a --- /dev/null +++ b/Tests/RunCMake/configure_file/SourcePermissionsInvalidArg-5.cmake @@ -0,0 +1,6 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt + ${CMAKE_CURRENT_BINARY_DIR}/sourcefile-source-permissions.txt + FILE_PERMISSIONS + OWNER_READ OWNER_RX + GROUP_RWX +) 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() diff --git a/Tests/RunCMake/configure_file/sourcefile.txt b/Tests/RunCMake/configure_file/sourcefile.txt new file mode 100644 index 0000000..2296808 --- /dev/null +++ b/Tests/RunCMake/configure_file/sourcefile.txt @@ -0,0 +1 @@ +an empty file |