From 4ceb0ca59ea13f1f3f76414a214fbbd9ecb57707 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 26 Mar 2021 21:25:51 +1100 Subject: Tests: Remove redundant files for configure_file() tests --- Tests/RunCMake/configure_file/SourcePermissions-result.txt | 0 Tests/RunCMake/configure_file/SourcePermissions-stderr.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Tests/RunCMake/configure_file/SourcePermissions-result.txt delete mode 100644 Tests/RunCMake/configure_file/SourcePermissions-stderr.txt diff --git a/Tests/RunCMake/configure_file/SourcePermissions-result.txt b/Tests/RunCMake/configure_file/SourcePermissions-result.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Tests/RunCMake/configure_file/SourcePermissions-stderr.txt b/Tests/RunCMake/configure_file/SourcePermissions-stderr.txt deleted file mode 100644 index e69de29..0000000 -- cgit v0.12 From 635431a0c9696c8c8be5d94e6afdc044afd5384c Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 26 Mar 2021 22:17:01 +1100 Subject: Tests: Check host platform instead of target for running stat --- Tests/RunCMake/File_Generate/UseSourcePermissionsVerify.cmake | 2 +- Tests/RunCMake/configure_file/SourcePermissions.cmake | 6 +++--- Tests/RunCMake/configure_file/UseSourcePermissions.cmake | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/RunCMake/File_Generate/UseSourcePermissionsVerify.cmake b/Tests/RunCMake/File_Generate/UseSourcePermissionsVerify.cmake index 8b30f96..31494d5 100644 --- a/Tests/RunCMake/File_Generate/UseSourcePermissionsVerify.cmake +++ b/Tests/RunCMake/File_Generate/UseSourcePermissionsVerify.cmake @@ -2,7 +2,7 @@ if(NOT EXISTS "${generatedFile}") message(SEND_ERROR "Missing generated file:\n ${generatedFile}") endif() -if (UNIX) +if (CMAKE_HOST_UNIX) find_program(STAT_EXECUTABLE NAMES stat) if(NOT STAT_EXECUTABLE) return() diff --git a/Tests/RunCMake/configure_file/SourcePermissions.cmake b/Tests/RunCMake/configure_file/SourcePermissions.cmake index 50330fc..c4d3d61 100644 --- a/Tests/RunCMake/configure_file/SourcePermissions.cmake +++ b/Tests/RunCMake/configure_file/SourcePermissions.cmake @@ -6,17 +6,17 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt WORLD_READ ) -if (UNIX) +if (CMAKE_HOST_UNIX) find_program(STAT_EXECUTABLE NAMES stat) if(NOT STAT_EXECUTABLE) return() endif() - if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + if (CMAKE_HOST_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") + elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-source-permissions.txt" OUTPUT_VARIABLE output ) diff --git a/Tests/RunCMake/configure_file/UseSourcePermissions.cmake b/Tests/RunCMake/configure_file/UseSourcePermissions.cmake index f7aedd1..65e5954 100644 --- a/Tests/RunCMake/configure_file/UseSourcePermissions.cmake +++ b/Tests/RunCMake/configure_file/UseSourcePermissions.cmake @@ -3,20 +3,20 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt USE_SOURCE_PERMISSIONS ) -if (UNIX) +if (CMAKE_HOST_UNIX) find_program(STAT_EXECUTABLE NAMES stat) if(NOT STAT_EXECUTABLE) return() endif() - if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + if (CMAKE_HOST_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") + elseif (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt" OUTPUT_VARIABLE output1 ) -- cgit v0.12 From 900184616afd01cf44115f1db777e05d97776306 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 26 Mar 2021 22:06:20 +1100 Subject: Cleanup: Fix misspelt name of local C++ variable --- Source/cmConfigureFileCommand.cxx | 14 +++++++------- Source/cmFileCommand.cxx | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index edd261d..12b2925 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -165,7 +165,7 @@ bool cmConfigureFileCommand(std::vector const& args, return false; } - mode_t permisiions = 0; + mode_t permissions = 0; if (filePermissions) { if (filePermissionOptions.empty()) { @@ -175,7 +175,7 @@ bool cmConfigureFileCommand(std::vector const& args, std::vector invalidOptions; for (auto const& e : filePermissionOptions) { - if (!cmFSPermissions::stringToModeT(e, permisiions)) { + if (!cmFSPermissions::stringToModeT(e, permissions)) { invalidOptions.push_back(e); } } @@ -197,14 +197,14 @@ bool cmConfigureFileCommand(std::vector const& args, } if (noSourcePermissions) { - permisiions |= cmFSPermissions::mode_owner_read; - permisiions |= cmFSPermissions::mode_owner_write; - permisiions |= cmFSPermissions::mode_group_read; - permisiions |= cmFSPermissions::mode_world_read; + permissions |= cmFSPermissions::mode_owner_read; + permissions |= cmFSPermissions::mode_owner_write; + permissions |= cmFSPermissions::mode_group_read; + permissions |= cmFSPermissions::mode_world_read; } if (!status.GetMakefile().ConfigureFile(inputFile, outputFile, copyOnly, - atOnly, escapeQuotes, permisiions, + atOnly, escapeQuotes, permissions, newLineStyle)) { status.SetError("Problem configuring file"); return false; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index f674833..4a28238 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2446,18 +2446,18 @@ bool HandleGenerateCommand(std::vector const& args, } } - mode_t permisiions = 0; + mode_t permissions = 0; if (arguments.NoSourcePermissions) { - permisiions |= cmFSPermissions::mode_owner_read; - permisiions |= cmFSPermissions::mode_owner_write; - permisiions |= cmFSPermissions::mode_group_read; - permisiions |= cmFSPermissions::mode_world_read; + permissions |= cmFSPermissions::mode_owner_read; + permissions |= cmFSPermissions::mode_owner_write; + permissions |= cmFSPermissions::mode_group_read; + permissions |= cmFSPermissions::mode_world_read; } if (!arguments.FilePermissions.empty()) { std::vector invalidOptions; for (auto const& e : arguments.FilePermissions) { - if (!cmFSPermissions::stringToModeT(e, permisiions)) { + if (!cmFSPermissions::stringToModeT(e, permissions)) { invalidOptions.push_back(e); } } @@ -2479,7 +2479,7 @@ bool HandleGenerateCommand(std::vector const& args, AddEvaluationFile(input, arguments.Target, arguments.Output, arguments.Condition, inputIsContent, - newLineStyle.GetCharacters(), permisiions, status); + newLineStyle.GetCharacters(), permissions, status); return true; } -- cgit v0.12 From 769ff05483fa92e63466839854c4f3f0142a4fb3 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 26 Mar 2021 22:02:28 +1100 Subject: Help: Clarify permission-related command options The previous docs did not make clear that at most only one of the three permissions-related options can be given for configure_file() or file(GENERATE) and that USE_SOURCE_PERMISSIONS is already the default behavior for these commands. Use consistent wording to refer to the input and output files for configure_file(). Add missing "versionadded" directives on some of these keywords. Use the consistent wording and keyword ordering between the configure_file(), file(GENERATE) and file(COPY) commands. --- Help/command/configure_file.rst | 37 ++++++++++++++++++++++--------------- Help/command/file.rst | 26 ++++++++++++++++++-------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/Help/command/configure_file.rst b/Help/command/configure_file.rst index 63ea84d..d00f08b 100644 --- a/Help/command/configure_file.rst +++ b/Help/command/configure_file.rst @@ -6,9 +6,9 @@ Copy a file to another location and modify its contents. .. code-block:: cmake configure_file( - [FILE_PERMISSIONS ...] + [NO_SOURCE_PERMISSIONS | USE_SOURCE_PERMISSIONS | + FILE_PERMISSIONS ...] [COPYONLY] [ESCAPE_QUOTES] [@ONLY] - [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS] [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) Copies an ```` file to an ```` file and substitutes @@ -75,8 +75,27 @@ The arguments are: If the path names an existing directory the output file is placed in that directory with the same file name as the input file. +``NO_SOURCE_PERMISSIONS`` + .. versionadded:: 3.19 + + Do not transfer the permissions of the input file to the output file. + The copied file permissions default to the standard 644 value + (-rw-r--r--). + +``USE_SOURCE_PERMISSIONS`` + .. versionadded:: 3.20 + + Transfer the permissions of the input file to the output file. + This is already the default behavior if none of the three permissions-related + keywords are given (``NO_SOURCE_PERMISSIONS``, ``USE_SOURCE_PERMISSIONS`` + or ``FILE_PERMISSIONS``). The ``USE_SOURCE_PERMISSIONS`` keyword mostly + serves as a way of making the intended behavior clearer at the call site. + ``FILE_PERMISSIONS ...`` - Use user provided permissions for the output file. + .. versionadded:: 3.20 + + Ignore the input file's permissions and use the specified ```` + for the output file instead. ``COPYONLY`` Copy the file without replacing any variable references or other @@ -89,18 +108,6 @@ The arguments are: Restrict variable replacement to references of the form ``@VAR@``. This is useful for configuring scripts that use ``${VAR}`` syntax. -``NO_SOURCE_PERMISSIONS`` - .. versionadded:: 3.19 - - Does not transfer the file permissions of the original file to the copy. - The copied file permissions default to the standard 644 value - (-rw-r--r--). - -``USE_SOURCE_PERMISSIONS`` - .. versionadded:: 3.20 - - Transfer the file permissions of the original file to the output file. - ``NEWLINE_STYLE