summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Revise C++ coding style using clang-format-15Kitware Robot2023-01-181-1/+1
| | | | | | | | | | | | | | Run the `clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`. Use `clang-format` version 15. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit. Fixes: #24315
* file(COPY_FILE): Add option to retry on Windows if input access failsBrad King2022-11-171-1/+18
| | | | | | | | On Windows, a file may be inaccessible for a short time after it is created. This occurs for various reasons, including indexing, antivirus tools, and NTFS's asynchronous semantics. Add an `INPUT_MAY_BE_RECENT` option to tell CMake that the input file may have been recently created so that we can retry a few times to read it.
* cmSystemTools: Remove unused CopySingleFile overloadBrad King2022-11-171-7/+0
|
* file(COPY_FILE): Report if failure occurred on input or output pathBrad King2022-11-151-4/+14
| | | | | When we know whether a failure was associated with the input or the output path, include this information in the error message.
* cmSystemTools: Provide quiet link creation methodsBrad King2022-10-061-18/+25
| | | | Offer variants that let the caller handle error messages.
* cmSystemTools: Fix encoding of whole-environment lookup on Windowszhenhaonong2022-09-231-0/+9
| | | | | | | On Windows, `environ` is encoded by `CP_ACP`, which may be different from `KWSYS_ENCODING_DEFAULT_CODEPAGE`. When environment variables include a unicode character, they may be corrupted. Use `_wenviron` instead.
* cmSystemTools: Add MakeTempDirectoryMatthew Woehlke2022-09-051-1/+92
| | | | | | | | | | | | Add a cross-platform wrapper over mkdtemp. This will allow us to create guaranteed-unique directories. On POSIX platforms, this is simply a wrapper over mkdtemp. On Windows, we take a brute-force approach using C++11's random facilities and relying on attempts to create an existing directory resulting in an error. (This approach is very possibly how mkdtemp is implemented internally, and should be suitable for any platform if needed, although at present it only uses a partial set of substitution characters since Windows likely implies a case-insensitive file system.)
* cmake -E env: Add --modify flagAlex Reinking2022-08-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | When `cmake -E env` is given the `--modify` flag, try to parse the following argument as an `ENVIRONMENT_MODIFICATION` operation and apply it to the environment. This generalizes `--unset=`: 1. When implementing `ENVIRONMENT_MODIFICATION` features for other CMake commands, the `MYVAR=OP:VALUE` strings do not need to be translated to OP-specific flags. 2. This provides a natural and consistent extension point to introduce new operations without introducing very many flags. 3. Users need to learn only one syntax to access the same functionality. There is one difference between the behavior here as compared to CTest's interpretation of the `ENVIRONMENT_MODIFICATION` test property. The `MYVAR=reset:` command when run in `cmake -E env` will reset `MYVAR` to whatever its value was when `cmake -E env` launched, rather than try to checkpoint after plain `MYVAR=VALUE` options. This makes `MYVAR=VALUE` and `--modify MYVAR=set:VALUE` semantically equivalent.
* cmCTestRunTest: Implement the ENVIRONMENT test property with EnvDiff tooAlex Reinking2022-08-151-5/+18
| | | | | | | | Going through the same internal API for both `ENVIRONMENT` and `ENVIRONMENT_MODIFICATION` properties will make it easier to implement checkpointing for `MYVAR=reset:` more efficiently if the need ever presents itself. It also makes the two-stage nature of the environment mutation clearer in the code itself.
* cmSystemTools: Add EnvDiff class to hold ENVIRONMENT_MODIFICATION logicAlex Reinking2022-08-151-0/+121
| | | | Prepare to re-use this logic when enhancing `cmake -E env`.
* Merge topic 'windows-symlink-dir'Brad King2022-08-021-12/+2
|\ | | | | | | | | | | | | a4f1c0fac8 Windows: Revert "Prefer junctions for directory symlinks" Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7530
| * Windows: Revert "Prefer junctions for directory symlinks"Brad King2022-08-011-12/+2
| | | | | | | | | | | | | | | | | | | | Revert commit 5101d586c4 (Windows: Prefer junctions for directory symlinks, 2022-02-22, v3.24.0-rc1~575^2). Junctions do not support `../` and other non-canonical paths. Revert their use pending further investigation. Fixes: #23781 Issue: #23257
* | Merge topic 'refactor-win-ver'Brad King2022-07-261-0/+38
|\ \ | |/ | | | | | | | | | | ee047a68f2 cmSystemTools: Factor out method to get Windows OS version Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7509
| * cmSystemTools: Factor out method to get Windows OS versionBrad King2022-07-251-0/+38
| | | | | | | | Factor the implementation out of `cmGlobalGenerator`.
* | cmSystemTools: Fix unsetenv() fallbackRaul Tambre2022-06-261-2/+1
| | | | | | | | | | | | | | The fallback path boils down to putenv(). Calling that with a "=" sets the variable to an empty string. Use cmSystemTools::UnPutEnv() instead, which correctly handles unsetting variables on a variety of systems.
* | Source: Replace uses of sprintf with safer snprintfSean McBride2022-06-221-1/+1
|/
* cmSystemTools: Fix 'ErrorOccurred' spellingFeRD (Frank Dana)2022-06-131-3/+3
| | | | | | | | Rename the booleans 's_ErrorOccured' and 's_FatalErrorOccured' to 's_ErrorOccurred' and 's_FatalErrorOccurred', respectively. Rename the getters and setters to 'Get[Fatal]ErrorOccurred' and 'Set[Fatal]ErrorOccurred', and fix all uses across the codebase.
* clang-tidy: address `readability-container-data-pointer` lintsBen Boeckel2022-05-241-5/+5
|
* cmake-presets: add ${pathListSep} macroErin Melucci2022-05-121-0/+9
| | | | Fixes: #23282
* cmake -E tar: Add --touch optionKasper Laudrup2022-03-231-6/+12
| | | | | | | | Similar to GNU tar add a --touch option to the tar extract command to skip extracting the timestamps from the files in the archive effectively touching them as if they were just created. Issue: #22746
* Windows: Prefer junctions for directory symlinksSergei Kryvonos2022-03-011-2/+12
| | | | | | | | | Update the approach added by commit afb7f6e4ff (cmake: Add '-E create_symlink' support on Windows, 2018-06-11, v3.13.0-rc1~75^2) to use junctions, as suggested [here](https://superuser.com/a/1291446/140450). This allows them to work under security limitations on Windows. Fixes: #23257
* Merge topic 'rpath-unrecognized-format'Brad King2021-12-021-4/+21
|\ | | | | | | | | | | | | | | | | 643fc46bdc file(RPATH): Restore tolerance of unknown formats if new RPATH is empty 5596cba7dc cmSystemTools: Remove unnecessary mark-as-used casts to void Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !6779
| * file(RPATH): Restore tolerance of unknown formats if new RPATH is emptyBrad King2021-12-011-2/+21
| | | | | | | | | | | | | | | | | | | | | | Since commit 2e1149874d (cmSystemTools: Support multiple binary formats, 2021-06-14, v3.22.0-rc1~575^2) the `file(RPATH_...)` operations fail on files that are not ELF or XCOFF format. Previously the RPATH operations tolerated files of unknown format if the goal was to produce a file with an empty RPATH. Restore this tolerance in order to support setting an empty RPATH on GNU ld scripts. Fixes: #22963
| * cmSystemTools: Remove unnecessary mark-as-used casts to voidBrad King2021-12-011-2/+0
| | | | | | | | The `CheckRPath` arguments are always used now.
* | Source: Replace C headers with C++ onesRose2021-11-021-1/+1
| | | | | | | | In applicable areas only, of course.
* | bootstrap: Do not declare cmSystemTools functions that are not implementedBrad King2021-10-271-20/+4
| | | | | | | | Convert runtime error messages into compile-time errors.
* | Merge topic 'warnings-cleanup'Brad King2021-10-271-7/+7
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7e4e192ce2 Source: fix clang-tidy modernize-redundant-void-arg warning 8d671dd94c Source: fix more -Wmissing-prototypes warnings 1cf14f8c03 Source: fix many -Wmissing-prototypes warnings by marking functions static 319944b3d2 Source: fix some -Wunused-macros warnings 5257d9e71a Source: fix only -Wshorten-64-to-32 warning with explicit cast Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !6648
| * | Source: fix many -Wmissing-prototypes warnings by marking functions staticSean McBride2021-10-251-7/+7
| |/
* | Source: Replace most calls to sprintf with snprintfSean McBride2021-10-251-6/+8
|/
* Move helpers functions from cmStringAlgorithms.h to cmValue.hMarc Chevrier2021-09-211-0/+1
| | | | | Helpers functions related to cmValue semantic are now part of cmValue.h header.
* cmSystemTools::VersionCompare: use std::string for argumentsMarc Chevrier2021-09-171-8/+20
|
* Xcode: add support for embedding dynamic librariesLucas SOLTIC2021-09-131-0/+6
|
* cmArchiveWrite: Check for construction errors on OpenBrad King2021-08-201-1/+4
| | | | | | Also update call sites to report the error. Issue: #19666
* cmELF: Include the ELF parsing code unconditionallyAlex Richardson2021-06-241-33/+3
| | | | | Now that the ELF definitions are provided on all platforms there is no need to keep the CMake_USE_ELF_PARSER option.
* cmELF: Fix check for TagMipsRldMapRelAlex Richardson2021-06-241-2/+1
| | | | | | | DT_MIPS_RLD_MAP_REL is a machine-speicific dynamic tag, so other architectures could re-use the value of 0x70000035 to mean something else. Before using DT_MIPS_RLD_MAP_REL, we have to check that the ELF file is actually has a e_machine of EM_MIPS.
* cmSystemTools: Support multiple binary formatsAlex Richardson2021-06-211-76/+139
| | | | | This prepares the code to handle both the ELF and XCOFF being enabled by trying to parse an ELF file first and if that fails falling back to XCOFF.
* cmSystemTools: Add SetRPath() methodKyle Edwards2021-06-041-0/+32
|
* Refactor: Break up logic in cmSystemTools::ChangeRPath()Kyle Edwards2021-06-041-70/+108
|
* cmMessenger: Pass title inside a metadata structureMarius Messerschmidt2021-05-191-1/+9
|
* cmSystemTools: Adopt RelativeIfUnder helperBrad King2021-05-171-0/+14
| | | | This returns a relative path if it does not start in `../`.
* cmSystemTools: Improve CreateLink and CreateSymlink error codesBrad King2021-05-071-3/+15
| | | | | | | | | | | In commit 7f89053953 (cmSystemTools: Return KWSys Status from CreateLink and CreateSymlink, 2021-04-15) we just took the `-err` from libuv and treated it as a POSIX error. This is accurate on POSIX, but on Windows does not match the POSIX error codes. Use `uv_fs_get_system_error` to get the actual system error code. This requires libuv 1.38 or higher. Require that for Windows, but fall back to the previous approach on POSIX.
* Merge topic 'nvhpc-warnings'Brad King2021-04-291-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | f881b4e4cc cmCPackDebGenerator: Remove unused local variable 5ad8862318 Source: Convince NVHPC that RAII variables are used 1898f9dd82 cmFileCommand: Remove unused local variable 6a003c6f35 cmSystemTools: Avoid unreachable code warning on NVHPC 16275c7f82 LexerParser: Suppress NVHPC warnings in generated code cefda16d35 LexerParser: Regenerate parsers with bison 3.7.5 Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6049
| * cmSystemTools: Avoid unreachable code warning on NVHPCBrad King2021-04-281-1/+1
| |
* | MSYS: Add support for running under MSYS runtime environmentOrgad Shaneh2021-04-261-1/+5
|/ | | | Detect MSYS as CYGWIN, with the required adaptations.
* cmSystemTools: Return KWSys Status from CreateLink and CreateSymlinkBrad King2021-04-151-12/+12
|
* cmSystemTools: Simplify using KWSys StatusBrad King2021-04-141-31/+26
|
* Update CMake code using KWSys to account for Status return valuesBrad King2021-04-141-2/+2
| | | | | | KWSys as of 2021-04-14 changed the return type of `SystemTools` operations from `bool` to `Status`. Update our call sites. This may improve error reporting accuracy in a few places.
* Merge topic 'openbsd-defines'Brad King2021-04-141-3/+2
|\ | | | | | | | | | | | | 317a477283 OpenBSD: Fix system feature definitions Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6000
| * OpenBSD: Fix system feature definitionsRafael Sadowski2021-04-141-3/+2
| | | | | | | | | | | | | | | | Since commit f034b0f663 (CMake compilation: do not use compiler extensions, 2020-03-14, v3.18.0-rc1~494^2), some sources explicitly enable needed system APIs on some platforms using definitions like `_POSIX_C_SOURCE` and `_XOPEN_SOURCE`. Drop the definitions for OpenBSD, which provides the POSIX APIs by default.
* | Refactor: Add cmSystemTools::GetSystemName()Kyle Edwards2021-03-151-0/+47
| | | | | | | | And use it for CMAKE_HOST_SYSTEM_NAME and CMAKE_SYSTEM_NAME.