summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-07-07 14:28:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-07-07 14:28:37 (GMT)
commit304255a6c663e4c6f70beff1a826b81d67d2d4d1 (patch)
tree2dd5fbca885225e0817069f48887aa29e4c90d51 /Source/cmcmd.cxx
parentc7ddbfe9cc430f61399f37ab43ce92d057ec4fac (diff)
parent8a07bcc149d9c886cee924d9a68c8001b1011ae3 (diff)
downloadCMake-304255a6c663e4c6f70beff1a826b81d67d2d4d1.zip
CMake-304255a6c663e4c6f70beff1a826b81d67d2d4d1.tar.gz
CMake-304255a6c663e4c6f70beff1a826b81d67d2d4d1.tar.bz2
Merge topic 'msvc-embed-manifest-direct'
8a07bcc149 MSVC: Restore support for non-incremental linking without 'rc' in PATH Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8613
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index eb1f93d..ce2479b 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -2497,6 +2497,26 @@ int cmVSLink::LinkIncremental()
int cmVSLink::LinkNonIncremental()
{
+ // The MSVC link tool expects 'rc' to be in the PATH if it needs to embed
+ // manifests, but the user might explicitly set 'CMAKE_RC_COMPILER' instead.
+ // Add its location as a fallback at the end of PATH.
+ if (cmSystemTools::FileIsFullPath(this->RcPath)) {
+ std::string rcDir = cmSystemTools::GetFilenamePath(this->RcPath);
+#ifdef _WIN32
+ std::replace(rcDir.begin(), rcDir.end(), '/', '\\');
+ char const pathSep = ';';
+#else
+ char const pathSep = ':';
+#endif
+ cm::optional<std::string> path = cmSystemTools::GetEnvVar("PATH");
+ if (path) {
+ path = cmStrCat(*path, pathSep, rcDir);
+ } else {
+ path = rcDir;
+ }
+ cmSystemTools::PutEnv(cmStrCat("PATH=", *path));
+ }
+
// Sort out any manifests.
if (this->LinkGeneratesManifest || !this->UserManifests.empty()) {
std::string opt =