You type touch afile.txt in a directory that contains no files. what will be the effect?
File manipulation command. Show
This command is dedicated to file and path manipulation requiring access to the filesystem. For other path manipulation, handling only syntactic aspects, have a look at Synopsis¶Reading file(READ Reading¶file(READ Read content from a file called file(STRINGS Parse a list of ASCII strings from LENGTH_MAXIMUM Consider only strings of at most a given length. LENGTH_MINIMUM Consider only strings of at least a given length. LIMIT_COUNT Limit the number of distinct strings to be extracted. LIMIT_INPUT Limit the number of input bytes to read from the file. LIMIT_OUTPUT Limit the number of total bytes to store in the NEWLINE_CONSUME Treat newline characters ( NO_HEX_CONVERSION
Intel Hex and Motorola S-record files are automatically converted to binary while reading unless this option is given. REGEX Consider only strings that match the given regular expression, as described under string(REGEX). ENCODING New in version 3.1. Consider strings of a given encoding. Currently
supported encodings are: New in version 3.2: Added the For example, the code file(STRINGS myfile.txt myfile) stores a list in the variable file( Compute a cryptographic hash of the content of file(TIMESTAMP Compute a string representation of the modification time of See the file(GET_RUNTIME_DEPENDENCIES [RESOLVED_DEPENDENCIES_VAR New in version 3.16. Recursively get the list of libraries depended on by the given files. Please note that this sub-command is
not intended to be used in project mode. It is intended for use at install time, either from code generated by the install(CODE [[ file(GET_RUNTIME_DEPENDENCIES # ... ) ]]) The arguments are as follows: RESOLVED_DEPENDENCIES_VAR Name of the variable in which to store the list of resolved dependencies. UNRESOLVED_DEPENDENCIES_VAR Name of the variable in which to store the list of unresolved dependencies. If this variable is not specified, and there are any unresolved dependencies, an error is issued. CONFLICTING_DEPENDENCIES_PREFIX Variable prefix in which to store conflicting dependency information. Dependencies are conflicting if two files with the same name are found in two different directories. The list of filenames that conflict are
stored in EXECUTABLES List of executable files to read for dependencies. These are executables that are typically created with LIBRARIES List of library files to read for dependencies. These are libraries that are typically created with
MODULES List of loadable module files to read for dependencies. These are modules that are typically created with
DIRECTORIES List of additional directories to search for dependencies. On Linux platforms, these directories are searched if the dependency is not found in any of the other usual paths. If it is found in such a directory, a warning is issued, because it means that the file is incomplete (it does not list all of the directories that contain its dependencies). On Windows platforms, these directories are searched if the dependency is not found in any of the other search paths, but no warning is issued, because searching other paths is a normal part of Windows dependency resolution. On Apple platforms, this argument has no effect. BUNDLE_EXECUTABLE Executable to treat as the "bundle executable" when resolving libraries. On Apple platforms, this argument determines the value of The following arguments specify filters for including or excluding libraries to be resolved. See below for a full description of how they work. PRE_INCLUDE_REGEXES List of pre-include regexes through which to filter the names of not-yet-resolved dependencies. PRE_EXCLUDE_REGEXES List of pre-exclude regexes through which to filter the names of not-yet-resolved dependencies. POST_INCLUDE_REGEXES
List of post-include regexes through which to filter the names of resolved dependencies. POST_EXCLUDE_REGEXES List of post-exclude regexes through which to filter the names of resolved dependencies. POST_INCLUDE_FILES New in version 3.21. List of post-include filenames through which to filter the names of resolved dependencies. Symlinks are resolved when attempting to match these filenames. POST_EXCLUDE_FILES New in version 3.21. List of post-exclude filenames through which to filter the names of resolved dependencies. Symlinks are resolved when attempting to match these filenames. These arguments can be used to exclude unwanted system libraries when resolving the dependencies, or to include libraries from a specific directory. The filtering works as follows:
Different platforms have different rules for how dependencies are resolved. These specifics are described here. On Linux platforms, library resolution works as follows:
On Windows platforms, library resolution works as follows:
On Apple platforms, library resolution works as follows:
This function accepts several variables that determine which tool is used for dependency resolution: CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM¶Determines which operating system and executable format the files are built for. This could be one of several values:
If this variable is not specified, it is determined automatically by system introspection. CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL¶Determines the tool to use for dependency resolution. It could be one of several values, depending on the value of
If this variable is not specified, it is determined automatically by system introspection. CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND¶Determines the path to the tool to use for dependency
resolution. This is the actual path to If this variable is not specified, it is determined by the value of New in version 3.18: Use Writing¶file(WRITE Write If the file is a build input, use the file(TOUCH [ New in version 3.12. Create a file with no content if it does not yet exist. If the file already exists, its access and/or modification will be updated to the time when the function call is executed. Use TOUCH_NOCREATE to touch a file if it exists but not create it. If a file does not exist it will be silently ignored. With TOUCH and TOUCH_NOCREATE the contents of an existing file will not be modified. file(GENERATE OUTPUT output-file <INPUT input-file|CONTENT content> [CONDITION expression] [TARGET target] [NO_SOURCE_PERMISSIONS | USE_SOURCE_PERMISSIONS | FILE_PERMISSIONS Generate an output file for each build configuration supported by the current CONDITION Generate the output file for a particular configuration only if the condition is true. The condition must be either CONTENT Use the content given explicitly as input. INPUT Use the content from a given file as input. Changed in version 3.10: A relative path is treated with respect to the value of
OUTPUT Specify the output file name to generate. Use
generator expressions such as Changed in version 3.10: A relative path (after evaluating generator expressions) is treated with respect to the value of
TARGET New in version 3.19. Specify
which target to use when evaluating generator expressions that require a target for evaluation (e.g. NO_SOURCE_PERMISSIONS New in version 3.20. The generated file permissions default to the standard 644 value (-rw-r--r--). USE_SOURCE_PERMISSIONS New in version 3.20. Transfer the file permissions of the FILE_PERMISSIONS New in version 3.20. Use the specified permissions for the generated file. NEWLINE_STYLE New in version 3.20. Specify the newline style for the generated file. Specify Exactly one Note also that file(CONFIGURE OUTPUT output-file CONTENT content [ESCAPE_QUOTES] [@ONLY] [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) New in version 3.18. Generate an output file using the input given by The arguments are: OUTPUT Specify the output file name to generate. A relative path is treated with respect to the value of CONTENT
Use the content given explicitly as input. ESCAPE_QUOTES Escape any substituted quotes with backslashes (C-style). @ONLY Restrict variable replacement to references of the form NEWLINE_STYLE Specify the newline style for the output file. Specify Filesystem¶file(GLOB Generate a list of files that match the Changed in version 3.6: The results will be ordered lexicographically. On Windows and macOS, globbing is case-insensitive even if the underlying filesystem is case-sensitive (both filenames and globbing expressions are converted to lowercase before matching). On other platforms, globbing is case-sensitive. New in version 3.3: By default New in version 3.12: If the Note We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the
generated build system cannot know when to ask CMake to regenerate. The Examples of globbing expressions include: *.cxx - match all files with extension cxx *.vt? - match all files with extension vta,...,vtz f[3-5].txt - match files f3.txt, f4.txt, f5.txt The New in version 3.3: By default Examples of recursive globbing include: /dir/*.py - match all python files in /dir and subdirectories file(MAKE_DIRECTORY [ Create the given directories and their parents as needed. file(REMOVE [ Remove the given files. The Changed in version 3.15: Empty input paths are ignored with a warning. Previous versions of CMake interpreted empty strings as a relative path with respect to the current directory and removed its contents. file(RENAME Move a file or directory within a filesystem
from The options are: RESULT New in version 3.21. Set NO_REPLACE New in version 3.21. If the file(COPY_FILE New in version 3.21. Copy a file from The options are: RESULT Set ONLY_IF_DIFFERENT If the This sub-command has some similarities to See also the file(<COPY|INSTALL> Note For a simple file copying operation, the The New in version 3.15: If
and you do: file(COPY /opt/foo/lib/libfoo.so DESTINATION lib FOLLOW_SYMLINK_CHAIN) This will install all of the symlinks and See the The Installation scripts generated by the Changed in version 3.22: The environment variable
file(SIZE New in version 3.14. Determine
the file size of the file(READ_SYMLINK New in version 3.14. This subcommand queries the symlink Note that this command returns the raw symlink path and does not resolve a relative path. The following is an example of how to ensure that an absolute path is obtained: set(linkname "/path/to/foo.sym") file(READ_SYMLINK "${linkname}" result) if(NOT IS_ABSOLUTE "${result}") get_filename_component(dir "${linkname}" DIRECTORY) set(result "${dir}/${result}") endif() file(CREATE_LINK New in version 3.14. Create a link The Specifying file(CHMOD New in version 3.19. Set the permissions for the Valid combination of keywords are: PERMISSIONS All items are changed. FILE_PERMISSIONS Only files are changed. DIRECTORY_PERMISSIONS Only directories are changed. PERMISSIONS and FILE_PERMISSIONS
PERMISSIONS and DIRECTORY_PERMISSIONS
FILE_PERMISSIONS and DIRECTORY_PERMISSIONS Use file(CHMOD_RECURSE New in version 3.19. Same as CHMOD, but change the permissions of files and directories present in the Path Conversion¶file(REAL_PATH New in version 3.19. Compute the absolute path to an existing file or directory with symlinks resolved. BASE_DIRECTORY If the provided EXPAND_TILDE New in version 3.21. If the file(RELATIVE_PATH Compute the relative path from a file(TO_CMAKE_PATH " The The Always use double quotes around the Transfer¶file(DOWNLOAD The New in version 3.19: If Options to both INACTIVITY_TIMEOUT Terminate the operation after a period of inactivity. LOG Store a human-readable log of the operation in a variable. SHOW_PROGRESS Print progress information as status messages until the operation is complete. STATUS Store the resulting status of the operation in a variable. The status is a
TIMEOUT Terminate the operation after a given total time has elapsed. USERPWD New in version 3.7. Set username and password for operation. HTTPHEADER New in version 3.7. HTTP header for operation. Suboption can be repeated several times. NETRC New in version 3.11. Specify whether the .netrc file is to be used for operation. If this option is not specified, the value of the IGNORED The .netrc file is ignored. This is the default. OPTIONAL The .netrc file is optional, and information in the URL is preferred. The file will be scanned to find which ever information is not specified in the URL. REQUIRED The .netrc file is required, and information in the URL is ignored. NETRC_FILE New in version 3.11. Specify an alternative .netrc file to
the one in your home directory, if the TLS_VERIFY Specify whether to verify the server certificate for New in version 3.18: Added support to TLS_CAINFO Specify a custom Certificate Authority file for New in version 3.18: Added support to For Additional
options to
EXPECTED_MD5 Historical short-hand for RANGE_START New in version 3.24. Offset of the start of the range in file in bytes. Could be omitted to download up to the specified RANGE_END New in version 3.24. Offset of the end of the range in file in bytes. Could be omitted to download everything
from the specified Locking¶file(LOCK New in version 3.2. Lock a file specified by Note that lock is advisory - there is no guarantee that other processes will respect this lock, i.e. lock synchronize two or more CMake instances sharing some modifiable resources. Similar logic applied to Trying to lock file twice is not allowed. Any intermediate directories and file itself will be created if they not exist. Archiving¶file(ARCHIVE_CREATE OUTPUT New in version 3.18. Creates the specified Use the Some archive formats allow the type of compression to be specified. The New in version 3.19: The compression level can be specified with the Note With The To specify the modification time recorded in tarball entries, use the New in version 3.18. Extracts or lists the content of the specified The directory where the content of the archive will be extracted to can be specified using the If required, you may select
which files and directories to list or extract from the archive using the specified
New in version 3.24: The With When you enter the command touch Afile TXT in a directory what will happen?The only thing that happens when you run touch on an already existing file is that the file's access and modification timestamps are updated to the current time.
Which of the following redirection operators appends a command's standard output to an existing file without overwriting that original contents?The append >> operator adds the output to the existing content instead of overwriting it. This allows you to redirect the output from multiple commands to a single file.
Which of the following commands displays the name of the directory in which you are working?By default, the ls commands lists the contents of the working directory (i.e. the directory you are in). You can always find the directory you are in using the pwd command.
Which type of link might you use to create a link from your home directory on your hard disk to a directory on a CD ROM drive?17. You want to create a link from your home directory on your hard disk to a directory on a CD-ROM drive. Which of the following types of links might you use? Only a symbolic link.
|